Log in

View Full Version : Waking a sleeping PIC



anj
- 18th May 2005, 04:21
Gday all
I am looking for ideas on the best way to waken a sleeping pic, based on data sent from a PC.
I am planning on using a 16f88, but on reading the datasheet, i cannot use an interrupt on the usart unless i'm in synchronous mode.
I need to operate asynch, so was wondering what the best option would be.
Basically i will have a piece of equipment controlled by a bog std RS232 connection.
I plan to tap into the PC Tx, and passively snoop for special commands to operate a power switch.
On receiving a specific code, the PIC will open a MOSFET and thus supply power to the equipment.
On receiving another code, the PIC will close the MOSFET and hence turn off power ( but stay powered itself ). After say 10mins with no serial traffic, ( and Mosfet turned off ), i will put the PIC to sleep.
When asleep ( which may last for days ), i need to still watch/trap any serial traffic, and if detected, wake up the PIC and then act on it.
So, what is the best way to do this.
1) Can i waken the pic and still trap the data in one operation
2) Do i need to say set a pin to input, and just use a std "on change" interrupt to waken the PIC, then configure the usart to send a code to the host PC saying i',m awake, then get the PC to resend the real code.
3) anything better?
I'm still going through the datasheets, but still cant find a way of doing it in one operation, which is the preferred method.
Any pointers greatly appreciated.
Andrew

Dave
- 18th May 2005, 11:52
Anj, Why not just tie the rx line of the pic to say portb.0. Then setup the pic for external interrupt. When there is a change in the state of the rx pin you would wake and disable the interrupt then capture the the command? Just a thought.....

Dave Purola,
N8NTA

anj
- 18th May 2005, 22:26
Gday Dave
Thats sort of what i was thinking for option 2.
If i write my own control program, its easy enough.
However, it may end up standalone so i need the control string/mechanism to be simple as possible.
Maybe if i send a string like "wakeup" and look for "wakeup" on the usart, then an interrupt on b.0 will do the trick
But i would need to send "wakeup" twice. Not a real hassle i guess.
Andrew

suded
- 19th May 2005, 01:51
Hi anj.
You can use any of the signals for RS 233 like Tx.
You can connect trhat to your INT 0 line as well as the normal serial connection that you are using.
The micro is normally at sleep state,inorder to wake it up send any rubbish serial data this will wakeup the micro.
Then pause & send the actual code you need to communicate with.
Regards.
Suded.