AnsweredAssumed Answered

Configuration of USART4 interrupts STM32F030CC

Question asked by karlis77 on Feb 16, 2016
Latest reply on Feb 16, 2016 by Clive One
Hello everyone.
I am beginner in programming, and I was not able to find working example for USART4  interrupt configuration for STM32F030CC.
Until now I was just using USART4 to send messages, but now I need to read them too.
I wanted to make a interrupt routine that saves received messages in buffer.  I have made an working interrupt for push button and I tried to apply same principles to USART, but there are several problems.

This is my interrupt configuration for push button:
/* Tell system that you will use PA0 for EXTI_Line_0 */
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOA, BAT_PLUGIN_PIN); // EXTI_PinSource0 var rakstit BAT_PLUGIN_PIN
 /* PA0 is connected to EXTI_Line0 */
EXTI_InitStruct.EXTI_Line = EXTI_Line7;
/* Enable interrupt */
EXTI_InitStruct.EXTI_LineCmd = ENABLE;
/* Interrupt mode */
EXTI_InitStruct.EXTI_Mode = EXTI_Mode_Interrupt;
/* Triggers on rising and falling edge */
EXTI_InitStruct.EXTI_Trigger = EXTI_Trigger_Rising_Falling;
/* Add to EXTI */
NVIC_SetPriority(EXTI4_15_IRQn, 0);

First I wanted to configure which line I am using. In datasheet it's written that USART4 is in Position 29, but when I open stm32f0xx_exti.h I can't locate  it. It seems that there is a incompatibility.

#define EXTI_Line0       ((uint32_t)0x00000001)  /*!< External interrupt line 0  */
#define EXTI_Line1       ((uint32_t)0x00000002)  /*!< External interrupt line 1  */
#define EXTI_Line2       ((uint32_t)0x00000004)  /*!< External interrupt line 2  */
#define EXTI_Line3       ((uint32_t)0x00000008)  /*!< External interrupt line 3  */
#define EXTI_Line4       ((uint32_t)0x00000010)  /*!< External interrupt line 4  */
#define EXTI_Line5       ((uint32_t)0x00000020)  /*!< External interrupt line 5  */
#define EXTI_Line6       ((uint32_t)0x00000040)  /*!< External interrupt line 6  */
#define EXTI_Line7       ((uint32_t)0x00000080)  /*!< External interrupt line 7  */
#define EXTI_Line8       ((uint32_t)0x00000100)  /*!< External interrupt line 8  */
#define EXTI_Line9       ((uint32_t)0x00000200)  /*!< External interrupt line 9  */
#define EXTI_Line10      ((uint32_t)0x00000400)  /*!< External interrupt line 10 */
#define EXTI_Line11      ((uint32_t)0x00000800)  /*!< External interrupt line 11 */
#define EXTI_Line12      ((uint32_t)0x00001000)  /*!< External interrupt line 12 */
#define EXTI_Line13      ((uint32_t)0x00002000)  /*!< External interrupt line 13 */
#define EXTI_Line14      ((uint32_t)0x00004000)  /*!< External interrupt line 14 */
#define EXTI_Line15      ((uint32_t)0x00008000)  /*!< External interrupt line 15 */
#define EXTI_Line16      ((uint32_t)0x00010000)  /*!< External interrupt line 16  Connected to the PVD Output,  not applicable for STM32F030 devices */
#define EXTI_Line17      ((uint32_t)0x00020000)  /*!< Internal interrupt line 17    Connected to the RTC Alarm   event */
#define EXTI_Line18      ((uint32_t)0x00040000)  /*!< Internal interrupt line 18    Connected to the USB  event, only applicable for  STM32F072 devices */
#define EXTI_Line19      ((uint32_t)0x00080000)  /*!< Internal interrupt line 19  Connected to the RTC Tamper  and Time Stamp events */
#define EXTI_Line20      ((uint32_t)0x00100000)   /*!< Internal interrupt line 20   Connected to the RTC wakeup
 event, only applicable for    STM32F072 devices  */
#define EXTI_Line21      ((uint32_t)0x00200000)  /*!< Internal interrupt line 21  Connected to the Comparator 1  event, only applicable for STM32F051 ans STM32F072 devices */
#define EXTI_Line22      ((uint32_t)0x00400000)  /*!< Internal interrupt line 22  Connected to the Comparator 2       event, only applicable for STM32F051  and STM32F072 devices */
#define EXTI_Line23      ((uint32_t)0x00800000)  /*!< Internal interrupt line 23   Connected to the I2C1 wakeup  event, not applicable for STM32F030 devices */
#define EXTI_Line25      ((uint32_t)0x02000000)  /*!< Internal interrupt line 25       Connected to the USART1 wakeup  event, not applicable for STM32F030 devices */
#define EXTI_Line26      ((uint32_t)0x04000000)  /*!< Internal interrupt line 26      Connected to the USART2 wakeup         event, applicable only for   STM32F072 devices */
#define EXTI_Line27      ((uint32_t)0x08000000)  /*!< Internal interrupt line 27 Connected to the CEC wakeup  event, applicable only for STM32F051   and STM32F072 devices */
#define EXTI_Line31      ((uint32_t)0x80000000)  /*!< Internal interrupt line 31      Connected to the VDD USB monitor event, applicable only for       STM32F072 devices */

After this failure, which I did not know how to solve Itried to use some examples what I found here, like in [DEAD LINK /public/STe2ecommunities/mcu/Lists/STM32Discovery/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/STM32Discovery/UART%20example%20code%20for%20STM32F0&FolderCTID=0x01200200770978C69A1141439FE559EB459D75800084C20D8867EAD444A5987D47BE638E0F&currentviews=38320]this thread. Especially clive1 post at 6:42, but I have same problem as that guy with NVIC_InitTypeDef being undefinied. I added preprocessor macro, but NVIC_InitTypeDef is still undefined. preprocessormacro1.png

I have configured the USART4 and I know I have to write the USART4_IRQHandler(void) , but how to configure/enable this interrupt? Can someone please help?