cancel
Showing results for 
Search instead for 
Did you mean: 

timer 2 and its channel

gfoujanet
Associate II
Posted on August 20, 2013 at 16:57

Hello,

I am working for 6 months with the Timer 2 of a STM32L15x.

I use the channel 2 to capture the timer value; 

The pin used is PB3.

My application is working fine.

Now, for an hardware problematic, I need to use the channel 3. So I mapped channel 3 and PB10. 

Now the application is working, but some values are not accurate.

I understand that my problem is not very understanding;

But I would like to know if you have already work with the timer 2 and channel 2 and 3, and if the expected results are ok?

thank you very much.

#timer2-channel-accuracy
3 REPLIES 3
Posted on August 20, 2013 at 17:11

I think you are narrowing your potential audience to the point you'll get no answer.

I wouldn't expect PB3 (TIM2_CH2 - JTDO/SWO) vs PB10 (TIM2_CH3) if configured correctly to be materially different in function. Certain modes of operation, like encoder, would not be available, based on internal signal routing and configuration.

You'd want to review your board schematic to determine if anything electrically different is causing a problem.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
gfoujanet
Associate II
Posted on August 21, 2013 at 11:47

Thanks,

So, to be understandable , some explanations are useful.

With a function generator, there is a Pulse signal of 1200Hz injected. 

I configure the timer 2 of the STM32L152zd (EVAL board ) to capture the value of the timer at each rise edge of the pulse, and then the value timer is reseted. So we count from 0 to the pulse. 

In the interrupt of the TIM2, I save 50 values of the capture, and then, with GDB, I print theses values.

When I use the Channel 2 mapped on PB3, captures values are: 

  {26688, 26694, 26693, 26688, 26689, 26686, 26691, 26688, 26686, 26691, 26685, 26690, 26678, 26676, 26682, 26678, 26685, 26683, 26682, 26684, 26688, 26688, 26688, 26680, 26685, 26685, 26689, 26691, 26693, 26691, 26691, 26689, 26690, 26696, 26693, 26692, 26687, 26689, 26687, 26686, 26687, 26684, 26688, 26680, 26686, 26683, 26681, 26684, 26686, 26675}

==> We can see that values are +/- constants., With other pin mapped on channel3, it's also ok.

With the channel 3 mapped on PE11, captures values are:

{19403, 46080, 7224, 33893, 60568, 21708, 48381, 9528, 36219, 62905, 24051, 50734, 11887, 38580, 65268, 26422, 53109, 14256, 40932, 2077, 28764, 55455, 16603, 43296, 4450, 31139, 57831, 18985, 45674, 6829, 33531, 60230, 21392, 48087, 9242, 35930, 62616, 23771, 50462, 11618, 38309, 64998, 26148, 52833, 13984, 40675, 1829, 28516, 55208, 16365}

==> values are not constant. If I try other Pin mapped on Channel3, it's the same thing.

When I read the STM32L152D-EVAL user manual, I don't find a device connected to GPIO E. 

I hope that is more understandable now.

GF

Posted on August 21, 2013 at 14:04

Doesn't PE11 conflict with the FSMC external bus connecting to the RAM/NAND/LCD? You'd want to double check the pin configuration, and usage.

Perhaps you want to try something like an STM32L-Discovery board with less pin conflicts.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..