Question
STM32F415RGT6 UART4 RXNE Interrupt ?!
Posted on May 22, 2012 at 15:25
Hello,
I try to work with the UART4 RXNE interrupt but something went wrong. // USART2-TX, UART4-TX GPIO_StructInit(&GPIO_InitStructure); GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOA, &GPIO_InitStructure); GPIO_PinAFConfig(GPIOA, GPIO_PinSource0, GPIO_AF_UART4); // USART2-RX, UART4-RX GPIO_StructInit(&GPIO_InitStructure); GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOA, &GPIO_InitStructure); GPIO_PinAFConfig(GPIOA, GPIO_PinSource1, GPIO_AF_UART4); //configure NVIC //select NVIC channel to configure NVIC_InitStructure.NVIC_IRQChannel = UART4_IRQn; //set priority to lowest NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x1; //set subpriority to lowest NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x1; //enable IRQ channel NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //update NVIC registers NVIC_Init(&NVIC_InitStructure); NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x2; NVIC_Init(&NVIC_InitStructure); USART_DeInit(UART4); USART_ClockStructInit(&USART_ClockInitStructure); USART_ClockInitStructure.USART_CPHA = USART_CPHA_1Edge; USART_ClockInitStructure.USART_CPOL = USART_CPOL_Low; USART_ClockInitStructure.USART_Clock = USART_Clock_Enable; USART_ClockInitStructure.USART_LastBit = USART_LastBit_Enable; USART_ClockInit(UART4, &USART_ClockInitStructure); USART_StructInit(&USART_InitStructure); USART_InitStructure.USART_BaudRate = 19200; USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx; USART_InitStructure.USART_Parity = USART_Parity_No; USART_InitStructure.USART_StopBits = USART_StopBits_1; USART_InitStructure.USART_WordLength = USART_WordLength_8b; USART_Init(UART4, &USART_InitStructure); USART_Cmd(UART4, ENABLE); //enable Receive Data register not empty interrupt USART_ITConfig(UART4, USART_IT_RXNE, ENABLE); USART_ITConfig(UART4, USART_IT_TXE, DISABLE); This is my init source code. I can send strings over my functions but if I try to send a char from the computer, the STM32 dont jump into the interrupt handler. Here is my function, which will be called in the UART4_IRQHandler: if(USART_GetITStatus(UART4, USART_IT_RXNE) == SET) { uint16_t temp = UART4->DR; UART_SendChar(temp); } My idea is that every character send back to the computer. Whats wrong with this code? Thanks, Dennis #interrupt #usart #tags-are-pointless #uart #stm32