2012-10-09 09:13 AM
I am new to the 32-bit world and am trying to generate an interruptable timer every 5us or so.
The application is an A/D read and the the channel has to settle for 30us before a read can occur. I am currently using the STM32L Discovery board because we will be using a similar chip for our platform.I tried using the systick but the best resolution I can get out of that is 20us at 32MHz.Any suggestions or something I have overlooked. Im coming from an 8-bit world mostly using Atmels and Freescales so Im unfamiliar with ST peripheral usage.Regards,Doug #timers2012-10-09 10:54 AM
I tried using the systick but the best resolution I can get out of that is 20us at 32MHz.
Should be able to get resolution/granularity of 250ns from SysTick A regular timer, depending on the period, should be able to get 31.25ns granularity in setting. Program the timebase, prescale = 0, period = 640 - 1, and enable the update interrupt. A bigger issue might be that you only have 640 cycles to play with.2012-10-09 11:01 AM
STM32L1xx_StdPeriph_Lib_V1.1.1\Project\STM32L1xx_StdPeriph_Examples\SysTick\SysTick_Example\main.c
if (SysTick_Config(SystemCoreClock / 50000)) { /* Capture error */ while (1); } STM32L1xx_StdPeriph_Lib_V1.1.1\Project\STM32L1xx_StdPeriph_Examples\TIM\TimeBase\main.c /* Time base configuration */ TIM_TimeBaseStructure.TIM_Period = 640 - 1; // Where TIMCLK2 = 32 MHz, 50 KHz timebase TIM_TimeBaseStructure.TIM_Prescaler = 0; TIM_TimeBaseStructure.TIM_ClockDivision = 0; TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure); /* TIM IT enable */ TIM_ITConfig(TIM2, TIM_IT_Update, ENABLE); /* TIM2 enable counter */ TIM_Cmd(TIM2, ENABLE);