This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

UART0_IRQHandler here EVENTS_RXDRDY event is not generated after receiving 1st 6 bytes

Here i have made an UART0_IRQHandler routine. When i try to send some 50 bytes data through UART using PC tool here its receiving bytes, but it only receives 1st 6 bytes which i send. After that nothing is happening. I am not getting any interrupt after that.

Here i even referred nRF51_Series_Reference_Manuel there they have written that, The UART receiver chain implements a FIFO capable of storing six incoming RXD bytes before data is overwritten. Bytes are extracted from this FIFO by reading the RXD register. When a byte is extracted from the FIFO a new byte pending in the FIFO will be moved to the RXD register. The UART will generate an RXDRDY event every time a new byte is moved to the RXD register.
Here in my case bytes form FIFO are not getting written to RXD register after 1st cycle ??

Can anybody help me out with this??? Here below is the Interrupt routine which i made.

void UART0_IRQHandler(void) {

// Handle reception
if (NRF_UART0->EVENTS_RXDRDY != 0)
{
    // Clear UART RX event flag
    NRF_UART0->EVENTS_RXDRDY = 0;
    
			if(st_rcvmsg_ok==false)                           // Protect Against RxBuffer OverWrite 
			{
					st_rcvtimeout = TIME_BTWN_TWO_CHAR;      			// Time out between two char
					rx_buf[st_rcvcntr] = (uint8_t)NRF_UART0->RXD;	// Write received byte 
				
					st_rcvcntr++;
					
					if(st_rcvcntr==2)
					{
							rx_msg_len=(rx_buf[1]+(rx_buf[0]*256)); 
					}
				
					if(st_rcvcntr>=3)
					{
							if(st_rcvcntr == (rx_msg_len + 2))
							{
									if(initialization_complete_flg)				//flag set after uart initilization.
									{
										st_rcvmsg_ok = true;	    					// Just set flag and call routine from while(1)
										st_rcvcntr=0;
										st_rcvtimeout = 0;
									}
									
									
							}
					}
			}		
}	
			
// Handle errors.
if (NRF_UART0->EVENTS_ERROR != 0)
{
    // Clear UART ERROR event flag.
    NRF_UART0->EVENTS_ERROR = 0;
	}

}

Parents
  • Hi jayesh

    Yes, as the nRF51 Series Reference Manual indicates, a new byte should be moved to the RXD register when you extract a byte from it if there are any remaining bytes in the 6 byte FIFO. This should generate a RXDRDY event. I can think of several ways for the RXDRDY event not to be generated:

    • The RXDRDY event is not cleared after entering the UART interrupt handler. Your code shows that you are clearing the event.
    • A byte is not extracted from RXD after receiving the RXDRDY event. Seems like you are doing that in your code.
    • The FIFO buffer is empty and therefore a TXDRDY event is not generated when byte is extracted from the RXD register. This might occur if you do not have e.g. flow control enabled (HWFC). Then the PC could write the 50 bytes before the nRF51 UART starts handling incoming UART bytes. When nRF51 UART starts handling bytes, it only has 6 bytes in the FIFO buffer
  • When you get the error event, what is the error source in the ERRORSRC? That should tell you what kind of error it is.

    What happens when you decide to transfer fewer bytes at at time from the PC, say 6 bytes and pause in between? Do you then receive more bytes on the nRF51 side?

    You can also hook a logical analyzer to the UART lines to see what is really going on there.

    I would recommend to have HWFC enabled. Otherwise you are going to lose bytes at some point because if you write more than 6 bytes at a time from the PC while the CPU on the nRF51 is doing something else (CPU not available to extract data from the UART) then you are going to lose data.

    There is a UART example in the SDK under \nRF51_SDK_9.0.0_2e23562\examples\peripheral\uart. Have you tried that? That examples uses the app_uart library which should work.

Reply
  • When you get the error event, what is the error source in the ERRORSRC? That should tell you what kind of error it is.

    What happens when you decide to transfer fewer bytes at at time from the PC, say 6 bytes and pause in between? Do you then receive more bytes on the nRF51 side?

    You can also hook a logical analyzer to the UART lines to see what is really going on there.

    I would recommend to have HWFC enabled. Otherwise you are going to lose bytes at some point because if you write more than 6 bytes at a time from the PC while the CPU on the nRF51 is doing something else (CPU not available to extract data from the UART) then you are going to lose data.

    There is a UART example in the SDK under \nRF51_SDK_9.0.0_2e23562\examples\peripheral\uart. Have you tried that? That examples uses the app_uart library which should work.

Children
No Data
Related