2017-05-24 05:37 AM
Hey guys,
I'm using a serial terminal to communicate with USART3 on an STM32F1 via an FTDI USB-UART converter cable. I am successfully receiving data from USART3 in my serial terminal but when I try to send data to it the RX interrupt I have configured is not being fired. Here is my code:
void USART3_IRQHandler(void)
{ if(USART_GetITStatus(USART3, USART_IT_RXNE) != RESET){ // Read one byte from data register RxBuffer[RxCounter++] = USART_ReceiveData(USART3); if(RxCounter == 15){ // Disable interrupt USART_ITConfig(USART3, USART_IT_RXNE, DISABLE); } }}
, where RxBuffer is a u8 array[16] and RxCounter is u8 initially set to zero. I have configured USART3 like so:
USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);
I'm using RealTerm as my serial terminal and can see that the TXD status light goes yellow when I type in some characters and click 'Send ASCII', i.e. the transmission is good. I've also checked the RXNE flag and it is not being set.
Can anyone help me with this? Have I left out some code?
Cheers,
Tony
#usart3 #stm32f1 #no-interrupt2017-05-24 06:53 AM
>>Can anyone help me with this? Have I left out some code?
I only see one subroutine outside any context, so arguably yes.
Make sure you enable the interrupt in the NVIC.
If using C++ option or .cpp file extension, then use the extern 'C' void USART3_IRQHandler(void) form
2017-05-25 04:14 AM
Hi Clive,
Sorry I do have the interrupt enabled in the NVIC like so:
NVIC_InitStructure.NVIC_IRQChannel = USART3_IRQChannel;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=0; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure);Is this ok?
Tony