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

app_uart_get returns NRF_ERROR_NOT_FOUND, nRF51822 on nRF6310 with RS232

I want to read a line of text from a UART peripheral. I'm using app_uart.c, not the "simple UART" example code.

My main() looks something like this:

uint8_t line[MAX_CHARS];
uint8_t command[] = "ATI\n";
uint32_t err_code;
uint16_t uart_uid;
app_uart_comm_params_t comm_params;

leds_init();

comm_params.rx_pin_no = RX_PIN_NUMBER;
comm_params.tx_pin_no = TX_PIN_NUMBER;
comm_params.rts_pin_no = NULL;
comm_params.cts_pin_no = NULL;
comm_params.flow_control = APP_UART_FLOW_CONTROL_DISABLED;
comm_params.baud_rate = UART_BAUDRATE_BAUDRATE_Baud38400;
		
err_code = app_uart_init(&comm_params, NULL, &uart_event_handler, APP_IRQ_PRIORITY_HIGH, &uart_uid);
APP_ERROR_CHECK(err_code);
		
uart_getline(line);

for (;;)
{
}

and my implementation of uart_getline() is:

static void uart_getline(uint8_t * line)
{
	uint_fast8_t i = 0;
	uint8_t ch;
	uint32_t err_code;

	do {
		err_code = app_uart_get(&ch);
		APP_ERROR_CHECK(err_code);

		line[i++] = ch;
	}
	while (ch != '\n');
}

My uart_event_handler() function does nothing.

I have the peripheral connected to the RS-232 port on the motherboard and the red RS232 switch set to on. My pins P2.0 and P2.1 are connected with jumpers to the TXD and RXD pins on port P15. I haven't connected anything to the RTS and CTS pins (not using hardware flow control).

I can connect to the peripheral from a hyperterminal session and see output. It's a simple GPS eval board. I know it works fine with no flow control, 38400 baud, 8N1.

What I'm seeing is that in app_uart_get...

uint32_t app_uart_get(uint8_t * p_byte)
{
    if (m_rx_byte == BYTE_INVALID)
    {
        return NRF_ERROR_NOT_FOUND;
    }

    *p_byte   = m_rx_byte;
    m_rx_byte = BYTE_INVALID;

    return NRF_SUCCESS;
}

... is that m_rx_byte is always BYTE_INVALID

What could be causing this?

Parents
  • Thanks for this. I'm having trouble finding the implementation of sd_app_evt_wait(). Have included nrf_soc.h in my main.c but presumably there's a .c source file I need in my project too?

    compiling main.c...
    src\main.c(960): warning:  #223-D: function "sd_app_evt_wait" declared implicitly
    ...
    linking...
    .\device-nordic.axf: Error: L6218E: Undefined symbol sd_app_evt_wait (referred from main.o).
    ".\device-nordic.axf" - 1 Errors, 16 Warning(s).
    
  • I see now that that function is sd_app_event_wait() in SDK 4 and sd_app_evt_wait() in SDK 5. I've just upgraded to SDK 5 so have changed it back in my code.

    Have set a breakpoint in UART0_IRQHandler() and it never fires. Really can't see anything wrong with my wiring. Any other ideas?

    I guess I could take the RS232 connection out of the equation but wiring straight from the motherboard pins on to the GPS eval board pins is electrically difficult.

Reply
  • I see now that that function is sd_app_event_wait() in SDK 4 and sd_app_evt_wait() in SDK 5. I've just upgraded to SDK 5 so have changed it back in my code.

    Have set a breakpoint in UART0_IRQHandler() and it never fires. Really can't see anything wrong with my wiring. Any other ideas?

    I guess I could take the RS232 connection out of the equation but wiring straight from the motherboard pins on to the GPS eval board pins is electrically difficult.

Children
No Data
Related