wakeup initialization and PD
ok so im trying to figure out how to run some code at powerup but not every time a wakeup happens
ive been trying to figure this out for a week
this should work but led just flickers and stays on a wakeup, its like im getting two wakeups in a row with the second one having PD = 1
if i set another led to = PD then it stays off so why does the code in the if statement execute?
can anyone tell whats wrong here?
RB.0 is connected to channel A of an optical encoder with 10K pullup
chip is SX28AC/DP marked ubicom
-Ben
ive been trying to figure this out for a week
this should work but led just flickers and stays on a wakeup, its like im getting two wakeups in a row with the second one having PD = 1
if i set another led to = PD then it stays off so why does the code in the if statement execute?
can anyone tell whats wrong here?
DEVICE SX28, OSCHS2, TURBO, STACKX, OPTIONX FREQ 50_000_000 led PIN RA.3 OUTPUT PROGRAM Start NOSTARTUP Start: IF PD = 1 THEN led = 1 ENDIF WKED_B = %1111_1111 WKPND_B = %0000_0000 WKEN_B = %1111_1110 SLEEP
RB.0 is connected to channel A of an optical encoder with 10K pullup
chip is SX28AC/DP marked ubicom
-Ben
Comments
· Set WKPND_B after you set WKEN_B (note that you need something between the WKPND_B and SLEEP, a NOP will do).
· Also, if you are running from the IDE, it does strange things with the PD and TO bit. I can't remember right off hand, I think it never sets PD.
··I don't know if you realize that all pins are set to INPUT at wake-up. Because you have the LED defined as an OUTPUT, SX/B will make it an output again in the start-up code.
You might be getting bounce in the signal too, that would cause multiple start-ups.
What do you expect it to do ? The LED will always be on, even on a wake-up.
Bean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.iElectronicDesigns.com
Post Edited (Bean (Hitt Consulting)) : 11/20/2007 3:08:01 PM GMT
ill integrate this into my main code
thanks
-ben
do i need to set it to 0 before making latch output?
i didnt realize thats what was happening
Yeah just use "LED = 0" before the "IF PD = 1" line.
The pin doesn't actually go LOW during the wake-up. It goes to INPUT state (which of course make the LED go off).
It is the SX/B startup code that is making the pin an OUTPUT (since you have it defined that way).
Are you just experimenting or do you have a specific goal in mind ?
Bean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.iElectronicDesigns.com
·
basicly this is strobing my lcd enable line every wakeup/reset, repeating the last char command since i have the lcd data linse latched on an i2c expander
my solution as of now is remove OUTPUT keywork and insert two lines at the top of Start
\· mov ra,#0
\· mov !ra,#0
doesnt apear to be strobing now
thanks for your input on this
Can you just put a pull-down or pull-up on the pin? That will hold it in the desired state during the reset (when it is in INPUT mode).
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.iElectronicDesigns.com
·