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

UART pin should not use AIN pin

Hi, 

I init the UART pin with the AIN pin such as P0.05, but the program will run into __WEAK void app_error_fault_handler(uint32_t id, uint32_t pc, uint32_t info) every time. Is there anyone experience this problem, any suggestion or response is appreciated.

following is the uart init funciton.

static void uart_init(void)
{
uint32_t err_code;
app_uart_comm_params_t const comm_params =
{
.rx_pin_no = RX_PIN_NUMBER,
.tx_pin_no = TX_PIN_NUMBER,
.rts_pin_no = RTS_PIN_NUMBER,
.cts_pin_no = CTS_PIN_NUMBER,
.flow_control = APP_UART_FLOW_CONTROL_DISABLED,
.use_parity = false,
#if defined (UART_PRESENT)
.baud_rate = NRF_UART_BAUDRATE_115200
#else
.baud_rate = NRF_UARTE_BAUDRATE_115200
#endif
};

APP_UART_FIFO_INIT(&comm_params,
UART_RX_BUF_SIZE,
UART_TX_BUF_SIZE,
uart_event_handle,
APP_IRQ_PRIORITY_LOWEST,
err_code);
APP_ERROR_CHECK(err_code);
}

Parents
  • Hi Vernon,

    Please keep in mind nrf52840 has only 1 UART so as a second peripheral you can use UARTE.

    See this thread for more information.

     

    (could also be interesting)

  • Hi Martin,

    I have tried to use the low-frequency-IO as the UART PIN, when configuring all of these IO, the program also ran into the  __WEAK void app_error_fault_handler(uint32_t id, uint32_t pc, uint32_t info), P0.00 and P0.01 also does.  

  • Hi Vernon,

    Could you try to debug the application, and see what information the app_error_fault_handler gives out.

    Debugging in Segger IDE.

    Are you running this on the nrf52840 DK?

    Which SDK version are you using?

  • Hi Martin,

    Thank you very much for your answer, I follow the debug steps and trace the error code, it seems that the error code number is NRF_ERROR_DATA_SIZE(Invalid Data size), see the below shot, can you point out what's wrong with the data size in my code?  and I attached the zip files which is used for uart1 application.

    app_uart1.zip

    #define UART_TX_BUF_SIZE                256                                         /**< UART TX buffer size. */
    #define UART_RX_BUF_SIZE                256                                         /**< UART RX buffer size. */
    
    
    
    static void uart1_init(void)
    {
    uint32_t err_code;
    app_uart1_comm_params_t const comm_params =
    {
    .rx_pin_no = 5,//14,
    .tx_pin_no = 6,//16,
    .rts_pin_no = 255,
    .cts_pin_no = 255,
    .flow_control = APP_UART1_FLOW_CONTROL_DISABLED,
    .use_parity = false,
    #if defined (UART_PRESENT)
    .baud_rate = NRF_UART_BAUDRATE_115200
    #else
    .baud_rate = NRF_UARTE_BAUDRATE_115200
    #endif
    };
    
    APP_UART1_FIFO_INIT(&comm_params,
    UART_RX_BUF_SIZE,
    UART_TX_BUF_SIZE,
    uart1_event_handle,
    APP_IRQ_PRIORITY_LOWEST,
    err_code);
    APP_ERROR_CHECK(err_code);
    }
    
    

    #define UART_TX_BUF_SIZE                256                                         /**< UART TX buffer size. */
    #define UART_RX_BUF_SIZE                256                                         /**< UART RX buffer size. */
    
    static void uart_init(void)
    {
    uint32_t err_code;
    app_uart_comm_params_t const comm_params =
    {
    .rx_pin_no = RX_PIN_NUMBER,
    .tx_pin_no = TX_PIN_NUMBER,
    .rts_pin_no = RTS_PIN_NUMBER,
    .cts_pin_no = CTS_PIN_NUMBER,
    .flow_control = APP_UART_FLOW_CONTROL_DISABLED,
    .use_parity = false,
    #if defined (UART_PRESENT)
    .baud_rate = NRF_UART_BAUDRATE_115200
    #else
    .baud_rate = NRF_UARTE_BAUDRATE_115200
    #endif
    };
    
    APP_UART_FIFO_INIT(&comm_params,
    UART_RX_BUF_SIZE,
    UART_TX_BUF_SIZE,
    uart_event_handle,
    APP_IRQ_PRIORITY_LOWEST,
    err_code);
    APP_ERROR_CHECK(err_code);
    }


     

    int main(void)
    {
    bool erase_bonds;
    
    // Initialize.
    uart_init();
    uart1_init();
    log_init();
    timers_init();
    buttons_leds_init(&erase_bonds);
    
    }
    

Reply
  • Hi Martin,

    Thank you very much for your answer, I follow the debug steps and trace the error code, it seems that the error code number is NRF_ERROR_DATA_SIZE(Invalid Data size), see the below shot, can you point out what's wrong with the data size in my code?  and I attached the zip files which is used for uart1 application.

    app_uart1.zip

    #define UART_TX_BUF_SIZE                256                                         /**< UART TX buffer size. */
    #define UART_RX_BUF_SIZE                256                                         /**< UART RX buffer size. */
    
    
    
    static void uart1_init(void)
    {
    uint32_t err_code;
    app_uart1_comm_params_t const comm_params =
    {
    .rx_pin_no = 5,//14,
    .tx_pin_no = 6,//16,
    .rts_pin_no = 255,
    .cts_pin_no = 255,
    .flow_control = APP_UART1_FLOW_CONTROL_DISABLED,
    .use_parity = false,
    #if defined (UART_PRESENT)
    .baud_rate = NRF_UART_BAUDRATE_115200
    #else
    .baud_rate = NRF_UARTE_BAUDRATE_115200
    #endif
    };
    
    APP_UART1_FIFO_INIT(&comm_params,
    UART_RX_BUF_SIZE,
    UART_TX_BUF_SIZE,
    uart1_event_handle,
    APP_IRQ_PRIORITY_LOWEST,
    err_code);
    APP_ERROR_CHECK(err_code);
    }
    
    

    #define UART_TX_BUF_SIZE                256                                         /**< UART TX buffer size. */
    #define UART_RX_BUF_SIZE                256                                         /**< UART RX buffer size. */
    
    static void uart_init(void)
    {
    uint32_t err_code;
    app_uart_comm_params_t const comm_params =
    {
    .rx_pin_no = RX_PIN_NUMBER,
    .tx_pin_no = TX_PIN_NUMBER,
    .rts_pin_no = RTS_PIN_NUMBER,
    .cts_pin_no = CTS_PIN_NUMBER,
    .flow_control = APP_UART_FLOW_CONTROL_DISABLED,
    .use_parity = false,
    #if defined (UART_PRESENT)
    .baud_rate = NRF_UART_BAUDRATE_115200
    #else
    .baud_rate = NRF_UARTE_BAUDRATE_115200
    #endif
    };
    
    APP_UART_FIFO_INIT(&comm_params,
    UART_RX_BUF_SIZE,
    UART_TX_BUF_SIZE,
    uart_event_handle,
    APP_IRQ_PRIORITY_LOWEST,
    err_code);
    APP_ERROR_CHECK(err_code);
    }


     

    int main(void)
    {
    bool erase_bonds;
    
    // Initialize.
    uart_init();
    uart1_init();
    log_init();
    timers_init();
    buttons_leds_init(&erase_bonds);
    
    }
    

Children
No Data
Related