PDA

View Full Version : How to get PIC out of Sleep mode and turn-on LCD, vice versa ?



aggie007
- 20th November 2007, 22:47
Hi,

I have PIC18F4525 connected to a LCD (16X2).

1. I want to set the PIC into SLEEP mode.

2. I want the LCD screen to turn-on when a push-button, connected to the PIC, is pressed. This means that the PIC should be switched out of SLEEP mode.

3. The LCD screen should remain ON for the next 5 mins, displaying the desired result.

4. The LCD should then turn-off after 5 mins, i.e. the PIC should go back into the SLEEP mode.


I would really appreciate if you guys can give me suggestions on how to write a code for this.

Thanks !

Jerson
- 21st November 2007, 01:09
1. I want to set the PIC into SLEEP mode
Use the following lines of code
@ sleep
@ nop
@ nop
This will give indefinite sleep time

2. I want the LCD screen to turn-on when a push-button, connected to the PIC, is pressed. This means that the PIC should be switched out of SLEEP mode
Configure your PIC to generate an 'interrupt on port change'. You need not enable the interrupt. When the port change occurs, the PIC will execute the statements after sleep.

3. The LCD screen should remain ON for the next 5 mins, displaying the desired result.
Use some kind of timing code to achieve this; either using for loops or timer.

4. The LCD should then turn-off after 5 mins, i.e. the PIC should go back into the SLEEP mode.
Go back to number 1

aggie007
- 27th November 2007, 05:38
Thanks Jerson !!!

I have come up with some kinda code which you can see in my new post titled - "Need help with SLEEP mode ".

Please correct me on it. I would really appreciate everyone's suggestions and help.

Thanks.

Acetronics2
- 27th November 2007, 08:56
Hi, Aggie

Some "bond" to your project ( LOL ):

Here I use a 18F452

LCD is powered Through a P-Mosfet ( Driven by PortB.4 ... LOW for ON )
The "wakeup" interrupt is generated by a Low to High transition on Port B.1 ...

see "sommeil" and "Wakeup" labels for what you look for ...

Alain