2018-06-13 10:38 PM
2018-06-14 12:59 AM
If I understand correctly, you are trying to count pulses of the measured signal in TIM2, gated by TIM21, set to 1 second period, correct?
As TIM2 is 16-bit only in 'L0, this cannot work higher than up to 65.535kHz. The demo you are mentioning, hasn't it been demonstrated on a different STM32 model?
You have to change your approach. There are many ways to do that. One of them is described here:
https://community.st.com/0D50X00009bMMA8SAO
JW
2018-06-14 03:16 AM
Thank you so much for the response. I know that the counter is only 16-bit. I can measure proper values upto 65KHz. After this, my OLED display shows me the overflow. This continues upto 72Khz. After this value, the frequency directly goes to 0. It does not record anything. That is what is confusing me.
2018-06-14 03:56 AM
As for the demo, it is for the STM32L053C8. It is able to measure frequency in MHz as well. And when I say overflow, I mean to say that it actually displays the difference between the actual frequency and 65535. I can easily print the right value for this as well. But what I am not able to understand, is why no frequency is measured after 72KHz.
2018-06-14 04:18 AM
can you rearrange your code ?
here is your error, commonly understood as a code 9
Raahul Jagannathan wrote:
/* USER CODE BEGIN 2 */
HAL_TIM_Base_Start(&htim2); HAL_TIM_IC_Start(&htim2, TIM_CHANNEL_1); HAL_TIM_Base_Start(&htim21); HAL_TIM_OC_Start(&htim21, TIM_CHANNEL_1);for high frequency you should configure a timer/counter as a counter.
count the pulses in 0.1seconds, and calculate the frequency.
the limit there is 1/2 input pin clocking frequency
what is the maximum pin clock frequency ?
what page in the reference manual are you on ?
2018-06-14 04:27 AM
Thank you for replying. I am not able to understand what you want me to do. If you could type out exactly what I am to change, it would be great. I did not have the time to look through the entire manual. I only read up on clocks and timers.
2018-06-14 05:00 AM
for high frequency you should configure a timer/counter as a counter.
count the PIN pulses in 0.1seconds, and calculate the frequency.
initialise one timer to interrupt to exactly 0.1sec
initialise the other timer to count pin input edges.
in the 0.1Sec interrupt, subtract this count value for the last count value, to get a relative difference in counts per 0.1Sec.
2018-06-14 05:05 AM
I did that. It records values up to 72999. The value of the frequency becomes 0 after this.
2018-06-14 05:43 AM
Raahul Jagannathan wrote:
I did that. It records values up to 72999. The value of the frequency becomes 0 after this.
HAL_TIM_Base_Start(&htim2);
HAL_TIM_IC_Start(&htim2, TIM_CHANNEL_1); HAL_TIM_Base_Start(&htim21); HAL_TIM_OC_Start(&htim21, TIM_CHANNEL_1);that is not what I suggested.
2018-06-14 05:58 AM