![]() | ![]() | ![]() |
| | |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
| | LinkBack | Thread Tools | Display Modes |
| | (permalink) |
| I wrote and burned a program using sleep and wdt for a delay into a 16F84A, and it worked as expected. Simulated it a lot with MPLAB IDE v6.40. I am trying to write a program for the 12C508A that also uses sleep and wdt as a delay, but as I am trying to simulate it, it does't work as expected. When the wdt goes to zero, and it wakes the pic up from sleep, it does a full reset, instead of just moving on to the next instruction like how it worked on the 16F84A. am i overlooking something? This is what I am loading that into my option reg. 11001001 :quick reference to what each bit of the option reg means: bit 7: GPWU: Enable wake-up on pin change (GP0, GP1, GP3) 1 = Disabled 0 = Enabled bit 6: GPPU: Enable weak pull-ups (GP0, GP1, GP3) 1 = Disabled 0 = Enabled bit 5: T0CS: Timer0 clock source select bit 1 = Transition on T0CKI pin 0 = Transition on internal instruction cycle clock, Fosc/4 bit 4: T0SE: Timer0 source edge select bit 1 = Increment on high to low transition on the T0CKI pin 0 = Increment on low to high transition on the T0CKI pin bit 3: PSA: Prescaler assignment bit 1 = Prescaler assigned to the WDT 0 = Prescaler assigned to Timer0 bit 2-0: PS2:PS0: Prescaler rate select bits Thanks, Steve | |
| |
| | (permalink) | |
| Quote:
| ||
| |
| | (permalink) |
| so how would I go about resuming my program after using sleep on the 12c508a? Why does the 16f84A work differently? | |
| |
| | (permalink) | |
| Quote:
Presumably your program is going to sleep at a particular point, all you need to do is, from reset, check if it was caused by a WDT timeout during sleep, and jump to where you want the program to resume from. The datasheet also discusses which registers are changed or not for the various reset conditions. Certainly the 16F84A is simpler to use (for your application), but is probably less versatile.[/code] | ||
| |
| | (permalink) |
| yeah, the 16F84A was much easier to use. I have a program running, and when the wdt wakes it up from sleep, it just continues like normal. I did modify my program for the 12c508A to copy the PCL into a registry before going into sleep mode, and then after the reset on wakeup, i checked the 3 bits in that status to see if the wdt caused the wake up. if so, I added "2" to the PCL number I have saved, and then moved that to the PCL, and that took me right were I wanted to go. but.......I noticed that my config registry was being effected some how, and changed my prescaler to 1:128, when I originally had it set to 1:2. I noticed other things were being reset too, but I forget what they are now. I found it too much of a hassle, so I figured I would forget it. I was trying to use it to debounce the inputs for 36 ms. an added bonus was my circuit would use less power too. oh well, I just decided to use a subroutine that delays for 20ms. | |
| |