AnsweredAssumed Answered

Cannot get UART interrupt to fire with standard peripheral lib

Question asked by Alexander Hoffman on Feb 14, 2018
Latest reply on Feb 21, 2018 by dhenry

Hi all,


I am working on a project based around an old comms stack that uses the standard peripheral library, which i'm not that familiar with. I have been trying for a good couple of days now to get the UART rx interrupt to fire without luck. I have been basing my work off of the example here STM32 UART Example . I am able to send over UART but cannot seem to receive via interrupt.


I am initilizing USART1 and 3, 3 being part of the exsisting comms stack I am trying to implement in my project, my code for initilizing USART is as follow


void serial_init_1(unsigned int baud)
USART_InitTypeDef USART_InitStructure;
GPIO_InitTypeDef GPIO_InitStructure;

// Enable USART1 and GPIOA clock */

/* Configure USART1 Tx (PA.09) as alternate function push-pull */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);

/* Configure USART1 Rx (PA.10) as input floating */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOA, &GPIO_InitStructure);

USART_InitStructure.USART_BaudRate = baud;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;

USART_Init(USART1, &USART_InitStructure);

/* Enable the USART1 Receive interrupt: this interrupt is generated when the
USART1 receive data register is not empty */

/* Enable USART1 */

Then the NVIC as follows

nvic_initialisierung(USART1_IRQn | USART3_IRQn);

void nvic_initialisierung(uint16_t IRQ)
NVIC_InitTypeDef NVIC_InitStructure; //create NVIC structure
NVIC_InitStructure.NVIC_IRQChannel = IRQ;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
// NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);

I have then defined 

void USART1_IRQHandler(void)


But it is never reached.

Any advice and or links to solid examples would be appreciated. I have tried many slight variations of what is above but nothing seems to work.