This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

nrf52840 crashes after connecting usb

I'm trying to implement usb function on the nrf52840. The moment that I connect the usb to the computer the chip resets.

With gdb debugger i found out where the fault happens. It happens if he jumps back in the file core_cm4.h on line 1629.

image description

the assemly code where i think the fault happens is:

0x6de <NVIC_EnableIRQ+34>       adds   r7, #12
0x6e0 <NVIC_EnableIRQ+36>       mov    sp, r7 
0x6e2 <NVIC_EnableIRQ+38>       ldr.w  r7, [sp], #4
0x6e8 <NVIC_EnableIRQ+44>       b.n    0x8ec <nrf_drv_power_usbevt_init+48> 
0x6ea <NVIC_EnableIRQ+46>       b.n    0x6ee <NVIC_ClearPendingIRQ+2>

registers:

===== arm v7m registers (0) r0 (/32): 0x00000001 (1) r1 (/32): 0xE000E100 (2) r2 (/32): 0x00000080 (3) r3 (/32): 0x00000001 (4) r4 (/32): 0x00000000 (5) r5 (/32): 0x00000000 (6) r6 (/32): 0x00000000 (7) r7 (/32): 0x2000FF98 (8) r8 (/32): 0x00000000 (9) r9 (/32): 0x00000000 (10) r10 (/32): 0x20000000 (11) r11 (/32): 0x00000000 (12) r12 (/32): 0x00000000 (13) sp (/32): 0x2000FF98 (14) lr (/32): 0x000007B7 (15) pc (/32): 0x000006DE (16) xPSR (/32): 0x01000000 (17) msp (/32): 0x2000FF98 (18) psp (/32): 0x00000000 (19) primask (/1): 0x00 (20) basepri (/8): 0x00 (21) faultmask (/1): 0x00 (22) control (/2): 0x00 (23) d0 (/64): 0x0000000000000000 (24) d1 (/64): 0x0000000000000000 (25) d2 (/64): 0x0000000000000000 (26) d3 (/64): 0x0000000000000000 (27) d4 (/64): 0x0000000000000000 (28) d5 (/64): 0x0000000000000000 (29) d6 (/64): 0x0000000000000000 (30) d7 (/64): 0x0000000000000000 (31) d8 (/64): 0x0000000000000000 (32) d9 (/64): 0x0000000000000000 (33) d10 (/64): 0x0000000000000000 (34) d11 (/64): 0x0000000000000000 (35) d12 (/64): 0x0000000000000000 (36) d13 (/64): 0x0000000000000000 (37) d14 (/64): 0x0000000000000000 (38) d15 (/64): 0x0000000000000000 (39) fpscr (/32): 0x00000000

I tried the example code and found a difference in the compiling on that line. So I think that the reason that it crashes is there: image description

  • Added the wrong start up file (from an older chip) so the vector table was incorrect. When the interrupt occurt it got to the wrong vector -> so the processor crasht

  • Hi, Steven. I was trying to build several examples from SDK (usb hid, usb cdc) and I have got the same errors. I have also tried to flash precompiled hex from the SDK, but my PC couldn't recognize usb device. I am new to Nordic devices, so I have next questions. How can I change the start up file? Where it is supposed to be?

Related