Shop OBEX P1 Docs P2 Docs Learn Events
wakeup initialization and PD — Parallax Forums

wakeup initialization and PD

TheRac25TheRac25 Posts: 5
edited 2007-11-20 20:32 in General Discussion
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?
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

  • BeanBean Posts: 8,129
    edited 2007-11-20 14:49
    Ben,
    · 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.



    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
      WKEN_B = %1111_1110
      WKPND_B = %0000_0000
      NOP
      NOP
      SLEEP
    


    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
  • TheRac25TheRac25 Posts: 5
    edited 2007-11-20 15:11
    ok i put an ELSE led = 0 in there and it works as expected
    ill integrate this into my main code

    thanks
    -ben
  • TheRac25TheRac25 Posts: 5
    edited 2007-11-20 18:48
    hrm ok so how do i make a pin an output without it going low->high on reset?
    do i need to set it to 0 before making latch output?
    i didnt realize thats what was happening
  • BeanBean Posts: 8,129
    edited 2007-11-20 19:12
    Ben,
    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

    ·
  • TheRac25TheRac25 Posts: 5
    edited 2007-11-20 19:19
    i am working on somthing specific this code is just a simplification so anyone looking doesnt have to look through all of my code

    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
  • BeanBean Posts: 8,129
    edited 2007-11-20 19:49
    So you don't want it to strobe at power-on, but you do want it to strobe at wake-up ?

    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

    ·
  • TheRac25TheRac25 Posts: 5
    edited 2007-11-20 20:32
    i do have a pull down it was OUTPUT keyword that was making the pin high
Sign In or Register to comment.