Tool/software:
Hi ,
I have an application based on the basic_ble_LP_EM_CC2340R5_freertos_ticlang example (Central). When I receive the command string AT+SCAN\r\n from UART, After starting the scan, the program jumps to ICall_abort?
Reference article:
SDK : simplelink_lowpower_f3_sdk_7_40_00_64
My code
/* * ======== callbackFxn ======== */ void callbackFxn(UART2_Handle handle, void *buffer, size_t count, void *userArg, int_fast16_t status) { if (status != UART2_STATUS_SUCCESS) { /* RX error occured in UART2_read() */ while (1) {} } numBytesRead = count; if(scan_state == 0) sem_post(&sem); } /* * ======== start_scan ======== */ void start_scan(void) { bStatus_t status; const BLEAppUtil_ScanStart_t centralScanStartParams = { /*! Zero for continuously scanning */ .scanPeriod = DEFAULT_SCAN_PERIOD, /* Units of 1.28sec */ /*! Scan Duration shall be greater than to scan interval,*/ /*! Zero continuously scanning. */ .scanDuration = DEFAULT_SCAN_DURATION, /* Units of 10ms */ /*! If non-zero, the list of advertising reports will be */ /*! generated and come with @ref GAP_EVT_SCAN_DISABLED. */ .maxNumReport = APP_MAX_NUM_OF_ADV_REPORTS }; status = BLEAppUtil_scanStart(¢ralScanStartParams); if(status == FAILURE) { while(1){} } } /* * ======== mainThread ======== */ void *mainThread(void *arg0) { char input; const char echoPrompt[] = "Echoing characters:\r\n"; UART2_Handle uart; UART2_Params uartParams; int32_t semStatus; uint32_t status = UART2_STATUS_SUCCESS; /* Call driver init functions */ GPIO_init(); /* Configure the LED pin */ //GPIO_setConfig(CONFIG_GPIO_LED_0, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW); /* Create semaphore */ semStatus = sem_init(&sem, 0, 0); if (semStatus != 0) { /* Error creating semaphore */ while (1) {} } /* Create a UART in CALLBACK read mode */ UART2_Params_init(&uartParams); uartParams.readMode = UART2_Mode_CALLBACK; uartParams.readCallback = callbackFxn; uartParams.baudRate = 115200; uart = UART2_open(CONFIG_DISPLAY_UART, &uartParams); if (uart == NULL) { /* UART2_open() failed */ while (1) {} } /* Turn on user LED to indicate successful initialization */ //GPIO_write(CONFIG_GPIO_LED_0, CONFIG_GPIO_LED_ON); /* Pass NULL for bytesWritten since it's not used in this example */ UART2_write(uart, echoPrompt, sizeof(echoPrompt), NULL); /* Loop forever echoing */ while (1) { switch(scan_state) { case 0: numBytesRead = 0; /* Pass NULL for bytesRead since it's not used in this example */ status = UART2_read(uart, &input, 1, NULL); if (status != UART2_STATUS_SUCCESS) { /* UART2_read() failed */ while (1) {} } /* Do not write until read callback executes */ sem_wait(&sem); if (numBytesRead > 0) { ch_buffer[ch_cnt++] = (uint8_t)input; if(strstr((const char *)ch_buffer,(const char *)"\r\n" ) != 0) { if(strcmp((const char *)ch_buffer,(const char *)"AT+SCAN\r\n") == 0 ) { scan_state = 1; status = UART2_write(uart, (const char *)"Msg:success:", strlen((const char *)"Msg:success:"), NULL); } else{ status = UART2_write(uart, (const char *)"ack:", strlen((const char *)"ack:"), NULL); } status = UART2_write(uart, (const char *)ch_buffer, strlen((const char *)ch_buffer), NULL); if (status != UART2_STATUS_SUCCESS) { /* UART2_write() failed */ while (1) {} } void *ptr = (void *)ch_buffer; memset(ptr,0,100); ch_cnt = 0; } } break; case 1: start_scan(); scan_state = 2; break; } } }
ICall_abort
/** * Aborts. * * This is preferred over C runtime abort() function, * in an external image since the C runtime abort() is only * guaranteed in a root image which contains the C runtime * entry function that is executed upon startup. */ ICall_Errno ICall_abort(void) { #ifdef HALNODEBUG #elif defined(EXT_HAL_ASSERT) HAL_ASSERT(HAL_ASSERT_CAUSE_ICALL_ABORT); #else { volatile uint8_t j=1; while(j); } #endif /* EXT_HAL_ASSERT */ ICALL_HOOK_ABORT_FUNC(); return(ICALL_ERRNO_SUCCESS); }