2012-08-30 10:44 AM
Hello everyone,
I am new to embedded programming. I was trying to make a simple program that measures frequency and ON time of two different i/p pulses. The frequency that I want to measure is in the range of 37 to 917 Hz where as On time is in msec range. I wrote a program using two timers, followed steps given for initialization in stdperipheral examples. The Problem is I am not reaching ISR even when event occurs. I dont know where I am going wrong. Any help will be highly appreciated..!! Thanks2012-08-30 11:03 AM
The Problem is I am not reaching ISR even when event occurs. I dont know where I am going wrong.
Me neither, sounds like an issue with initialization or vector table naming. If you expect productive answers try providing something for people to work with.2012-08-30 11:18 AM
2012-08-30 04:53 PM
Very similar to \STM32L1xx_StdPeriph_Lib_V1.1.1\Project\STM32L1xx_StdPeriph_Examples\TIM\InputCapture\main.c
The timers look to function a little different to the F1,F2 parts. Did you change the stm32lxx_it.c file? What tool chain are you using?2012-08-31 02:22 AM
Many thanks Clive1..!!
I am using IAR workbench. Do i need to use Remapping as you said in some earlier posts regarding timer input capture mode.GPIO_PinRemapConfig(GPIO_FullRemap_TIM1, ENABLE); Heres te code for stm32l1xx_it
void TIM4_IRQHandler(void) { if (TIM_GetITStatus(TIM4, TIM_IT_CC2) != RESET) { /* Clear TIM4 Capture compare interrupt pending bit */ TIM_ClearITPendingBit(TIM4, TIM_IT_CC2); if(CaptureNumber == 0) { /* Get the Input Capture value */ IC4ReadValue1 = TIM_GetCapture2(TIM4); CaptureNumber = 1; } else if(CaptureNumber == 1) { /* Get the Input Capture value */ IC4ReadValue2 = TIM_GetCapture2(TIM4); /* Capture computation */ if (IC4ReadValue2 > IC4ReadValue1) { Capture = (IC4ReadValue2 - IC4ReadValue1) - 1; } else if (IC4ReadValue2 < IC4ReadValue1) { Capture = ((0xFFFF - IC4ReadValue1) + IC4ReadValue2) - 1; } else { Capture = 0; } /* Frequency computation */ TIM4Freq = (uint32_t) SystemCoreClock / Capture; CaptureNumber = 0; } } }2012-08-31 02:39 AM
Also, how can i set prescaler value to measure 10 to 100s of msec pulse width??
2012-08-31 04:14 AM
Thanks Clive.., I found the problem. Sounds so stupid but I had set NVIC vector table in flash and was using RAM.
Now the problem is, in freq measurement, in the range of 100s its measuring perfectly but in 10 of hundreds its giving almost random readings.2014-02-22 12:35 AM