Forum > Embedded - ARM

STM32 interrupts

(1/3) > >>

petex:
hello,
I am trying to enable interrupts on the STM32 bluepill with the MBR framework and compiler.

I was trying to enable a character received interrupt on the uart1. When I press a key at the terminal I get an interrupt generated but it doesn't hit a breakpoint on the interrupt handler. I get vectored into the file "cortexm3_start.inc" which generally happens for any hardware fault.

The library calls are in "stm32f103fw.pas" which is a c to pascal conversion of the STM library.

As far as i can see there is no general documentation on this subject so the code has been constructed from what i can extract from tinternet. Why is this not working ???

A question :-
The interrupt handlers have alias names - are these essential or meant to be helpful ? I would have thought essential as how else is the handler code tied into the interrupt vector table. But am i using the right name ?


the initialisation code is as follows:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- procedure init_uart_intr;const    USART1_IRQn                 = 37;  begin     USART_ITConfig(USART1, USART_IT_RXNE, TState.Enabled);     NVIC.ISER[USART1_IRQn shr 5] := 1 shl (USART1_IRQn and $1F); //Enable Interrupt 
the interrupt handler is:-


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure UART_interrupt; public name 'USART1_global_interrupt'; interrupt;var     b : byte;begin     if USART_GetITStatus(USART1, USART_IT_RXNE)  then            b := USART_ReceiveData(USART1);     USART_ClearITPendingBit(USART1, USART_IT_RXNE)end;   
edit:
I get a breakpoint at "_PendSV_Handler " location in the vector table

MiR:
I am guessing here that you use -Wpbluepill to select the bluepill

Have a look at the code for the stm32f103rb:

procedure USART1_IRQHandler; external name 'USART1_IRQHandler';
procedure USART2_IRQHandler; external name 'USART2_IRQHandler';
procedure USART3_IRQHandler; external name 'USART3_IRQHandler';


I case you used -Wpstm32f10x (do not know the exact name here) then

procedure USART1_global_interrupt; external name 'USART1_global_interrupt';
procedure USART2_global_interrupt; external name 'USART2_global_interrupt';
procedure USART3_global_interrupt; external name 'USART3_global_interrupt';

can be found in the unit file for the chip.

This difference comes from the fact that the headers I created are automagically converted from CMSIS Sources and for that reason they are available for close to all cortex-m* chips available from ST today.

The older Headers were hand-crafted (I guess) so they do not follow the naming that is used in the CMSIS sources and may even be older than the CMSIS standard (which, when I remmber correctly was established when Arm bought Keil)

So it may very well be that you are now suffering from living in two worlds....

I started abstracting those differences in mbf-freertos as they are a pain when trying to develop with one sourcecode for several processors, check here how I have done it in MBF-Freertos:

https://github.com/michael-ring/mbf-freertos/blob/master/source/MBF.STM32F4.UART.pas


MiR

petex:
ok thanks.

I changed the interrupt handler header to


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure USART1_IRQHandler; interrupt; public name 'USART1_IRQHandler';var     b : byte;begin     if USART_GetFlagStatus(USART1,USART_FLAG_RXNE) then            b := USART_ReceiveData(USART1);     USART_ClearITPendingBit(USART1, USART_IT_RXNE)end;      
and  that did the trick. I get a breakpoint at my interrupt handler and it returns ok.

Is there a list of these alternative interrupt names or the file location ? thanks


And yes I am in two worlds ... I am using the MBF stuff as much as possible, but I need to dip into the STM32 library c to pascal conversion for missing bits.

MiR:
This directory has all the unit files for supported chips:

https://github.com/michael-ring/freepascal/tree/master/rtl/embedded/arm

This is the original of fpc-trunk:

https://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/rtl/embedded/arm/

when you want to see the file mapping which header actually gets used (there are some cases where this helps) look here:

https://github.com/michael-ring/freepascal/blob/master/compiler/arm/cpuinfo.pas

look for controllerunitstr

MiR

petex:
ok thanks

