0

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 ?

Guillaume.P
  • 421
  • 1
  • 4
  • 12

2 Answers2

2

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.

Mike
  • 419
  • 3
  • 7
0

The software instruction reset triggers a hardware reset and is as such comparable with a "real" hardware reset. See the specific manual of your device for details. For example, the clock source might not change.

In contrast, your second attempt is just a jump to the reset address. This does not affect GPIO states.


Note: As always in embedded development, you need the manual to understand what you do. If you don't read it, you are "programming by accident" and will have a hard time.

the busybee
  • 10,755
  • 3
  • 13
  • 30
  • 1
    In the doc, It is not clear if the software reset affects the default values of the GPIO. As per section "7.Reset" of the documentation https://ww1.microchip.com/downloads/aemDocuments/documents/MCU16/ProductDocuments/DataSheets/PIC24FJ512GU410-Family-Data-Sheet-DS30010203D.pdf#unique_834 , it says: **Any active source of Reset will make the SYSRST signal active. Many registers associated with the CPU and peripherals are forced to a known Reset state. Most registers are unaffected by a Reset; their status is unknown on POR and unchanged by all other Resets.** – Guillaume.P May 12 '23 at 09:14
  • You did not mention the specific document you read, and since the answer to your main question as well as the reset values of the registers (for GPIO see chapter 11) are in the data sheet, I needed to assume that you did not read it. – the busybee May 12 '23 at 09:18