logo elektroda
logo elektroda
X
logo elektroda
REKLAMA
REKLAMA
Adblock/uBlockOrigin/AdGuard mogą powodować znikanie niektórych postów z powodu nowej reguły.

Jak wybudzić AT89C2051 z trybu power down bez restartu programu?

brodziszx 19 Lip 2007 11:23 1782 2
REKLAMA
  • #1 4094734
    brodziszx
    Poziom 12  
    Posty: 33
    Ocena: 2
    Witam!

    Mam taki problem. Zbudowalem pilota na 4 przyciski, wyswietlacz 7-segmentowy, podwojny itd. na at89c2051 i wszystko dziala. Jest tylko problem z wyprowadzeniem uC z trybu power down! Na poczatku inicjalizuje potrzebne mi rzeczy, ktore uC ma zrobic tylko raz i w momencie kiedy nic nie jest wcisniete wejsc w stan uspienia. Spr wchodzi, bo pobor pradu spada znacznie. Jednak wychodzac z tego stanu startuje program od poczatku od main() (pisze w C). Wiem, ze tam wchodzi dlatego, ze w inicjalizacji wpisuje do zmiennej wartosc mowiaca ze zrobil ta inicjalizacje i wrzucam to na wyswietlacz. Pozniej spr czy ta zmienna ma wartosc, ktora wpisalem w inicjalizacji i albo robie inicjalizacje (restart pilota) albo przechodze dalej. Objaw jest taki ze po wyprowadzeniu ze "smierci klinicznej" na wyswietlaczu mam caly czas ta wartosc z inicjalizacji! Czytalem w nocie, ze uC budzac sie do zycia wykonuje nastepna instrukcje po tej,ktora wprowadzila go w stan uspienia !!! ale u mnie tak nie jest
    Moze ja robie cos zle! Nie wiem. Jesli ktos wie z doswiadczenia lub po prostu wie o co chodzi prosze o pomoc!

    Pozdrawiam
    Radek

    Ps. Ze stanu uspienia wyprowadzam go krotkim sygnalem resetu, jedna z mozliwosci wyprowadzenia z power down.
  • REKLAMA
  • #2 4094912
    jj
    Poziom 19  
    Posty: 145
    Pomógł: 42
    Witam,
    przeczytaj jeszcze raz ten fragment dokumentacji i porównaj tryby Idle i Power down

    Cytat:
    9. Idle Mode
    In idle mode, the CPU puts itself to sleep while all the on-chip peripherals remain active. The
    mode is invoked by software. The content of the on-chip RAM and all the special functions registers
    remain unchanged during this mode. The idle mode can be terminated by any enabled
    interrupt or by a hardware reset.
    The P1.0 and P1.1 should be set to “0” if no external pull-ups are used, or set to “1” if
    external pull-ups are used.
    It should be noted that when idle is terminated by a hardware reset, the device normally
    resumes program execution, from where it left off, up to two machine cycles before the internal
    reset algorithm takes control. On-chip hardware inhibits access to internal RAM in this event, but
    access to the port pins is not inhibited. To eliminate the possibility of an unexpected write to a
    port pin when Idle is terminated by reset, the instruction following the one that invokes Idle
    should not be one that writes to a port pin or to external memory.

    10. Power-down Mode
    In the power-down mode the oscillator is stopped, and the instruction that invokes power-down
    is the last instruction executed. The on-chip RAM and Special Function Registers retain their
    values until the power-down mode is terminated. The only exit from power-down is a hardware
    reset. Reset redefines the SFRs but does not change the on-chip RAM. The reset should not be
    activated before VCC is restored to its normal operating level and must be held active long
    enough to allow the oscillator to restart and stabilize.
    The P1.0 and P1.1 should be set to “0” if no external pull-ups are used, or set to “1” if
    external pull-ups are used.


    Pozdrawiam,
    Jacek
  • #3 4094967
    brodziszx
    Poziom 12  
    Posty: 33
    Ocena: 2
    Czytalem ta note juz kilkadziesiat razy i nie widze, tu zadnej wskazowki dla mnie :(. Napisane jest, ze podtrzymuje pamiec RAM bedac w power down`ie i ze mozna go wybudzic tylko resetem co zreszta robie. Ale uC realizuje program od poczatku.

    Na starcie robie tak:

    if (fstart!=0xCC)
    init_zm();

    pozniej spr czy w pamieci fstart ma wartosc 0xCC i wykonuje init albo nie. Na pilocie widac ze nie zapamietuje tej wartosci poniewaz robi init po wybudzeniu.
    Kolego JJ jakbys mogl sprecyzowac co miales na mysli ??

    Pozdrawiam

    Dodano po 3 [godziny] 59 [minuty]:

    Problem rozwiazany! Moj kompilator dolaczyl sobie jakis plik startup gdzie byly inicjalizacje stosu i inne pierdoly. Zauwazylem tam, ze jest kawalek kodu, ktory zeruje pamiec i wykasowalem ow kawalek :). Wszystko dziala.
    pozdro
REKLAMA