I have a hypothetical question here. From what I can see in the code - shown below - Is that the interrupt vector table has some gaps in it and is populated with nil pointers in places.
What would I need to do to extend this. For example if I was using the second uart and I wanted to have an interrupt handler for it.
I would need....

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure USART2_IRQHandler; external name 'USART2_IRQHandler'; and an entry ..

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---etc. etc. etc......long I2C1_IRQHandler  .long 0  .long SPI1_IRQHandler  .long 0  .long USART1_IRQHandler  .long USART2_IRQHandler    <<<<<<<------------------------  
or for example if i wanted to patch in a "Memory Manage" interrupt where there is currently a nil


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- procedure NonMaskableInt_Handler; external name 'NonMaskableInt_Handler';procedure HardFault_Handler; external name 'HardFault_Handler';procedure SVC_Handler; external name 'SVC_Handler';procedure PendSV_Handler; external name 'PendSV_Handler';procedure SysTick_Handler; external name 'SysTick_Handler';procedure WWDG_IRQHandler; external name 'WWDG_IRQHandler';procedure RTC_IRQHandler; external name 'RTC_IRQHandler';procedure FLASH_IRQHandler; external name 'FLASH_IRQHandler';procedure RCC_IRQHandler; external name 'RCC_IRQHandler';procedure EXTI0_1_IRQHandler; external name 'EXTI0_1_IRQHandler';procedure EXTI2_3_IRQHandler; external name 'EXTI2_3_IRQHandler';procedure EXTI4_15_IRQHandler; external name 'EXTI4_15_IRQHandler';procedure DMA1_Channel1_IRQHandler; external name 'DMA1_Channel1_IRQHandler';procedure DMA1_Channel2_3_IRQHandler; external name 'DMA1_Channel2_3_IRQHandler';procedure DMA1_Channel4_5_IRQHandler; external name 'DMA1_Channel4_5_IRQHandler';procedure ADC1_IRQHandler; external name 'ADC1_IRQHandler';procedure TIM1_BRK_UP_TRG_COM_IRQHandler; external name 'TIM1_BRK_UP_TRG_COM_IRQHandler';procedure TIM1_CC_IRQHandler; external name 'TIM1_CC_IRQHandler';procedure TIM2_IRQHandler; external name 'TIM2_IRQHandler';procedure TIM3_IRQHandler; external name 'TIM3_IRQHandler';procedure TIM14_IRQHandler; external name 'TIM14_IRQHandler';procedure TIM16_IRQHandler; external name 'TIM16_IRQHandler';procedure TIM17_IRQHandler; external name 'TIM17_IRQHandler';procedure I2C1_IRQHandler; external name 'I2C1_IRQHandler';procedure SPI1_IRQHandler; external name 'SPI1_IRQHandler';procedure USART1_IRQHandler; external name 'USART1_IRQHandler';  {$i cortexm0_start.inc} procedure Vectors; assembler; nostackframe;label interrupt_vectors;asm  .section ".init.interrupt_vectors"  interrupt_vectors:  .long _stack_top  .long Startup  .long NonMaskableInt_Handler  .long HardFault_Handler  .long 0  .long 0  .long 0  .long 0  .long 0  .long 0  .long 0  .long SVC_Handler  .long 0  .long 0  .long PendSV_Handler  .long SysTick_Handler  .long WWDG_IRQHandler  .long 0  .long RTC_IRQHandler  .long FLASH_IRQHandler  .long RCC_IRQHandler  .long EXTI0_1_IRQHandler  .long EXTI2_3_IRQHandler  .long EXTI4_15_IRQHandler  .long 0  .long DMA1_Channel1_IRQHandler  .long DMA1_Channel2_3_IRQHandler  .long DMA1_Channel4_5_IRQHandler  .long ADC1_IRQHandler  .long TIM1_BRK_UP_TRG_COM_IRQHandler  .long TIM1_CC_IRQHandler  .long TIM2_IRQHandler  .long TIM3_IRQHandler  .long 0  .long 0  .long TIM14_IRQHandler  .long 0  .long TIM16_IRQHandler  .long TIM17_IRQHandler  .long I2C1_IRQHandler  .long 0  .long SPI1_IRQHandler  .long 0  .long USART1_IRQHandler  

Navigation

[0] Message Index

[#] Next page

Go to full version