2024-10-11 03:22 AM
I've wrote a code without using Hal to produce a signal on the scope but i'm not getting any signal on my pin.
This is on a NUCLEO F401RE. Using TIMER3_CHANNEL1 and GPIOB for my Alternate function.
Solved! Go to Solution.
2024-10-13 04:17 AM
Is the goal to write the most inefficient code, that's hard to maintain too?
TIM3_CH1 is AF2 on PB4
ARR and PSC are set as N-1 values
2024-10-11 04:50 AM
>I've wrote a code without using Hal to produce a signal on the scope but i'm not getting any signal
So use Cube/HAL , to see, how its done. Even if you dont like it.
2024-10-12 10:17 AM
Read out and check/post content of TIM and relevant GPIO registers.
> GPIOB->AFR[0]|= (1U<<18);
This sets AFR for PB4 to 0b0100 = 4, that's not what you want.
JW
2024-10-13 03:48 AM
This is a reference of the datasheet. The reset values are 0's hence, I am trying to SET pin 18 and leave the rest to 0 as highlighted. Not sure what you meant by saying that's not what I want ? Any further explanation would be helpful . Thanks
2024-10-13 04:17 AM
Is the goal to write the most inefficient code, that's hard to maintain too?
TIM3_CH1 is AF2 on PB4
ARR and PSC are set as N-1 values
2024-10-18 01:47 AM
I've made changes and took on your advice , wasn't getting a signal still when I run it . I know when using CUBE/HAL you need to set the clock config tree, and as I'm writing manually I don't have anything set for it ,could that be the issue?
2024-10-19 09:19 AM - edited 2024-10-19 09:19 AM
You should have some output without configuring the clocks in RCC, too, as the whole mcu runs out of the default HSI RC oscillator at 16MHz.
Read out and check/post content of TIM and relevant GPIO registers.
JW
2024-10-19 01:40 PM - edited 2024-10-20 01:53 AM
How about:
TIM3->CCER = TIM_CCER_CC1E;
Use bit names instead of magic numbers!
Also, timer clock frequency is 84 MHz (2 x ABP1 frequency).
2024-10-19 03:26 PM
Nice catch!
JW