Hi, I'm using a timer to send message over uart. Here is the initialization code:
err_code = app_timer_create(&m_uart_timeout_timer, APP_TIMER_MODE_SINGLE_SHOT, uart_timeout_handler);
APP_ERROR_CHECK(err_code);
err_code = app_timer_create(&m_cmd_timer, APP_TIMER_MODE_REPEATED, send_cmd_handler);
APP_ERROR_CHECK(err_code);
nrf_drv_uart_config_t uart_config = NRF_DRV_UART_DEFAULT_CONFIG;
uart_config.baudrate = NRF_UART_BAUDRATE_9600;
uart_config.pselrxd = 2;
uart_config.pseltxd = 1;
err_code = nrf_drv_uart_init(&uart_config, my_uart_event_handler);
APP_ERROR_CHECK(err_code);
err_code = app_timer_start(m_cmd_timer, APP_TIMER_TICKS(5000, 0), NULL);
APP_ERROR_CHECK(err_code);
nrf_drv_uart_rx_enable();
Here is the handler:
void send_cmd_handler(void *p_context)
{
uint8_t tx_data[3] = {0x05, 0xdf, 0xad};
uint8_t tx_len = 3;
uint32_t err_code;
err_code = nrf_drv_uart_tx(tx_data, 3);
APP_ERROR_CHECK(err_code);
err_code = app_timer_start(m_uart_timeout_timer, UART_TIMEOUT, NULL);
APP_ERROR_CHECK(err_code);
}
I am receiving the uart data using ftdi board. The incoming data is shown as:
05 80 02 05 ff 01 05 ff 01 Rest all are 05 ff 01.
If I remove the timer and call the function separately, the data received is correct. Don't know what I'm doing wrong. Please help.
Regards
Lalit