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
causal has joined #rust-embedded
IlPalazzo-ojiisa has quit [Remote host closed the connection]
<re_irc> unsafe {
<re_irc> tim.psc.modify(|_, w| w.psc().bits(500));
<re_irc> <Stephen D> fn setup_timer(clocks: &Clocks, tim: &pac::TIM3) {
<re_irc> // set clock prescaler
<re_irc> <Stephen D> Not too concerned on the frequency - will sort that out once I get it running at all. The CNT register isn't budging from 0
<re_irc> <rjmp> Stephen D: did you enable the clock?
<re_irc> <rjmp> To verify that, are the config registers reading back the way you set them?
<re_irc> <Stephen D> rjmp: I have my clocks set up like this:
<re_irc> rcc.cfgr
<re_irc> .hclk(48u32.MHz())
<re_irc> .sysclk(48.MHz())
<re_irc> <Stephen D> rjmp: I don't think they are. I thought they might be write-only registers
<re_irc> <rjmp> Stephen D: Nope. You should be able to read back the value, and if you cannot, this usually means you have fallen victim to what I suspect is one of the most common STM32 problems of all time :).
<re_irc> <rjmp> You've got to enable clocks on a per-peripheral basis, generally speaking. You probably need something like: "rcc.apb1enr.modify(|_, w| w.tim3en().set_bit());"
<re_irc> <Dlaw> I am actually using the same stm32f411 peripheral right now (well, TIM4 instead of TIM3), and I ended up using the HAL to handle the clock enabling before dropping down to the PAC for register configuration. Not sure if this is useful at all, but here you go:
<re_irc> let _ = Timer::new(ctx.device.TIM4, &clocks); // use HAL to enable and reset
<re_irc> let timer: TIM4 = unsafe {
<re_irc> // Okay to steal because we just dropped our Timer(TIM4) reference
<re_irc> <Dlaw> (I should also add that I am new to Rust and I have no idea if this is considered the "right" way to do things)
<re_irc> < (@nihal.pasham:matrix.org)> question - do rust docs support permalinking (to specific line of text)?
<re_irc> < (@nihal.pasham:matrix.org)> I guess not but just wanted to check
crabbedhaloablut has quit [Ping timeout: 255 seconds]
crabbedhaloablut has joined #rust-embedded
<re_irc> <Stephen D> rjmp: Thanks! It's getting late but I'll try this out tomorrow
dc740 has joined #rust-embedded
gordea has quit [Quit: gordea]
cr1901 has quit [Read error: Connection reset by peer]
cr1901 has joined #rust-embedded
cr1901_ has joined #rust-embedded
cr1901_ has quit [Remote host closed the connection]
dc740 has quit [Remote host closed the connection]
crabbedhaloablut has quit [Remote host closed the connection]
crabbedhaloablut has joined #rust-embedded
jr-oss has quit [Ping timeout: 265 seconds]
IlPalazzo-ojiisa has joined #rust-embedded
crabbedhaloablut has quit [Ping timeout: 255 seconds]
crabbedhaloablut has joined #rust-embedded
causal has quit [Quit: WeeChat 3.7.1]
<re_irc> <Stephen D> Dlaw: Thanks, this seems to work! My ADC still isn't getting triggered so I have more to look into but the timer "cnt" register is clearly getting incremented now
<Darius> Stephen: make sure the ADC clock is also on :D
<re_irc> <Stephen D> Darius: let mut adc = Adc::adc1(
<re_irc> true,
<re_irc> AdcConfig::default()
<re_irc> adc,
<Darius> I haven't used it on Rust so not sure, but make sure the ADC clock is enabled in teh RCC block
crabbedhaloablut has quit [Remote host closed the connection]
crabbedhaloablut has joined #rust-embedded
<re_irc> <Stephen D> Darius: According to the docs the Adc::adc1 method will enable the clock
crabbedhaloablut has quit [Remote host closed the connection]
crabbedhaloablut has joined #rust-embedded
<Darius> OK
<re_irc> <Dlaw> I was confused about how Adc::adc1 enables the ADC clock without &Clocks being passed in. Turns out it does it with an unsafe pointer to the RCC.
<re_irc> <Dlaw> I'm confused about why the ADC HAL and timer HAL handle initialization differently ("Adc::adc1()" vs "Timer::new(TIM4, &clocks)")
<re_irc> <Dlaw> i.e. why not "Timer::tim4()" or "Adc::new(ADC1, &clocks)"
<re_irc> <Dlaw> So now I'm confused about why the ADC HAL and timer HAL handle initialization differently ("Adc::adc1()" vs "Timer::new(TIM4, &clocks)")
<re_irc> < (@adamgreig:matrix.org)> I think timer needs clocks to know what frequencies the various clock domains are so that you can configure a timer in terms of frequency
<re_irc> < (@adamgreig:matrix.org)> It can't read that from registers because it often depends on an external clock freq
<re_irc> <Dlaw> Ah, that makes sense. ADC sidesteps it by configuring its sample time in cycles rather than seconds. https://docs.rs/stm32f4xx-hal/latest/stm32f4xx_hal/adc/config/enum.SampleTime.html
<re_irc> <Dlaw> Clocks aside, is there a meaningful difference between Thing::new(INSTANCE) vs Thing::instance()?
crabbedhaloablut has quit [Ping timeout: 255 seconds]
crabbedhaloablut has joined #rust-embedded
<re_irc> < (@marmrt:matrix.org)> Yes, Thing::new(INSTANCE) consumes INSTANCE and ensures that INSTANCE cannot be used safely elsewere
<re_irc> < (@marmrt:matrix.org)> the Adc::adc1() method also consumes ADC1
<re_irc> < (@marmrt:matrix.org)> To clarify, there is no difference between Thing::new(INSTANCE) and Thing::instance(INSTANCE)
<re_irc> <Dlaw> Ah, I see, thanks. I misread a call to Adc::adc1() and didn't see ADC1 being passed in.
IlPalazzo-ojiisa has quit [Quit: Leaving.]
bjc has quit [Remote host closed the connection]
emerent has quit [Ping timeout: 255 seconds]
emerent_ has joined #rust-embedded
<steew> Hello, I am hitting a wall here.
<steew> I'm trying to make a weak symbol for some function, lets call it extern "C" fn GPIO_interrupt();
<steew> I am using a linker script where I do PROVIDE(GPIO_interrupt, somefunction);, where somefunction is defined as a pub fn
<steew> lld is complaining that it cannot find a reference to GPIO_interrupt, but it supposedly should be replacing it with somefunction if it is not defined, right?
<steew> I am pretty sure I am doing it exactly the same as cortex-m-rt here: https://github.com/rust-embedded/cortex-m-rt/blob/master/link.x.in
jr-oss has joined #rust-embedded
IlPalazzo-ojiisa has joined #rust-embedded
jr-oss_ has joined #rust-embedded
jr-oss has quit [Ping timeout: 268 seconds]
jrgriffiniiieth[ has quit [Quit: Bridge terminating on SIGTERM]
dne has quit [Remote host closed the connection]
dne has joined #rust-embedded
jrgriffiniiieth[ has joined #rust-embedded
<re_irc> < (@adamgreig:matrix.org)> steew: Is it also no_mangle?
<steew> Yes, It is
<steew> I have to note, i finally found a fix
<steew> I think I'm doing something wrong when adding the linker scripts to cargo's path, for some reason it was not being caught, and renaming it to link.x overrides the one in riscv-rt's
<steew> I did some temp hack to import my script in other .x file and it worked now
<steew> I really have to clarify how does cargo look for linker scripts
IlPalazzo-ojiisa has quit [Remote host closed the connection]
<re_irc> < (@Ericson2314:matrix.org)> Does anyone know about getting debug info to work with ARM rwpi?
<re_irc> < (@Ericson2314:matrix.org)> I am getting link errors from invalid relocations in ".debug_info" sections, which is annoying as those sections are not actually loaded
<re_irc> < (@Ericson2314:matrix.org)> "(.debug_info+0x35): has non-ABS relocation R_ARM_SBREL32 against symbol" errors like that
<re_irc> < (@Ericson2314:matrix.org)> the issue might be that we are using "--emit-relocs"]
<re_irc> < (@Ericson2314:matrix.org)> * "--emit-relocs"\
<re_irc> < (@Ericson2314:matrix.org)> * "--emit-relocs"
<re_irc> < (@chrysn:matrix.org)> As much as I prefer working without alloc, I'm suffering a family of dependencies I can't make no_alloc in reasonable time. Is there any alloc implementation worth recommending for bare metal systems? (The awesome list has none).
<re_irc> < (@adamgreig:matrix.org)> there's https://github.com/rust-embedded/alloc-cortex-m which is a wrapper around https://crates.io/crates/linked_list_allocator, I understand some more modern alternatives include things like https://github.com/FluenTech/tlsf
<re_irc> < (@chrysn:matrix.org)> Thanks, I'll have looks at those.
<re_irc> < (@dirbaio:matrix.org)> : I don't think ropi/rwpi is supported in Rust right now. see https://github.com/rust-embedded/cortex-m-rt/issues/320
neceve has quit [Quit: ZNC - https://znc.in]
neceve has joined #rust-embedded