Rodkin 2019-04-06 23:32 采纳率: 0%
浏览 812
已结题

nrf51802接收串口数据,导致系统重启

用nrf51802作为数据透传模块,当上位MCU发送串口数据,导致nrf51802系统重启

void UART0_IRQHandler(void)
{
// Handle reception
if (NRF_UART0->EVENTS_RXDRDY != 0)
{
uint32_t err_code;

    // Clear UART RX event flag
    NRF_UART0->EVENTS_RXDRDY = 0;

    // Write received byte to FIFO
    err_code = app_fifo_put(&m_rx_fifo, (uint8_t)NRF_UART0->RXD);
    if (err_code != NRF_SUCCESS)
    {
        app_uart_evt_t app_uart_event;
        app_uart_event.evt_type          = APP_UART_FIFO_ERROR;
        app_uart_event.data.error_code   = err_code;
        m_event_handler(&app_uart_event);
    }
    // Notify that new data is available if this was first byte put in the buffer.
    else if (FIFO_LENGTH(m_rx_fifo) == 1)
    {
        app_uart_evt_t app_uart_event;
        app_uart_event.evt_type = APP_UART_DATA_READY;
        m_event_handler(&app_uart_event);
    }
    else
    {
        // Do nothing, only send event if first byte was added or overflow in FIFO occurred.
    }
}

// Handle transmission.
if (NRF_UART0->EVENTS_TXDRDY != 0)
{
    // Clear UART TX event flag.
    NRF_UART0->EVENTS_TXDRDY = 0;
    on_uart_event(ON_TX_READY);
}

// Handle errors.
if (NRF_UART0->EVENTS_ERROR != 0)
{
    uint32_t       error_source;
    app_uart_evt_t app_uart_event;

    // Clear UART ERROR event flag.
    NRF_UART0->EVENTS_ERROR = 0;

    // Clear error source.
    error_source        = NRF_UART0->ERRORSRC;
    NRF_UART0->ERRORSRC = error_source;

    app_uart_event.evt_type                 = APP_UART_COMMUNICATION_ERROR;
    app_uart_event.data.error_communication = error_source;

    m_event_handler(&app_uart_event);
}

}

  • 写回答

1条回答 默认 最新

  • devmiao 2019-04-06 23:55
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器