SDK version: nRF5_SDK_15.3.0
Platform: nRF52840 DK
SoftDevice: s140
--
Hi All,
I use blinky_freertos example to add nrf_serial lib to send/receive AT command by UART port.
It's work when I press "build and run" on SES IDE,
bit if I switch the power key on nRF52840DK, it's didn't work.
I try to trace to find that nrf_serial_init() call nrf_queue_reset() and the nrf_queue_reset() can not return.
I don't know why.
NRF_SERIAL_UART_DEF(serial1_uarte, 1);
NRF_SERIAL_DRV_UART_CONFIG_DEF(m_uarte1_drv_config,
ARDUINO_0_PIN, ARDUINO_1_PIN,
RTS_PIN_NUMBER, CTS_PIN_NUMBER,
NRF_UART_HWFC_DISABLED, NRF_UART_PARITY_EXCLUDED,
NRF_UART_BAUDRATE_115200,
UART_DEFAULT_CONFIG_IRQ_PRIORITY);
NRF_SERIAL_CONFIG_DEF(serial1_config, NRF_SERIAL_MODE_DMA,
&serial1_queues, &serial1_buffs, NULL, sleep_handler);
static void uart_init(void)
{
uint32_t err_code;
const app_uart_comm_params_t comm_params =
{
RX_PIN_NUMBER,
TX_PIN_NUMBER,
RTS_PIN_NUMBER,
CTS_PIN_NUMBER,
UART_HWFC,
false,
#if defined (UART_PRESENT)
NRF_UART_BAUDRATE_115200
#else
NRF_UARTE_BAUDRATE_115200
#endif
};
APP_UART_FIFO_INIT(&comm_params,
UART_RX_BUF_SIZE,
UART_TX_BUF_SIZE,
uart_error_handle,
APP_IRQ_PRIORITY_LOWEST,
err_code);
APP_ERROR_CHECK(err_code);
}
int main(void)
{
ret_code_t err_code;
ret_code_t ret;
uart_init();
ret = nrf_drv_clock_init();
APP_ERROR_CHECK(ret);
ret = nrf_drv_power_init(NULL);
APP_ERROR_CHECK(ret);
nrf_drv_clock_lfclk_request(NULL);
ret = app_timer_init();
APP_ERROR_CHECK(ret);
bsp_board_init(BSP_INIT_LEDS | BSP_INIT_BUTTONS);
ret = nrf_serial_init(&serial1_uarte, &m_uarte1_drv_config, &serial1_config);
APP_ERROR_CHECK(ret);
xMutex = xSemaphoreCreateMutex();
at_setting(_AT, 3000);
at_setting(_QICSGP, 200);
at_setting(_QIACT_1, 2000);
at_setting(_QIACT_IP, 2000);
// MQTT AT Command
at_setting(_QMTCFG_VER_0, 300);
at_setting(_QMTOPEN_0, 5000);
at_setting(_QMTCONN_0, 3000);
if( xMutex != NULL )
{
UNUSED_VARIABLE(xTaskCreate(mqtt_sub_task_function, "SUB", configMINIMAL_STACK_SIZE + 200, NULL, 3, &mqtt_sub_task_handle));
UNUSED_VARIABLE(xTaskCreate(mqtt_pub_task_function, "PUB", configMINIMAL_STACK_SIZE + 200, NULL, 3, &mqtt_pub_task_handle));
// Activate deep sleep mode
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
vTaskStartScheduler();
}
while (true)
{
// FreeRTOS should not be here... FreeRTOS goes back to the start of stack
// in vTaskStartScheduler function.
}
}
BTW, this example I use app_timer(RTC1) and FreeRTOS timer(RTC2)
Thanks.
Tim