microcontrollerpic24

Does a software reset clear the GPIOs state on PIC24?


I am trying to find out if a software reset would cause the GPIO state to default back to a reset states on PIC24F?

The reset command i would like to use:

asm ("reset");

I could not find the answer in the documentation so i tried the following tests.

Test 1:

(pseudo code). 
start firmware
wait 5 sec
turn LED on
wait 2 sec
reset soft using the code -> asm ("reset");

When this reset method is use, the behavior is as follow.
power on
LED off for 5 seconds
LED on for 2 seconds
...
LED off for 5 seconds
LED on for 2 seconds

Test 2:

(pseudo code). 
start firmware
wait 5 sec
turn LED on
wait 2 sec
reset soft using the code -> ((void(*)())NULL)();

When this "reset" (jump) method is use, the behavior is as follow.
power on
LED off for 5 seconds
LED on indefinitelly after

Can someone answer the initial question and explain why the PIC behave this way ?


Solution

  • Test 1 will perform a Hard reset, i.e. every PIN will reset to whatever default the Datasheet specifies.

    Test 2 will not perform a Hard Reset, it will JMP to the Reset Address, which from memory is 0x0 on the PIC24.

    Now, in both cases the Firmware will reinitialize (restart) and that in most cases is where the GPIO, etc would be set as per the Software requirements. It looks like your code doesn't set any GPIO as part of the Firmware.