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

Porting HRS Example to IAR - Crash at SVC 0x10

I'm trying to port the HRS example using S110 Softdevice and SDK 7.1.0 to IAR 7.10 on the pca10028 board.

I've created an IAR project which uses the same files as the Keil version, using the Keil limited demo IDE to determine the paths of each file, and each dependency. The only exception is the arm_startup_nrf51.s is replaced by iar_startup_nrf51.s. I also created a linker .icf file to set the memory regions and stack sizes, as well as the intvec location. This was copied from the file included with IAR 7.10 and placed into the same folder as main.c.

I use nRFGo to erase the part, then load the soft device. I can build the Keil demo and run it, and use the nRFToolbox app's Heartrate Monitor function to see the output from the board.

If I duplicate this with IAR, I can compile and load the app onto the board, and begin execution, but the app crashes when it hits the line:

err_code = sd_softdevice_enable(clock_source, softdevice_assertion_handler);

in softdevice_handler.c.

Digging deeper by tracing through the disassembly, I see that this is a wrapper for calling the SVC interrupt with index 0x10. As soon as this occurs, I get a Hard Fault exception.

I have verified by checking the .map file that my interrupt vectors are being placed at 0x16000, the same as the Keil compiler version.

Does anyone have any clue as to what I may have missed? I can provide a ZIP of the project files if necessary and allowed.

Thanks in advance, Jeff.

Parents
  • I'm not sure of what's causing the error you see, but I was able to port the hrs example by using the hrs IAR example in SDK 6.1.0 as reference.

    Extract the IAR.zip in ..\nRF51_SDK_7.1.0\examples\ble_peripheral\ble_app_hrs\pca10028\s110 to ensure the correct paths. Also had to make some small changes to the retarget.c for it to be compatible with IAR. You can replace the defalt on with this one: retarget.c. Then choose the debugger you're using in the debugger options.

  • Thanks for the files. I diff'ed them with mine, and I think the main difference was that I had fat fingered the RAM start in my linker file. I had "define symbol ICFEDIT_region_RAM_start = 0x20000200;" when I needed 0x20002000; After that, the project seems to run, although there are still some oddities. With the Keil demo project, when I look at the toolbox HRM app, the climb and fall of the rate was rock steady, but with the IAR compiled version, it misses a beat now and then. I'll try to reproduce your directory structure exactly so I can run your complete project and see if that continues to happen.

Reply
  • Thanks for the files. I diff'ed them with mine, and I think the main difference was that I had fat fingered the RAM start in my linker file. I had "define symbol ICFEDIT_region_RAM_start = 0x20000200;" when I needed 0x20002000; After that, the project seems to run, although there are still some oddities. With the Keil demo project, when I look at the toolbox HRM app, the climb and fall of the rate was rock steady, but with the IAR compiled version, it misses a beat now and then. I'll try to reproduce your directory structure exactly so I can run your complete project and see if that continues to happen.

Children
No Data
Related