2025-04-05 11:00 PM - edited 2025-04-05 11:10 PM
Looking for any suggestions.
I grabbed a Nucleo_F411RE board and hooked it up to a bog standard 600PPR rotary quadrature encoder and set up a basic test program in Cube IDE. I've done this a few times with F407 boards (my MCU of choice for most projects), never had a problem, but I couldn't get it to behave properly.
The code is trivial - standard TIM1 or TIM2 (tried both) encoder mode setup in CubeMX, then read the TIMx-CNT register once a second. No interrupts or anything, just standard CubeMX setup, latest CubeIDE as of today.
On the F411 it was doing weird things.
1. When the encoder was stationary, the count changed back and forth by one once every 500ms.
2. It consistently missed 75% of counts.
I beat my head against the wall for a while trying to figure out what I was doing wrong and couldn't see anything.
So, I pulled out a couple of F407VG boards (a custom one and a 307 Disco) and pulled the wires off the Nucleo and plugged them into the 407 boards, whipped up the same code, same settings, for that and it worked perfectly as expected.
Is there something weird about encoder mode on the F411? I searched about and couldn't find anything, and the RM0383 F411 Reference Manual doesn't show anything working substantially differently to the F407.
EDIT: Just a note that the F411 was on internal clock at 100MHz and the F407 on external HSE, in case that makes any difference. I can't see why it would! P1CLK and P2CLK were legal max on both.
Thanks,
Phil
Solved! Go to Solution.
2025-04-06 1:25 AM
I would try : set the F411 on HSE (8M, bypass , clock from st-link mco), to see, whether this has any effect on the behavior .
2025-04-06 1:25 AM
I would try : set the F411 on HSE (8M, bypass , clock from st-link mco), to see, whether this has any effect on the behavior .
2025-04-06 8:37 PM - edited 2025-04-06 8:54 PM
Thanks, I forgot about MCO from the ST-Link. I was too lazy to solder in the 8MHz crystal on the Nucleo. I don't use my Nucleos very often as I have a bunch of custom boards, but that's all I had for the F411, while I'm waiting for a black pill board (this is an open source project and black pill F411s are a good fit).
So, then, the next question is why? I'll repost on the bug forum. It's so weird that it would work on an external clock but not the internal oscillator. There must be something dodgy with my Nucleo, I, I can't believe that this is a bug. The timer runs off the APB clock, it wouldn't give a rats behind what the original clock source was as long as it's within spec (<=50MHz).