This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

NRF51822 ARMGCC FreeRTOS vTaskDelay not Work.

very sample led blink demo for FreeRTOS and S130 , but fail.

open source

repo: https://github.com/AMJKeyboard/AMJPureBLEKbd

eror code: https://github.com/AMJKeyboard/AMJPureBLEKbd/blob/master/src/main.c#L105

GDB error info:

Breakpoint 1 at 0x1b3c6: file /home/hanchen/projects/AMJPureBLEKbd/src/main.c, line    117.

Breakpoint 1, main () at /home/hanchen/projects/AMJPureBLEKbd/src/main.c:117
117         err_code = nrf_drv_clock_init();
(gdb) b led_toggle_task_function
Breakpoint 2 at 0x1b388: file /home/hanchen/projects/AMJPureBLEKbd/src/main.c, line 92.
(gdb) c
Continuing.

Breakpoint 2, led_toggle_task_function (pvParameter=0x0) at /home/hanchen/projects/AMJPureBLEKbd/src/main.c:92
92          NRF_LOG_INFO("task led_toggle_task_function. \r\n");
(gdb) n
97              NRF_LOG_INFO("led toggle while start. \r\n");
(gdb) n
98              nrf_drv_gpiote_out_toggle(GPIO_LED_OUTPUT_PIN_NUMBER);
(gdb) n
105             vTaskDelay(10);
(gdb) n

Program received signal SIGTRAP, Trace/breakpoint trap.
0xfffffffe in ?? ()
(gdb)

Could SVC_Handler not work? how to debug ?

Compile the project:

 put sdk to nRF_SDK dir.

 cmake . &&  make

 output AMJPureBLEKbd.hex

Append:

version info:

nRF5 SDK v12.1.0

S130 SoftDevice v2.0.1

debug code:

+     // read ic info
+     nrf_ic_info_t ic_info;
+     nrf_ic_info_get(&ic_info);
+     NRF_LOG_INFO("ic_info_get rev:%d, ram size: %d, flash size:%d \r\n",
+                     ic_info.ic_revision, ic_info.ram_size, ic_info.flash_size)
+
+     // set softdevice enable
+     err_code = sd_softdevice_enable(NULL, NULL);
+     NRF_LOG_INFO("sd_softdevice_enable code: %d. \r\n", err_code);
+
+     // check softdevice enable
+     uint8_t sd_is_enable = -1;
+     sd_softdevice_is_enabled(&sd_is_enable);
+     NRF_LOG_INFO("sd_is_enable: %d \r\n", sd_is_enable);

uart output result:

:INFO:ic_info_get rev:3, ram size: 16, flash size:256 
:INFO:sd_softdevice_enable code: 4097. 
:INFO:sd_is_enable: 0 

sd_softdevice_enable error info:

NRF_ERROR_SDM_INCORRECT_INTERRUPT_CONFIGURATION
Incorrect interrupt configuration (can be caused by using illegal priority levels, or having enabled SoftDevice interrupts).

link script:

FLASH (rx) : ORIGIN = 0x1b000, LENGTH = 0x25000
RAM (rwx) :  ORIGIN = 0x20001870, LENGTH = 0x2790

APPEND 2:

Used new version: port_cmsis_systick.c

vTaskDelay still does not work.

new debug info:

+ void nrf_fault_handler(uint32_t id, uint32_t pc, uint32_t info){
+     nrf_drv_gpiote_out_clear(GPIO_LED_OUTPUT_PIN_NUMBER);
+     NRF_LOG_ERROR("nrf_fault_handler id: %d pc:%d info:%d", id, pc, info);
+ }


+     /* Initialize clock driver for better time accuracy in FREERTOS */
+     //err_code = nrf_drv_clock_init();
+     //APP_ERROR_CHECK(err_code);
+ ====
+     err_code = sd_softdevice_enable(NULL, nrf_fault_handler);
+     NRF_LOG_INFO("sd_softdevice_enable code: %d. \r\n", err_code);
+
+     uint8_t sd_is_enable = -1;
+     sd_softdevice_is_enabled(&sd_is_enable);
+     NRF_LOG_INFO("sd_is_enable: %d \r\n", sd_is_enable);

uart output result:

:INFO:sd_softdevice_enable code: 0. 
:INFO:sd_is_enable: 1 
:DEBUG:button_event_setup.
:DEBUG:matrix_init.
:DEBUG:create task led_toggle_task.
:DEBUG:vTaskStartScheduler.
:ERROR:nrf_fault_handler id: 1 pc:37670 info:0
:INFO:task led_toggle_task_function. 
:INFO:vApplicationIdleHook. 
Parents Reply Children
Related