Interrupt Service routine issue. STM32F4-discovery.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-04-18 2:23 PM
Hi,
I'm trying to use interrupt based UART. My code compiles without errors but when I debug it, it does not branch to any ISR in stm32f4xx_it.c from the vector table. I have enabled the interrupt using NVIC_Init function, is there any initializaion that I have missed out.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-04-18 3:42 PM
I'm trying to use interrupt based UART. My code compiles without errors but when I debug it, it does not branch to any ISR in stm32f4xx_it.c from the vector table. I have enabled the interrupt usingNVIC_Init function, is there any initializaion that I have missed out.
You've almost certainly done something wrong, but it's a little hard to tell what. Compiler errors simple tell you if you've sent them something completely bogus, it is not a validation of the underlying code. PA9/PA10 USART1 is NOT usable on the STM32F4-DISCOUp vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-04-19 8:21 AM
Hello Yora,
It's nearly impossible to help you without seeing your code, specifically the initialization of the vector table and your usart init code. The best thing we can do is point you to example code which are already available on the internet. But just guessing did you actually enable the interrupt you want to int on USART_ITConfig()? Did you follow all of the instructions at the top of stm32f4xx_usart.c[..]
(#) Enable peripheral clock using the following functions
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USARTx, ENABLE) for USART1 and USART6
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USARTx, ENABLE) for USART2, USART3,
UART4 or UART5.
(#) According to the USART mode, enable the GPIO clocks using
RCC_AHB1PeriphClockCmd() function. (The I/O can be TX, RX, CTS,
or/and SCLK).
(#) Peripheral's alternate function:
(++) Connect the pin to the desired peripherals' Alternate
Function (AF) using GPIO_PinAFConfig() function
(++) Configure the desired pin in alternate function by:
GPIO_InitStruct->GPIO_Mode = GPIO_Mode_AF
(++) Select the type, pull-up/pull-down and output speed via
GPIO_PuPd, GPIO_OType and GPIO_Speed members
(++) Call GPIO_Init() function
(#) Program the Baud Rate, Word Length , Stop Bit, Parity, Hardware
flow control and Mode(Receiver/Transmitter) using the USART_Init()
function.
(#) For synchronous mode, enable the clock and program the polarity,
phase and last bit using the USART_ClockInit() function.
(#) Enable the NVIC and the corresponding interrupt using the function
USART_ITConfig() if you need to use interrupt mode.
(#) When using the DMA mode
(++) Configure the DMA using DMA_Init() function
(++) Active the needed channel Request using USART_DMACmd() function
(#) Enable the USART using the USART_Cmd() function.
(#) Enable the DMA using the DMA_Cmd() function, when using DMA mode.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-04-21 8:58 AM
Thank you for replying.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-04-21 10:34 AM
With C++ you're going to need to be particularly conscious of name mangling, and whether your IRQHandler routines are actually the ones being linked via the vector table. Review the .MAP file, review a disassembly.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-04-21 10:36 AM
Let me also reiterate that you can't use PA9 on the STM32F4-DISCO for a USART pin. Please review the schematic.
The STM32F4-DIS-BB demonstrates the use of USART6 via PC6/PC7Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-04-21 10:47 AM
Thanks clive.Really appreciate the help. Will look into the .MAP file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-04-22 12:27 PM
I reviewed the Disassembly and the ISRs are not being linked correctly. Can you please guide me on linking the routines correctly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-04-22 1:09 PM
The USART interrupt routine does not return a value, and you must either use C linkage for the vector table, or insert the C++ mangled name
extern ''C'' void USART2_IRQHandler(void)
{
// ..
}
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-04-22 2:14 PM
That worked. Thanks Clive!
