Hello,
My code( I add a source code lower ) has error on bold line printing NRF_ERROR_INVALID_STATE. The program uses three timers and init by "MAX_TIMERS = 6" and "OP_QUEUE_SIZE = 5".
Because of NRF_ERROR_INVALID_STATE, I create new timer before start timer(bold line!) but in that case, app_timer_create() is crashed by NRF_ERROR_NO_MEM. Before I said, the program not use timers over "MAX_TIMERS = 6". Even I increase values of "APP_TIMER_MAX_TIMERS" and "APP_TIMER_OP_QUEUE_SIZE" but same problem occurs.
I don't know that what is wrong on my code.
Thanks.
int main() {
timers_init();
ble_start();
for (;;)
{
uint8_t CurFrm[MAX_BLE_DATA_LENGTH] = {0,};
NVIC_DisableIRQ(UART0_IRQn);
popFrmQueue(CurFrm);
NVIC_EnableIRQ(UART0_IRQn);
if ( CurFrm[RF_TYPE_IND] == RFTYPE_RF) {
ble_stop();
RF_init(addr);
memcpy(packet,(CurFrm+1), MAX_BLE_DATA_LENGTH-1);
RF_send();
ble_start();
} else if ( CurFrm[RF_TYPE_IND] == RFTYPE_BLE ) {
if ( BLE_CONN_FLAG == true ) {
err_code = app_timer_start(m_data_send_timer_id, DATA_SEND_INTERVAL, NULL);
APP_ERROR_CHECK(err_code);
}
TIMEOUT_FLAG = false; // timeout flag init
**err_code = app_timer_start(m_wait_timer_id, BLE_TX_COMPLTE_WAIT_INTERVAL, NULL);**
APP_ERROR_CHECK(err_code);
while (BLE_TX_COMPLETE_FLAG != true && BLE_CONN_FLAG == true && TIMEOUT_FLAG != true) {
err_code = sd_app_event_wait();
APP_ERROR_CHECK(err_code);
}
err_code = app_timer_stop(m_wait_timer_id);
APP_ERROR_CHECK(err_code);
TIMEOUT_FLAG = false; // timeout flag init
simple_uart_putstring((const uint8_t *)"ble tx complete end\r\n");
if ( BLE_TX_COMPLETE_FLAG == true ) {
err_code = app_timer_stop(m_data_send_timer_id);
APP_ERROR_CHECK(err_code);
BLE_TX_COMPLETE_FLAG = false;
}
}
return 0;
}