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

app_uart getting started

I've modified the simple_uart example to use app_uart instead but I cannot get any data transmitting. I know the connections are correct because it works fine under normal simple_uart testing.

Here is my init code which also sends a character and a string. When I debug it always makes it through to NRF_SUCCESS case, but never transmits 'T'

uart_buffers.rx_buf = rx_buffer;
uart_buffers.rx_buf_size = sizeof(rx_buffer);
uart_buffers.tx_buf = tx_buffer;
uart_buffers.tx_buf_size = sizeof(tx_buffer);

comm_params.rx_pin_no = rxd_pin_number;
comm_params.tx_pin_no = txd_pin_number;
comm_params.cts_pin_no = cts_pin_number;
comm_params.rts_pin_no = rts_pin_number;
comm_params.baud_rate = 9600;
comm_params.use_parity = false;
comm_params.flow_control = APP_UART_FLOW_CONTROL_DISABLED;

uint32_t res = app_uart_init(&comm_params, &uart_buffers, &app_uart_handler, APP_IRQ_PRIORITY_HIGH, comm_uuid);

if(res == NRF_SUCCESS)
{
	app_uart_put('T');
	simple_uart_putstring("Test 1\r\n");
	return;
}
Parents Reply Children
  • The example I posted above seems to work just as well with SDK 5.1.0 as it did with 4.4.2. I would recommend you to try running the project with a debugger to see where it fails, and then post a new question if you have further problems.

    As for the define, I'd almost say that's my favorite define as well, mostly due to the fact that it shows the consistency of the register defines. All register defines are on the format PERIPHERAL_REGISTER_FIELDNAME_VALUE, which makes it trivial to write code with just the Reference Manual, without even considering what part was left out to please the eye in this register. I'd much rather have it consistent and redundant, than have random parts left out of every other define. All hail the Great Value of Consistency! ;-)

    (One could of course argue that we should name the fields and registers otherwise to avoid things like this, but I really don't see it as that big problem...)

  • I totally get it, but you have to agree its funny.

    I have run it under the debugger, and the call to app_uart_put is failing (debugger loses connection to the device. I'm able to single-step reliably up until then.

    I'm getting no error from app_uart_init either, so I'm a little bit at a loss as to what to try next.

  • I definitely agree that it's funny, I just wanted to point out that there is a reason it's the way it is. :)

    I don't really have any great suggestions for you, but I'd recommend you to verify that you don't end up in app_error_handler or in the HardFault_Handler.

    Anyway, it really sounds to me as if this is an unrelated problem to the original here, so if you could post a question with this separately, I'd be happy to take a look. If you could supply the complete project you're working with, that would make it easy for me to try reproducing your problem.

Related