Hallo Nordic team,
We are developing our own product based on the nRF9160. The software we wrote must use ADC in order to measure battery voltage and things are working well. However, sometimes we are encountering a BUS FAULT when the function adc_read(adc_dev, &sequence); is called. This bus fault is not persistent and doesn't happen all the time (sometimes once every 100 or 200 calls to adc_read(adc_dev, &sequence); sometimes twice or 3 times.
The ADC peripheral is in the non-secure sector and the same bus fault happens using SDK 1.2.1 and 1.3.1. Debugging is a bit hard as we dont know when this problem happens. Also, looking at the bus faults (as you can see in the following log) doesn't tell so many information other than the BFAR address is located in the SRAM (my assumption).
I am afraid that this problem is happening because of unaligned memory access somehow as it happened only one time that we got a USAGE FAULT instead of BUS FAULT (see LOG of usage fault). I wish you could help me to find out what is causing this strange problem and more information can be provided if required. Thanks
LOG of 3 bus faults:
E: ***** BUS FAULT *****
E: Precise data bus error
E: BFAR Address: 0x2e343430
E: r0/a1: 0x2e34342c r1/a2: 0x00000000 r2/a3: 0x40008000
E: r3/a4: 0x200225b8 r12/ip: 0x200253fc r14/lr: 0x0001940f
E: xpsr: 0x81020000
E: s[ 0]: 0x00000000 s[ 1]: 0x00000000 s[ 2]: 0x00000000 s[ 3]: 0x00000000
E: s[ 4]: 0x00000000 s[ 5]: 0x00000000 s[ 6]: 0x00000000 s[ 7]: 0x00000000
E: s[ 8]: 0x00000000 s[ 9]: 0x00000000 s[10]: 0x00000000 s[11]: 0x00000000
E: s[12]: 0x00000000 s[13]: 0x00000000 s[14]: 0x00000000 s[15]: 0x00000000
E: fpscr: 0x40008000
E: Faulting instruction address (r15/pc): 0x00019442
E: >>> ZEPHYR FATAL ERROR 0: CPU exception on CPU 0
E: Current thread: 0x20025b7c (unknown)
E: Halting system
E: ***** BUS FAULT *****
E: Precise data bus error
E: BFAR Address: 0x2c4d2c37
E: r0/a1: 0x2c4d2c33 r1/a2: 0x00000000 r2/a3: 0x40008000
E: r3/a4: 0x200225b8 r12/ip: 0x200253fc r14/lr: 0x0001940f
E: xpsr: 0x81020000
E: s[ 0]: 0x00000000 s[ 1]: 0x00000000 s[ 2]: 0x00000000 s[ 3]: 0x00000000
E: s[ 4]: 0x00000000 s[ 5]: 0x00000000 s[ 6]: 0x00000000 s[ 7]: 0x00000000
E: s[ 8]: 0x00000000 s[ 9]: 0x00000000 s[10]: 0x00000000 s[11]: 0x00000000
E: s[12]: 0x00000000 s[13]: 0x00000000 s[14]: 0x00000000 s[15]: 0x00000000
E: fpscr: 0x40008000
E: Faulting instruction address (r15/pc): 0x00019442
E: >>> ZEPHYR FATAL ERROR 0: CPU exception on CPU 0
E: Current thread: 0x20025b7c (unknown)
E: Halting system
E: ***** BUS FAULT *****
E: Precise data bus error
E: BFAR Address: 0x322e3230
E: r0/a1: 0x322e322c r1/a2: 0x00000000 r2/a3: 0x40008000
E: r3/a4: 0x200225b8 r12/ip: 0x200253fc r14/lr: 0x0001940f
E: xpsr: 0x81020000
E: s[ 0]: 0x00000000 s[ 1]: 0x00000000 s[ 2]: 0x00000000 s[ 3]: 0x00000000
E: s[ 4]: 0x00000000 s[ 5]: 0x00000000 s[ 6]: 0x00000000 s[ 7]: 0x00000000
E: s[ 8]: 0x00000000 s[ 9]: 0x00000000 s[10]: 0x00000000 s[11]: 0x00000000
E: s[12]: 0x00000000 s[13]: 0x00000000 s[14]: 0x00000000 s[15]: 0x00000000
E: fpscr: 0x40008000
E: Faulting instruction address (r15/pc): 0x00019442
E: >>> ZEPHYR FATAL ERROR 0: CPU exception on CPU 0
E: Current thread: 0x20025b7c (unknown)
E: Halting system
LOG of usage fault:
E: ***** USAGE FAULT *****
E: Unaligned memory access
E: r0/a1: 0x4d2c3839 r1/a2: 0x00000000 r2/a3: 0x40008000
E: r3/a4: 0x200225b8 r12/ip: 0x200253fc r14/lr: 0x0001940f
E: xpsr: 0x81020000
E: s[ 0]: 0x00000000 s[ 1]: 0x00000000 s[ 2]: 0x00000000 s[ 3]: 0x00000000
E: s[ 4]: 0x00000000 s[ 5]: 0x00000000 s[ 6]: 0x00000000 s[ 7]: 0x00000000
E: s[ 8]: 0x00000000 s[ 9]: 0x00000000 s[10]: 0x00000000 s[11]: 0x00000000
E: s[12]: 0x00000000 s[13]: 0x00000000 s[14]: 0x00000000 s[15]: 0x00000000
E: fpscr: 0x40008000
E: Faulting instruction address (r15/pc): 0x00019442
E: >>> ZEPHYR FATAL ERROR 0: CPU exception on CPU 0
E: Current thread: 0x20025b7c (unknown)
E: Halting system