cancel
Showing results for 
Search instead for 
Did you mean: 

reading Timer Status Reg kills timer?

jlarsen
Associate
Posted on June 09, 2011 at 22:22

We are using the Atollic IDE.  After setting up TIM2,TIM3, or TIM4 to clock continuously.  We output the counter bits on PCx lines and monitor with a scope.

We read the registers directly using:

adr=0x40000???;

data=*((u16 *)(adr)); and then write the data to the PCx lines.

We can read all regs. with no problems except for the counter status regs at 0x40000?10.  If we read the status reg the counter stops.  This is for all status registers and any counter.  For example: if we read 0x40000810, the TIM4_SR, TIM2 will stop.  This seems really odd.  I might accept the fact that somehow reading TIM2_SR might mess with TIM2 but do not understand how it could mess with TIM4, etc.  We are trying to monitor the UIF and TIF flags.

Does anybody have any suggestions?  

#timer-status-reg
2 REPLIES 2
Posted on June 11, 2011 at 04:44

It does sound rather odd. While I haven't tried your method, if this were truly the case it would break a lot of code. Do you have the timers generating interrupts?

Perhaps you should examine the code generated by the compiler, and confirm it's doing what you expect.

You could post/attach a more complete example that demonstrates this phenomenon, which others could compile/test.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
jlarsen
Associate
Posted on June 12, 2011 at 22:16

Thanks clive1,

We looked at the disassembly, but it was exceedingly tedious and looked appropriate.

 

We then decided to strip everything from the code, including the stm32f10x headers.

 

We used only standard C include stdint.h for integer types.

 

We created everything from scratch including our own register address definitions.

 

Everything now works as it should; we can now read the timer status registers with no problem.

 

Our project has a short fuse and we will revisit the problem when time permits.

 

Thanks again!