I am using the MCBSTM32 evaluation board. I started with the "blinky" project.
I wanted to change it so that I could DMA a block of data from the ADC to memory. OK, I did that and it worked fine.
Next, I wanted to get an interrupt when the specified number of transfers had happened. I modified DMA1_Channel1_IRQHandler in stm32f10x_it.c to toggle a LED and set a flag when it happens. I also set the TCIE bit in DMA_CCR1
Being unfamiliar with the interrupt handler for this processor I looked at the code in STM32_Init.c for inspiration. In there I found that the initialization routines used the following:
NVIC->Enable[n] |= (1 << ( <Position > & 0x1F));
Where n is the 32 bit array element where the bit is in and Position represents the bit position in that element.
With that in mind, and finding no initilization for DMA interrupt, I implemented the following in my code immediately after I enable the DMA chanel:
NVIC->Enable[0] |= (1 << (DMAChannel1_IRQChannel & 0x1F));
Where DMAChannel1_IRQChannel is 0x0B and being the position is less than 32, it should go into the first array element.
Needless to say it does not work. I put a break point on the interrupt and it never breaks. It seems to fault, but gets to an area of code I do not recognise. It is in STM32f10x.s and is the point highlighted in the following:
<snip> EXTI15_10_IRQHandler RTCAlarm_IRQHandler USBWakeUp_IRQHandler B . ENDP ALIGN ; User Initial Stack & Heap IF :DEF:__MICROLIB <snip>
Any help or pointers would be appreciated.
Have you defined a Function and placed it in the Vector for DMAChannel1_IRQHandler? (By default, just having a function with this name and exporting it is enough to have it defined.)
It looks as if it is going to the default (which is just an infinite branch).
If you do have a routine call DMACHannel1_IRQHandler then knowing which interrupt is going there could be helpful too (Is it the ADC_IRQHandler?)
Thanks Leon and Robert, this was my problem.
I guess I should not trust the sample interrupt vector code. It specifies "void DMA1_Channel1_IRQHandler(void)", which as Leon noted does not match the startup code. My IRQ functions properly now.
Thanks!
Mark
View all questions in Keil forum