2017-11-29 04:57 AM
With the community's help I have code that runs and demonstrates interrupts and interrupt handling. I need more information to understand how the STM32F3 series parts process event changes (interrupts) such as the SysTick and GPIOs and setting their priorities. All the docs I can easily find indicates the internal hardware but does not explain how to put the hardware (registers) together. Yes I have STD code examples (thanks to the community) but no foundation to understand what the settings are doing.
Can someone point to some documentation or suggest a way to get this experience/knowledge.
Thanks...
Randy
Solved! Go to Solution.
2017-11-30 07:00 AM
JW, Clive
Both great ideas. Used Clive's idea of having the free running clock and JW's idea of resetting the 'count' at the start. Simple idea and clean code.
Thanks to both!
Randy
2017-11-29 05:29 AM
More info. I'm trying to understand why my SysTick handler is not being called while in the handler for a GPIO pin changing. I'm wondering if this is a priority issue.
Randy
2017-11-29 06:05 AM
More likely NVIC preemption level, ie can I interrupt an interrupt vs queue to be serviced next.
Joseph Yiu's Essential Cortex-Mx books would be good for this, ARM also has Technical Reference Manuals for their cores, which include the NVIC
ST has programming manuals, this for the M3 showed up in a quick search, there should be an M4 one also
The SPL is documented in several ways
There is the library source, the examples, and a Windows Help file in the root directory
\STM32F30x_DSP_StdPeriph_Lib_V1.2.3\stm32f30x_dsp_stdperiph_lib_um.chm
2017-11-29 09:06 AM
Clive,
Can you explain your '
interrupt vs queue to be serviced next' comment more?
Randy
2017-11-29 09:41 AM
When you exit one IRQHandler (bx lr) it triggers the NVIC to either exit interrupt state or start the next highest priority interrupt pending (Tail Chaining). In the model a low number has highest priority, and where not called out (differentiated) the interrupt number.
The NVIC has programmable grouping, an allocation of priority vs preemption.
The SysTick is a System Handler rather than an Interrupt, so some settings live in the SCB rather than the NVIC
To 'interrupt an interrupt' you need something to have a high preemption level, otherwise the new interrupt will pend in the NVIC and get serviced in order as the current one exits.
One should generally avoid using software counters for time outs, ie use a 32-bit TIM rather than a variable you increment in an interrupt.
2017-11-29 02:43 PM
I've implemented Timer2 as my time out. Using this timer I can control the interrupt priority in relationship to my GPIO handler. It seems to work and do as designed but it is not consistent.
When my GPIO interrupt occurs I enable the timer at the start of the GPIO handler. At the end of my GPIO handler I disable the timer. But if this same GPIO event occurs and I am again in the handler and again enable my timer, the count does not do the full count.
Is there a proper way to always have a count up timer to always start at 0 when re-initialized.
Thanks for the help and suggestions.
Randy
2017-11-29 03:17 PM
Is there a proper way to always have a count up timer to always start at 0 when re-initialized.
I don't know what do you mean by 're-initialized'. Write 0 to TIMx_CNT if you want to zero it.
JW
2017-11-29 05:20 PM
Generally I'd free run a 32-bit TIM and measure elapsed time by doing a delta between entry and current time via the count register, and letting the unsigned math handle the wrapping. ie (current - start) > timeout
2017-11-30 07:00 AM
JW, Clive
Both great ideas. Used Clive's idea of having the free running clock and JW's idea of resetting the 'count' at the start. Simple idea and clean code.
Thanks to both!
Randy