12F675 problem with OSCCAL and SLEEP

Status
Not open for further replies.

itchy_frog

New Member
Hi Folks,
I hope someone can help with this. I'm running code on a 12F675 that uses the SLEEP command, then the device is woken from sleep by a reset on the MCLR pin. When I use the standard code to get the OSCCAL value (CALL 0x3FF), the program runs fine but on wake from sleep, the device runs for a second or so then dies/sleeps. If I read the OSCCAL value and hard-write it into the program, the whole thing runs as it should and wakes properly from SLEEP. I'm programming with the K8048 using PicProg2009, which I think might be part of the problem - certainly there is only one shot at programming then it deletes the OSCCAL value (however I now know to always record it first).

I'd also welcome advice on a more robust, cost effective programmer.
Kind regards,
Andrew
 
I suspect you are leaving the RAM in a state that causes a crash after the sleep. Can you add a Clear_RAM routine to the initilisation code to see if that fixes it.

Mike.
 
Last edited:
Problem solved

Thanks for the input folks - problem now solved. The SLEEP command was in a routine at the bottom of the code. On wake-up the code was sent to the RESET section, missing the START code where the OSCCAL value is retrieved and put into RAM. It simply needed a GOTO following SLEEP to send the program back to START, now it functions perfectly. No more reading the chip first, hard-writing the OSCCAL into the program code and individually programming each chip!
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…