cancel
Showing results for 
Search instead for 
Did you mean: 

ST32f4 UART receive interrupt don't work

robert_150
Associate
Posted on August 15, 2014 at 13:15

Hey guys,

I work on my bachelor thesis with an stm32f4 discovery board.

I want to revive data via UART3 form PC.

The Data fit at the Rx Pin (GPIOC.11), i checked it with the Oscilloscope.

But de controller doesn’t jump in the interrupt subroutine and don't set the RXNE Flag.

In the Debug mode the controller hangs off in the startup_stm Data(see picture).

I use Keil 4.72.1 and TM32F4xx_DSP_StdPeriph_Lib_V1.3.0.

Thanks for helping.

Getting

Robert

//********************************************************************** #include <stddef.h> #include ''stm32f4xx.h'' #include ''math.h'' #include <stdio.h> int k=0; //*************UART-INIT**************** void USART_INIT(void) { /* UART = UART3 Tx = Pin.C.10 Rx = Pin.C.11 BaudRate = 57600 StopBits = 2 HardwareFlowControl = NON WordLength = 8bit */ GPIO_InitTypeDef GPIO_InitStructure; USART_InitTypeDef UART_InitStructure; USART_ClockInitTypeDef USART_ClockInitstructure; /* Enable GPIOC clock */ RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE); /* Enable GPIOD clock */ RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE); /* Enable USART clock */ RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE); /* Connect PXx to USARTx_Tx*/ GPIO_PinAFConfig(GPIOC, GPIO_PinSource10, GPIO_AF_USART3); /* Connect PXx to USARTx_Rx*/ GPIO_PinAFConfig(GPIOC, GPIO_PinSource11, GPIO_AF_USART3); /* Configure USART Tx as alternate function */ GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOC, &GPIO_InitStructure); /* Configure USART Rx as alternate function */ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11; GPIO_Init(GPIOC, &GPIO_InitStructure); UART_InitStructure.USART_BaudRate = 57600; UART_InitStructure.USART_WordLength = USART_WordLength_8b; UART_InitStructure.USART_StopBits = USART_StopBits_2; UART_InitStructure.USART_Parity = USART_Parity_No; UART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; UART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; /* USART Clock Initialization */ USART_ClockInitstructure.USART_Clock = USART_Clock_Enable ; USART_ClockInitstructure.USART_CPOL =USART_CPOL_High ; USART_ClockInitstructure.USART_LastBit = USART_LastBit_Enable; USART_ClockInitstructure.USART_CPHA = USART_CPHA_1Edge; /* USART configuration */ USART_Init(USART3, &UART_InitStructure); USART_ClockInit (USART3, &USART_ClockInitstructure); USART_ITConfig(USART3,USART_IT_RXNE,ENABLE); /* Enable USART */ USART_Cmd(USART3, ENABLE); } //*************************************Interruppt*********************** *** void INTERRUPT_INIT(void) { NVIC_InitTypeDef NVIC_usart; NVIC_usart.NVIC_IRQChannel = USART3_IRQn; NVIC_usart.NVIC_IRQChannelCmd= ENABLE; NVIC_usart.NVIC_IRQChannelPreemptionPriority = 10; NVIC_usart.NVIC_IRQChannelSubPriority = 10; NVIC_Init(&NVIC_usart); } //*************************************Main***************************** *** int main(void) { SystemInit(); INTERRUPT_INIT(); USART_INIT(); while (1) { } } //********************************************************************** *** void USART3_IRQHandler(void) { if(USART_GetITStatus(USART3, USART_IT_RXNE) != RESET) { k++; } USART_ClearITPendingBit (USART3,USART_IT_RXNE); }

1 REPLY 1
Posted on August 15, 2014 at 14:00

Use

extern ''C'' void USART3_IRQHandler(void)

or stop using C++ (main.cpp)
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..