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

Not able to Initialize HIght Speed SPI in nRF Connect SDK v1.5.1

Hello,

I am using nRF5340DK board and I am trying to enable high-speed SPI pins in nrf5340dk_nrf5340_cpuapp.dts

&spi4 {
compatible = "nordic,nrf-spim";
status = "okay";
sck-pin = <8>;
miso-pin = <9>;
mosi-pin = <10>;
};

And enabled configuration in prj.conf :

CONFIG_SPI=y
CONFIG_SPI_4=y

Also added SPI in nrf5340dk_nrf5340_cpuapp.yaml 

identifier: nrf5340dk_nrf5340_cpuapp
name: NRF5340-DK-NRF5340-application-MCU
type: mcu
arch: arm
toolchain:
- gnuarmemb
- xtools
- zephyr
ram: 64
flash: 256
supported:
- gpio
- i2c
- spi
- pwm
- watchdog
- usb_cdc
- usb_device

Once I flash the board, immediately after power ON, DK board is resetting contineously. By connecting SEGGER IDE, I found following error

[00:00:00.405,059] [0m<inf> cp_central: >>>>>>>>>>> In cp ap main[0m
[00:00:03.889,007] [1;31m<err> os: ***** BUS FAULT *****[0m
[00:00:03.889,007] [1;31m<err> os: Precise data bus error[0m
[00:00:03.889,038] [1;31m<err> os: BFAR Address: 0x0[0m
[00:00:03.889,038] [1;31m<err> os: r0/a1: 0x200012f0 r1/a2: 0x00000000 r2/a3: 0x00000000[0m
[00:00:03.889,038] [1;31m<err> os: r3/a4: 0x00000000 r12/ip: 0x000033e4 r14/lr: 0x00018225[0m
[00:00:03.889,038] [1;31m<err> os: xpsr: 0x69000225[0m
[00:00:03.889,038] [1;31m<err> os: Faulting instruction address (r15/pc): 0x00017d98[0m
[00:00:03.889,068] [1;31m<err> os: >>> ZEPHYR FATAL ERROR 0: CPU exception on CPU 0[0m
[00:00:03.889,068] [1;31m<err> os: Fault during interrupt handling
[0m
[00:00:03.889,068] [1;31m<err> os: Current thread: 0x200013a0 (unknown)[0m
[00:00:04.179,931] [1;31m<err> fatal_error: Resetting system

I need help to configure SPI pins (8- SCK,10-MOSI) and how to use them in firmware. It will be helpful if I get any examples. For now, I want SPI freq @1MHz.

Note: If I use other pins then there is no crash. 

Parents
  • Hi,

     

    It looks like you have the correct setup for using SPI, but a fault is triggered during runtime.

    [00:00:03.889,007] [1;31m<err> os: Precise data bus error[0m
    [00:00:03.889,038] [1;31m<err> os: BFAR Address: 0x0[0m

    This indicates that you are executing a NULL pointer somewhere.

     

    Could you try to look at your .map file, or use arm-none-eabi-addr2line to resolve the faulting addresses to source code lines?

    ie.

    arm-none-eabi-addr2line -e build-folder/zephyr/zephyr.elf 0x00017d98
    arm-none-eabi-addr2line -e build-folder/zephyr/zephyr.elf 0x00018225

     

    [00:00:03.889,068] [1;31m<err> os: Current thread: 0x200013a0 (unknown)[0m

    This is a RAM mapped address, so you need to figure out which thread this is by manually checking the build-folder/zephyr/zephyr.map file. It might be that you need to adjust the stack size for this specific thread.

     

    Kind regards,

    Håkon  

  • Hi Håkon

    Thank you for your suggestion. After going through the code I have found that API "dk_buttons_init(button_changed);" is getting called twice and after correcting this SPI4 is up and running. But I am not able to figure out why it is only giving errors with SPI4 and why not in normal scenarios. If in case you have any information then please do let me.

      

Reply Children
No Data
Related