Search code examples
microcontrollerreset8051

How to know whether Power on reset or Software reset has occured in 8051 microcontrller


I am developing an application on ATMEL AT89C51 of 8051 family.

Could anyone suggest how to determine in coding whether the reset has been done due to power cycle or through software?


Solution

  • I don't think there is a method to determine how reset has occurred because once reset everything starts from the beginning in 8051.

    One method i guess would work is,

    Say take a variable X, before every software code of reset, just set X=1 (indicating software reset) and store this variable in any ROM if you interfaced externally.

    On every reset, at the beginning include an instance which checks this variable X to see which reset had occurred and change X to 0, for next time detection.

    If you do not have an external ROM, interface an D-latch atleast.

    I hope this works. Do tell me if this works.