S32K146 UART Rx interrupt

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

S32K146 UART Rx interrupt

1,818 Views
tonymor90
Contributor I

Hello,

 

I was trying to implement an RX interrupt but I can't make it work, I am able to send data through TX, I enable the interrupt just for RX and baudrate 115200. can you help if I am missing something please. I am using S32K146 DevBoard

 

I already enabled the Transmitter and Receiver and enable Receiver Interrupt. I can send but not receive anything. I am not using processor expert, I follow and example that I found but still can't figure it out.

Project is attached

Labels (1)
Tags (3)
0 Kudos
3 Replies

1,569 Views
dianabatrlova
NXP TechSupport
NXP TechSupport

Hello Hugo,

I tested your code with LPUART1 because I use the terminal to send the characters and the interrupt works without any issue. So, I assume that it should work also with LPUART0. Have you tested the simple example here? https://community.nxp.com/message/957747?commentID=957747#comment-957747 

Does it work?

Also, I recommend you to use the faster clock source for LPUART baudrate. 

Best Regards,

Diana

0 Kudos

1,569 Views
tonymor90
Contributor I

Hello Diana, I actually made it work, it was the NVIC issue, LPURAT0 goes to the vector 0 and LPUART1 goes to 1.

I also have another question, I am trying to make my application to work just with interrupts, RX as interrupt ( works fine ) and TX ( as interrupt ) the problem is that TX interrupt is always going to get triggered because the flag is always set ( Empty buffer ) until I put something in the buffer but I still don't want to send anything until I have data in my queue.  the problem I  have is that the erase mechanism for the flag is writing to DATA register, but I don't want to do it unless I have valid data. please refer to UartService.c  

void LPUART0_RxTx_IRQHandler(void) {

static uint8_t count;

if ( ( ( LPUART0->STAT & LPUART_STAT_RDRF_MASK ) >> LPUART_STAT_RDRF_SHIFT ) != 0 ) { // Wait for received buffer to be full
NordicReceiveBuffer();
}
if ( ( ( LPUART0->STAT & LPUART_STAT_TDRE_MASK ) >> LPUART_STAT_TDRE_SHIFT ) != 0 ) {
if ( nordicTxQueue.in == nordicTxQueue.out ) {
return;
}
else {
//for ( count = 0; nordicTxQueue.out != nordicTxQueue.in; count++ ) {
NEXT ( nordicTxQueue.out, BUFFER_SIZE );
SendNordicByte ( GET ( nordicTxQueue ) );
}
//}
}
}

/************ HOW CAN I CLEAR THE TDRE FLAG HERE  WITHOUT WRITING TO  DATA REGISTER*************//////////

if ( nordicTxQueue.in == nordicTxQueue.out ) {
return;
}

is there another way to clear the flag? is it possible to use RX and TX with interrupts at the same time?

0 Kudos

1,569 Views
dianabatrlova
NXP TechSupport
NXP TechSupport

Hello Hugo,

TDRE can be cleared only by writing to the DATA register.

However, if there is no data to be sent you can disable TX interrupt until you have data in your queue.

When you have data to send just enable the TX interrupt.

I hope it helps.

Best regards,

Diana

0 Kudos