I am debugging UART routine and met an issue that it can return back to mainloop after UART receiving. Is there anybody who can give any advice? Thanks in advance. Alex
below is the code:
/**@brief Function for initializing the UART module.
*/
static void uart_init(void)
{
/**@snippet [UART Initialization] */
simple_uart_config(RTS_PIN_NUMBER,TX_PIN_NUMBER,CTS_PIN_NUMBER,RX_PIN_NUMBER, HWFC);
NRF_UART0->INTENSET = UART_INTENSET_RXDRDY_Enabled << UART_INTENSET_RXDRDY_Pos;
NVIC_SetPriority(UART0_IRQn, APP_IRQ_PRIORITY_LOW);
NVIC_EnableIRQ(UART0_IRQn);
/**@snippet [UART Initialization] */
}
void UART0_IRQHandler(void)
{
cMachine ++;
}
/**@brief Application main functio
*/
int main(void)
{
// Initialize
APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, false);// stop RTC1,set Timer buffer size, tick number
// setup_RTC1_20ms_timer();
APP_GPIOTE_INIT(APP_GPIOTE_MAX_USERS);// set memory buffer
ble_stack_init_total();
uart_init();
gap_params_init();// set minimum interval, maximum interval, slave latency, supervision timeout, GAP security, Name, encoding and sending
services_init();// send the data from BLE to UART, set 16-bit UUID to 128-bit UUID, set RX characteristics(0x0003), set Tx characteristics(0x0002)
advertising_init();//builds a structure to be passed to the stack when starting advertising, Encodes the required advertising data and passes it to the stack.
conn_params_init();//Set the connection params in stack and fetch connection params from stack.
sec_params_init();// initializing security parameters.
advertising_start();
for(;;) // mainloop
{
if (cMachine != 0)
{
nrf_delay_ms(1);
}
}
}