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

About a procedure with UART as disable

Because of the power-saving support, I want to disable the UART before Call the sd_app_evt_wait().

I referred to two following sites to know the procedure of the case. 1.https://devzone.nordicsemi.com/question/5186/how-to-minimize-current-consumption-for-ble-application-on-nrf51822/?answer=5187#post-id-5187

2.https://devzone.nordicsemi.com/question/1119/handling-the-uart-when-sleeping/

However, there is for difference at the point that execute the following code when disable does UART in a procedure written as 1 to 2.


// Set TXD, RXD, CTS, RTS as high outputs
// Alternatively use NRF_GPIO->PIN_CNF to set pull resistors

NRF_GPIO->DIRSET = (1 << UART_TXD_GPIO) | (1 << UART_RXD_GPIO) | (1 << UART_RTS_GPIO) | (1 << UART_CTS_GPIO);

NRF_GPIO->OUTSET = (1 << UART_TXD_GPIO) | (1 << UART_RXD_GPIO) | (1 << UART_RTS_GPIO) | (1 << UART_CTS_GPIO);

As a result of having tried each procedure, I became able to reuse UART in 2 procedures, but UART did not become reusable in 1 procedure.

When disable does UART, is it right to perform in a procedure listed in 2?

  • Hi,Aryan, I'm sorry to confuse it. It is recognition from SDK_10.0.0 that nrf_drv_uart(nrf_drv_uart.c/nrf_drv_uart.h) was introduced, and my project makes app_uart_fifo.c of SDK_8.0.0 to a base. I think app_uart_fifo.c of SDK_8.0.0 to have taken the role of the driver. Therefore I do not use nrf_drv_uart. Is my understanding incorrect?

  • Hi satokato,

    I see, thanks for clarifying this. The API for the uart_fifo stays same in SDK8 and SDK11. That means that the recommendation i gave you to close the uart and the reinit again is still valid.

    while(your_condition)
    {
        err_code = app_uart_close();
        APP_ERROR_CHECK(err_code);
    
        err_code = sd_app_evt_wait();
        APP_ERROR_CHECK(err_code);
    
        APP_UART_FIFO_INIT( &comm_params,
                           UART_RX_BUF_SIZE,
                           UART_TX_BUF_SIZE,
                           uart_event_handle,
                           APP_IRQ_PRIORITY_LOW,
                           err_code);
        APP_ERROR_CHECK(err_code);
    }
    
  • Hi,Aryan, Thank you for confirmation. I tried a code recommended by you, but have not yet worked well. After checking it, in app_uart_init() function and app_uart_close() function recommended by you, there seems to be for difference to a register set in SDK8 and SDK10. (For example,the register setting by interrupts_disable() function and pins_to_default() function of SDK10.) As of the following code, it seems to work well if you set the register which has a difference in the manual.


    uint32_t app_uart_init() { … // Configure RX and TX pins. // << add start. nrf_gpio_pin_set(p_comm_params->tx_pin_no); // >> add end. nrf_gpio_cfg_output(p_comm_params->tx_pin_no); nrf_gpio_cfg_input(p_comm_params->rx_pin_no, NRF_GPIO_PIN_NOPULL); … }


    When I use SDK8, is it necessary to set the register with the difference by manual operation in comparison with setting of other SDK10?

  • Hi Satokato, I am sorry for late reply, I was sick all week. I did not realize that there are differences in the two SDKs for this API, after your changes, did you manage to get it to work?

  • Hi Aryan, Thank you for reply. When I compare SDK10 with SDK8 and set a certain register for the difference by manual operation for setting, I seem to work well. The register whom there was for the difference is as follows for setting.

    ・app_uart_init()

    NRF_GPIO->OUTSET

    ・app_uart_close()

    NRF_UART0->INTENCLR / NRF_UART0->PSELTXD / NRF_UART0->PSELRXD / NRF_GPIO->PIN_CNF[tx_pin_no] / NRF_GPIO->PIN_CNF[rx_pin_no]

    But I would like to confirm whether there is not a problem as a procedure.

    For example, in the case of app_uart_close() function, Between SDK8 and SDK10, I think that there is for difference as follows.

    ・In the case of SDK8

    uint32_t app_uart_close(uint16_t app_uart_uid);

    ・In the case of SDK10

    uint32_t app_uart_close(void);

    Is my understanding incorrect?

Related