UART + RTT LOG Setup

Hello, 

I have my own custom board with nRF52832 and a NB-iot module SIM7080G that interfaces via UART. 

I can easily program the device through SWD using J-Link. I am even able to print things using RTT.

I have a button and made a simple program to print a thing once the button is pressed:

 

Fullscreen
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

The thing is I want to communicate via UART (TX pin P0.04, RX pin P0.03) to the SIM7080G module at the same time I print things using RTT Log. This module is AT COMMAND so it would be really practical to write on the RTT in the computer and send this information to TX pin in the UART. After that, listen to the RX PIN (answer from the module) and print it again to the RTT Log so I can see it in the computer.

I tried setting up the UART in the corresponding pins like that (attached the full code):

Fullscreen
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

But I am getting error 

Fullscreen
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
at line 47 in the code attached.

I am really new in the Nordic Semiconductor environment so any kind of help would be really appreciated.

Thank you,

Toni

Parents
  • Hi,

    You are getting NRF_ERROR_INVALID_STATE returned from nrf_drv_uart_init(), which means that UART is already enabled. Logging is enabled beforehand, so I suspect you have enabled the UART backend for nrf_log? If so, you need to modify sdk_config.h so that NRF_LOG_BACKEND_UART_ENABLED is set to 0.

    As you write you want RTT logging you also need to ensure you set NRF_LOG_BACKEND_RTT_ENABLED to 1, and I also recommend you set NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED to 0.

Reply
  • Hi,

    You are getting NRF_ERROR_INVALID_STATE returned from nrf_drv_uart_init(), which means that UART is already enabled. Logging is enabled beforehand, so I suspect you have enabled the UART backend for nrf_log? If so, you need to modify sdk_config.h so that NRF_LOG_BACKEND_UART_ENABLED is set to 0.

    As you write you want RTT logging you also need to ensure you set NRF_LOG_BACKEND_RTT_ENABLED to 1, and I also recommend you set NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED to 0.

Children
  • Thanks Einar,

    I solved the ERROR 8 with what you said. Now I am having trouble transmiting. I am doing this:

    Fullscreen
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    I am trying to send two characters via UART. I am receiving message "no Ok!" in RTT viewer. Why am I getting error?

    I understand I am using the most low level UART library and I do so because the app_uart is getting me into a lot of trouble because of dependencies... I did start my project from ble_app_multilink_central_pca10040 example. When I tried to add app_uart_fifo.c and everything I started having a lot of problems.

    Why is that uart not working?

    Could you help me developing a simple tx/rx using nrf_drv_uart library?

    Thanks!

  • Hi,

    Toni Alomar said:
    I am receiving message "no Ok!" in RTT viewer. Why am I getting error?

    I don't know. Can you print the error code as well? That should give some hints.

    Toni Alomar said:
    Could you help me developing a simple tx/rx using nrf_drv_uart library?

    The SDK has the UART driver and several UART libraries built on top, I would think you should be able to use one of those. Building your own does not immediately seem like a good idea (and if you want to do so, that is up to you).