Forum: Mikrocontroller und Digitale Elektronik sleep Modus bei PIC


von Axel F. (Gast)


Lesenswert?

Moin Leute,

ich versuche gerade meinen PIC18F258 in den sleep Modus zu versetzen 
aber er will nicht so richtig. Er scheint den Befehl einfach zu 
überspringen.

Welche Randbedingungen sind denn zu beachten. Setze jetzt nur genau vor 
dem sleep Befehl das GIE auf disable und nach dem sleep Befehl gleich 
wieder auf enable.

Gibt es noch mehr zu beachten? Zum Beispiel im Konfigurationswort oder 
weitere Flags die gesetzt/rückgesetzt werden müssen?

Vielen dank schonmal für die Hilfe,

MfG Axel

von chris (Gast)


Lesenswert?

Hallo, setzte das GIE in einem loop auf disable, sonst kann es sein, daß 
es
nicht disabilitiert wird. Ev. kann das der Grund sein. Ein anderer Grund 
kann wake on pin change sein, d.h. wenn du das Port nicht eingelesen 
hast und es hat sich seit dem letzten einlesen verändert, dann geht er 
auch nicht in den sleep. Das sind mal die 2 Gründe, welche mir am 
warscheinlichsten vorkommen.

von tastendrücker (Gast)


Lesenswert?

Aus dem Manual:

24.3.2 WAKE-UP USING INTERRUPTS
When global interrupts are disabled (GIE cleared) and
any interrupt source has both its interrupt enable bit
and interrupt flag bit set, one of the following will occur:

• If an interrupt condition (interrupt flag bit and
interrupt enable bits are set) occurs before the
execution of a SLEEP instruction, the SLEEP
instruction will complete as a NOP. Therefore, the
WDT and WDT postscaler will not be cleared, the
TO bit will not be set and the PD bit will not be
cleared.

• If the interrupt condition occurs during or after
the execution of a SLEEP instruction, the device
will immediately wake-up from Sleep. The SLEEP
instruction will be completely executed before the
wake-up. Therefore, the WDT and WDT
postscaler will be cleared, the TO bit will be set
and the PD bit will be cleared.

Even if the flag bits were checked before executing a
SLEEP instruction, it may be possible for flag bits to
become set before the SLEEP instruction completes. To
determine whether a SLEEP instruction executed, test
the PD bit. If the PD bit is set, the SLEEP instruction
was executed as a NOP.
To ensure that the WDT is cleared, a CLRWDT
instruction should be executed before a SLEEP
instruction

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.