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

UART TASKS_SUSPEND and sending a break

Hello everybody,

I have a few questions about the built-in UART (UART0) in the nRF51822.

  1. I've noticed some registers that aren't fully documented in nrf51.h of the sdk. I'd like to know what TASKS_SUSPEND does. I'm also curious about SHORTS and if there's anything to know about POWER.

  2. The UART can interrupt on a break (en.wikipedia.org/.../transmitter, which is great for my application (two UARTs, one on each chip, go to sleep as often as possible and wake each other with a break). Does the UART have the capability to send a break using a simple command, or must I bit-bang a break of the pin by switching the crossbar to GPIO?

Thank you!

  • Hi Cody

    1. The SUSPEND task is a part of the TWI peripheral. You can find description of all registers, tasks, events and shorts in the nRF51 Series Refererence Manual v2.1 (RM), available on our web site. For general recommendation on how to tune your code or hardware for power efficiency, I can point to this thread and this thread.

    2. I do not think the nRF51 UART supports sending a break. What we usually recommend to implement on the UART to save power, is to connect two extra GPIO's between nRF51822 and the MCU, so you have full control of both sides. One GPIO is an interrupt signal from the nRF51822 to the peer and the other is potential interrupt signal from the peer to the nRF51822, to enable the nRF51822 to have UART disabled and only enable it when there is data to send. This would minimise current consumption. There is also another method described on this thread.

  • You can generate a break on UART0 by disconnecting the UART transmit from the GPIO pin and setting the GPIO pin low for the amount of time required to generate a break. You can then reconnect the UART transmit to your GPIO pin and begin your transmission.

    Here is how I did it for out project:

    
    // First disconnect the transmit pin from the UART by 
    // writing -1 to the PSELTXD register
    NRF_UART0->PSELTXD = 0xFFFFFFFF;
    
    // Set pin low to generate the necessary zeros on the line
    nrf_gpio_pin_write(TX_PIN_NUMBER, 0);
    
    // Delay for enough time to generate a break
    nrf_delay_us(100);
    
    // Reconnect the pin to the UART
    NRF_UART0->PSELTXD = TX_PIN_NUMBER;