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

Can I use RTT instead of UART for a console on nRF5340?

I have been using UART0 to implement a very simple console using console_getline_init() and console_getline().

So the nRF5340 receives commands over UART0 and outputs printf's over UART0.

I have also been using SPIS1.

Now I need a TWIM peripheral, but TWIM2 and TWIM3 don't work on nRF5340 yet.

So I've tried moving the console over to RTT so I can use TWIM0.

Output to RTT is working, but I haven't found an equivalent way to receive characters over RTT (something similar to console_getline())

The other tickets I've read are about enabling logging over RTT (output only).

Is there a way to get characters over RTT? (RTT input)

Parents Reply
  • You are correct that I can get RTT console input and output by using the shell module.

    Digging into the shell module code I found that the essential code is this (in order to do both input and output over RTT) without implementing the entire shell

    (snippets of my code)

    SEGGER_RTT_Init();
    SEGGER_RTT_ConfigUpBuffer(1, "mono6kHz", rtt_buffer, sizeof(rtt_buffer), SEGGER_RTT_MODE_NO_BLOCK_TRIM); // I was already using an "UpBuffer"

    #define RTT_IN_BUFSIZE 10 // number of characters to receive at a time in RTT console
    char rtt_in_buf[RTT_IN_BUFSIZE]; //console input

    SEGGER_RTT_ConfigDownBuffer(0, "console", rtt_in_buf, sizeof(rtt_in_buf), SEGGER_RTT_MODE_NO_BLOCK_TRIM);

    char c;
    u32_t n;

    n = SEGGER_RTT_Read(0, &c, 1); // read one character from RTT

Children
No Data
Related