2012-09-21 12:20 PM
STM32F407: I use Timer2-5 in QEI configuration, and in my motor control loop (coming every 45usec) I need to read out the current position from TIM->CNT.
If I scan the values read out - it is strange that about every 50th read fails - some strange value will be returned (if the QEI is counting while I read out). I assume, this might be some sort of access problem, as the timer module accesses the value of CNT, and I want to read it? In the ref. manual I do not find any info concerning buffer / shadow register for TIM->CNT. Is there some special trick to read this register? (e. g. should I read it only with some special command, or width?) - or do I really need to read it out several times and check for equal return values (so that I read at a time when the counter just stayed stable?)? PS: Sorry, stupid question - I meanwhile recognized that my QEI input signal has stupid spikes - I think the processor is doing perfectly well.