Hello,
I'm a bit confused which solution is best and easiest to use a second UART or UARTE in the nrf5 SDK for Thread. Since I want to work with students in a project and prepare exercises, I want to prepare the required project files and configuration files so that it is easier for the students to find their way into them.
As I understand it, the Thread SDK uses UARTE0 for the CLI, so that it is not available except by deactivating the CLI, which I managed to do. However, the CLI is very practical for the students, which is why I would like to leave it activated in the basic configuration.
According to the documentation, the app_uart module uses UART0. The documentation actually always states that the instance is hardcoded and cannot be changed. However, there is the MACRO APP_UART_DRIVER_INSTANCE to set the instance. In the sdk_config.h it is stated that the parameter can only be set to 0. If I set it to 1, a second connected UART-USB bridge works. Setting it to 0, on the other hand, leads to an error. Is it safe to use the app_uart module with the CLI at the same time and to set APP_UART_DRIVER_INSTANCE to 1 or does this lead to problems?
I also created a solution using the library libuarte. I've read that this should be the best solution. I used nrf_libuarte_async here. So that data can also be sent to the nrf52840. However, there are also some questions here and I think that a lot of configuration has to be carried out for a simple uart input and output (e.g. the queue module has to be activated and set in the flash_placement) and the question also arises as to which timer is best is to be used. The softdevice uses RTC0, but we do not use this. RTC1 is used by the app_timer. Normally I would actually use TIMER2 for bytes counting and RTC2 for timeout. However, the RTC2 is apparently used for OpenThread, why this leads to an error:
NRF_LIBUARTE_ASYNC_DEFINE (libuarte, 1, 2, 2, NRF_LIBUARTE_PERIPHERAL_NOT_USED, 255, 3);
RTC0 and TIMER2 works, but use of the softdevice is not possible anymore:
NRF_LIBUARTE_ASYNC_DEFINE (libuarte, 1, 2, 0, NRF_LIBUARTE_PERIPHERAL_NOT_USED, 255, 3);
Whereas using the app_timer does not work:
NRF_LIBUARTE_ASYNC_DEFINE (libuarte, 1, 2, NRF_LIBUARTE_PERIPHERAL_NOT_USED, NRF_LIBUARTE_PERIPHERAL_NOT_USED, 255, 3);
Even if the flag is set in the sdk_config.h:
#define NRF_LIBUARTE_ASYNC_WITH_APP_TIMER 1
There is no compile error. When running in debug mode, I get:
<error> app: ERROR 7 [NRF_ERROR_INVALID_PARAM]
To consume two timers just for the Uart, I find somehow quite a lot. So i am a little bit puzzled. So is it safe to use the app_uart? Is it possible to use libuarte_async with app_timer? Or do i have to use 2 Timer (TIMER2 and TIMER3) for it? Is RTC0 ok, if not using the Saoftdevice?
Regards
Markus