ChanServ changed the topic of #rust-embedded to: Welcome to the Rust Embedded IRC channel! Bridged to #rust-embedded:matrix.org and logged at https://libera.irclog.whitequark.org/rust-embedded, code of conduct at https://www.rust-lang.org/conduct.html
GrantM11235[m] has quit [Quit: Idle timeout reached: 172800s]
starblue1 has quit [Ping timeout: 260 seconds]
starblue1 has joined #rust-embedded
cinemaSundays has joined #rust-embedded
takkaryx[m] has joined #rust-embedded
<takkaryx[m]> ooo, now I have slides to watch when I listen, this is both a blessing and a curse, I listened to it on a bike ride before, but now I can understand more about what is being talked about!
crabbedhaloablut has quit []
crabbedhaloablut has joined #rust-embedded
cinemaSundays has quit [Quit: Connection closed for inactivity]
sugoi has quit [Ping timeout: 252 seconds]
sugoi has joined #rust-embedded
sugoi has quit [Ping timeout: 244 seconds]
tr09[m] has joined #rust-embedded
<tr09[m]> Hi, I’m bit-banging a buzzer to make some beeps and noticed pitch goes up when SWD has made a connection until power is cycled. It’s based on rtic v1 tasks and runs on nrf52. Is this overclocking supposed to happen and what other clock rates might be changing? (UART seems to become less reliable)
<JamesMunns[m]> it might not be actually raising in pitch, but the jitter might be causing harmonics. It would be interesting to look at with a scope or logic analyzer. The nrf52 definitely doesn't have any concept of overclocking, as far as I know
emerent has quit [Ping timeout: 246 seconds]
emerent has joined #rust-embedded
<tr09[m]> I’ll try to get some scope readings
<JamesMunns[m]> When you say bit-banging, are you using any peripherals at all, or just busy loops?
<JamesMunns[m]> Attaching the debugger does change some things, but not necessarily CPU speed. Off the top of my head, it does enable hfclk, and might inhibit sleep modes that could mean you do some things "faster"? Hard to tell without looking at your code tho.
<JamesMunns[m]> The things affected by the debugger aren't disabled until a power cycle, so it does somewhat match your symptoms
<JamesMunns[m]> some stuff says there might be 10us delay from a wake event (if you are sleeping waiting for a timer, which could happen if rtic is otherwise idle), for a 440hz tone (50% low, 50% high, toggle every 1136us), that could mean you are actually toggling every 1146us, which would be 0.8% slower than you expect, which would mean you are actually playing a 436.3hz tone.
<JamesMunns[m]> IF you aren't compensating for this wakeup delay (using a continuous timer), AND you do have wakeup delay without the debugger, AND the debugger inhibits sleep meaning you stop having the 10us delay, then actually I could see this being the case, if the change is only subtle. 436 -> 440hz is a noticable shift (you can hear it here, select square wave: https://onlinetonegenerator.com/)
<JamesMunns[m]> if it's a way bigger shift (2x or 4x frequency or something), then it's probably not that. The effect would be more noticable on higher frequencies, piezos usually recommend something like 4kHz, which would be 125us per toggle, so you'd be at 3.7kHz with the extra delay vs 4.0kHz without it
<JamesMunns[m]> 440 -> 436 is just a little flat, but 4.0k -> 3.7k is a little more than a semitone flat (B natural 7ish to B flat 7ish)
<JamesMunns[m]> yeah, if your scope shows a difference of 10 ish us before and after, then I would bet it is that.
<tr09[m]> First one is after debugger establishes connection
<JamesMunns[m]> yep, 21.93us difference in period
<JamesMunns[m]> which is 2 x 10us, give or take
M9names[m] has quit [Quit: Idle timeout reached: 172800s]
<JamesMunns[m]> oh, fourth fix: replace the idle task with loop { cortex_m::asm::nop() }, which will eliminate sleeping when idle, which means you never pay the wakeup cost
<JamesMunns[m]> but imo, using PWM is the best option, and using a hardware timer is the second best option.
<tr09[m]> The tone is just the symptom and i wanted to figure out the cause because it correlated with UART problems. Ideally yes, I should revisit PWM because I caused some panics when swapping buffers.
<tr09[m]> * swapping buffers when I first tried it.
<JamesMunns[m]> uart problem could be switching on the hfclk? that might force the 16mhz peripheral clock to be on instead of the low power 1mhz peripheral clock, which could give a slight change in error margin on the uart?
<tr09[m]> Clock setup is .enable_ext_hfosc().set_lfclk_src_synth().start_lfclk()
<tr09[m]> Wait a minute… lfclk?
<JamesMunns[m]> lfclk is the 32khz clock, usually used for low power sleeps
<JamesMunns[m]> nrf52 has two clock "kinds", hfclk (internal or external oscillator, used to generate 1/16/64mhz clock domains), and lfclk, which runs the 32khz clock domain
<JamesMunns[m]> the high frequency clocks on the nrf52 are dynamic: they run at the slowest speed they think they can get away with
<JamesMunns[m]> so if you are setting 115200, it might only enable the 1mhz lower power peripheral clock
<JamesMunns[m]> but if the debugger forces the higher power 16mhz peripheral domain on instead, then the uart will use 16mhz as the base frequency instead of 1mhz
<JamesMunns[m]> it should compensate for this correctly, but there are rounding errors in baudrate calculation (neither frequency divides by 115200 evenly), 16mhz might have a worse rounding error?
<JamesMunns[m]> idk, this is all a guess
<JamesMunns[m]> Also since you are using hfclk internal instead of hfclk external, you will already have a higher error % for PLL generated 1/16/64 clock domain numbers
<JamesMunns[m]> could be stacking tolerances? Your scope will show you the real picture though.
<tr09[m]> Yeah it seems I have some measuring to attend to.
<tr09[m]> Thanks for your help.
sugoi has joined #rust-embedded
<JamesMunns[m]> JamesMunns[m]: ah sorry, no, you are using internal lfclk, but external hfclk. Ignore this part :)
<JamesMunns[m]> (there's still some room for error, but it's generally pretty small if you have a good external crystal circuit)
<JamesMunns[m]> baudrate error is still a potential thing tho: https://devzone.nordicsemi.com/f/nordic-q-a/79977/uart-baudrate-is-inaccurate
sugoi has quit [Ping timeout: 264 seconds]
<tr09[m]> JamesMunns[m]: Let’s just say this has been dealt with (SPI <-> UART chip)
<tr09[m]> .im_feeling_lucky()
starblue1 has quit [Ping timeout: 246 seconds]
starblue1 has joined #rust-embedded
ben[m] has quit [Quit: Idle timeout reached: 172800s]
Mark[m] has quit [Quit: Idle timeout reached: 172800s]
jasperw has quit [Ping timeout: 272 seconds]
jasperw has joined #rust-embedded
chrysn[m] has joined #rust-embedded
<chrysn[m]> Many chips have some unique IDs, and when flashing (or provisioning through flashing), it'd be handy to access them.
<chrysn[m]> Would it be fitting for probe-rs to add to the chip descriptions the memory areas of Device ID (or comparable) registers, so that a user could see in probe-rs info which precise instance is connected, and could run probe-rs attach --protocol swd --chip nrf52840_xxAA --chip-id 001122334455667788 to be sure to get the right chip by identity (without the need to create a mapping between the physical device and the precise debugger
<chrysn[m]> / USB port it is attached to)?
<JamesMunns[m]> IIRC device ID is not handled consistently, I think there's talk of building a database to get the chip ID, but that requires custom code for every kind of chip?
<JamesMunns[m]> like, I don't *think* there's a cortex-m standard for "chip id goes at this addr"
<chrysn[m]> Device ID is not handled consistently, but should be relatively straightforward to add for individual chips.
<JamesMunns[m]> iirc even on stm32, there were numerous different ways this was exposed
<JamesMunns[m]> not saying it can't be done! Just that there would be a lot of work for writing a db of all the places you have to look based on the selected --chip
<chrysn[m]> For example, for all the nRF5x chips that would be reading two consecutive registers (FICR.DEVICEID[0..=1])
<JamesMunns[m]> this has been discussed in #probe-rs:matrix.org before, I believe
marmrt[m] has joined #rust-embedded
<marmrt[m]> The unique IDs of ATSAME70 is in a separate flashbank, so you would need a RAM function that switches the flash bank to the ID one, read it, and then switch back
<JamesMunns[m]> the rp2040 doesn't have a chip id, though most tooling will use the ID of the external QSPI flash
<JamesMunns[m]> but that also requires custom blocking flash commands to obtain
<chrysn[m]> I didn't find any discussion of it in probe-rs issues, but happy to ask there.
<chrysn[m]> I did expect that it'll be more difficult on other chips; RAM functions and reading external flash does however sound tedious.
<chrysn[m]> (It just so happens that my favorite chips over time, EFM32 series and nRF52, all have it similarly easy…)
<JamesMunns[m]> I do agree it would be extremely cool to have that ability :)
<JamesMunns[m]> and it could be worth doing it progressively: add a db of "how to do it", and fill out all the easy ones, and tackle the hard ones later?
<JamesMunns[m]> and if you ask for a chip that the db doesn't know, it can just say "that chip isn't supported yet, see tracking issue for how to add support"
dinkelhacker_ has joined #rust-embedded
d5[m] has quit [Quit: Idle timeout reached: 172800s]
sugoi has joined #rust-embedded
sugoi has quit [Ping timeout: 248 seconds]
xnor has joined #rust-embedded
sugoi has joined #rust-embedded
dinkelhacker_ has quit [Quit: Client closed]
<dirbaio[m]> you can't know the chip id without attaching first
<dirbaio[m]> while you can know the probe vid:pid:serial
<dirbaio[m]> so to make probe-rs attach --chip-id 001122334455667788 work it'd have to try attaching to every single probe it sees
<dirbaio[m]> and attaching is a somewhat disruptive operation
jasperw has quit [Read error: Connection reset by peer]
jasperw- has joined #rust-embedded
<JamesMunns[m]> (this conversation has moved over to #probe-rs:matrix.org, might be good to follow there so we don't end up talking in two places)
DominicFischer[m has quit [Quit: Idle timeout reached: 172800s]
ryan-summers[m] has quit [Quit: Idle timeout reached: 172800s]
IvanSanchez[m] has quit [Quit: Idle timeout reached: 172800s]
AtleoS has joined #rust-embedded
vollbrecht[m] has quit [Quit: Idle timeout reached: 172800s]
firefrommoonligh has quit [Quit: Idle timeout reached: 172800s]
GntherJena[m] has quit [Quit: Idle timeout reached: 172800s]
danielb[m] has quit [Quit: Idle timeout reached: 172800s]
geky[m] has quit [Quit: Idle timeout reached: 172800s]
therealprof[m] has quit [Quit: Idle timeout reached: 172800s]
Ralph[m] has quit [Quit: Idle timeout reached: 172800s]
bartmassey[m] has quit [Quit: Idle timeout reached: 172800s]
jannic[m] has quit [Quit: Idle timeout reached: 172800s]
henrik_alser[m] has quit [*.net *.split]
AlexandrosLiarok has quit [*.net *.split]
edm has quit [*.net *.split]
SanchayanMaity has quit [*.net *.split]
henrik_alser[m] has joined #rust-embedded
SanchayanMaity has joined #rust-embedded
AlexandrosLiarok has joined #rust-embedded
edm has joined #rust-embedded
<i509vcb[m]> I've heard of embeddedworld-na, is it worth going just for the expo part? Considering currently
<i509vcb[m]> I live close enough in Texas where it isn't an issue to go (2 hour drive)
henrik_alser[m] has quit [Quit: Idle timeout reached: 172800s]
diondokter[m] has quit [Quit: Idle timeout reached: 172800s]
RockBoynton[m] has quit [Quit: Idle timeout reached: 172800s]
kentborg[m] has quit [Quit: Idle timeout reached: 172800s]
sugoi has quit [Ping timeout: 246 seconds]
andar1an[m]1 has quit [Quit: Idle timeout reached: 172800s]
explodingwaffle1 has joined #rust-embedded
Jubilee[m] has quit [Quit: Idle timeout reached: 172800s]