cancel
Showing results for 
Search instead for 
Did you mean: 

Am looking for beginner documentation on interrupts on STM32F3 series

Randy Nelson
Associate III
Posted on November 29, 2017 at 13:57

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

1 ACCEPTED SOLUTION

Accepted Solutions
Posted on November 30, 2017 at 15:00

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

View solution in original post

8 REPLIES 8
Randy Nelson
Associate III
Posted on November 29, 2017 at 14:29

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

Posted on November 29, 2017 at 15:05

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

http://www.st.com/content/ccc/resource/technical/document/programming_manual/5b/ca/8d/83/56/7f/40/08/CD00228163.pdf/files/CD00228163.pdf/jcr:content/translations/en.CD00228163.pdf

 

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

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on November 29, 2017 at 17:06

Clive,

Can you explain your '

interrupt vs queue to be serviced next' comment more?

Randy

Posted on November 29, 2017 at 17:41

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on November 29, 2017 at 22:43

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

Posted on November 29, 2017 at 23:17

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

Posted on November 30, 2017 at 01:20

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

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on November 30, 2017 at 15:00

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