I'm working with the nRF5 SDK v15.3 and a nRF52840 Dongle; developing on Keil uVision V5.29; Compiler: Armcc V5.06
While debugging I that in my programm a NULL pointer was dereferenced without the programm crashing and I am really confused about that.
To verify this I wrote the following code:
uint8_t test = 10; uint8_t *p_test = NULL; if(*p_test != test){ *p_test = test; } volatile uint8_t test2 = 0; test2 = *p_test;
I can step through this code line by line with a debugger without causing to programm to crash. The only thing that does not seem to work is to write to the NULL address, since the variable test2 gets the value '0xE8' at the end and not '10'.
I attached is a picture from the debugger with Call Stack and dissaembly
.
I was under the assumption that dereferncing a NULL pointer or trying to write something to the NULL address would cause a hard fault on any ARM architecture microcontroller. Obviously I was wrong. Can please someone explain to me why that code works?
Kind Regards, lorv