Shop OBEX P1 Docs P2 Docs Learn Events
I think there is something wrong with my SX — Parallax Forums

I think there is something wrong with my SX

Armored CarsArmored Cars Posts: 172
edited 2005-03-16 16:36 in General Discussion
When I run this program


··device··sx18,OSCRC
··device··turbo,stackx,optionx
··IRC_CAL··IRC_SLOW
··reset··start_point
··freq ··50_000_000
··org 0
start_point··· mov·!rb,#0
· ··············· mov·!rc,#0
················· clr·rb
················· clr·rc
··················sleep

only leds on rc.2 through rb.7 and rb.3 to rb.1 turn on.
I know that all of rb and rc should be 0 and should light a led when connected to VDD (they are all in the right way) but I can't get them to do anything.

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-03-12 18:02
    Your declaration says SX18 but your refer to RC port (which doesn't exist on the SX18). Perhaps your code should be:

    · MOV · ·!RA, #0
    · MOV ·· !RB, #0
    · CLR·· ·RA
    · CLR··· RB

    Another point: the osc type (RC) doesn't match the speed you're requesting (50 MHz).· I think the upper end of RC is 4 MHz.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • Armored CarsArmored Cars Posts: 172
    edited 2005-03-12 18:36
    Now I am using the following program:

    device sx28,OSCRC
    device turbo,stackx,optionx
    IRC_CAL IRC_SLOW
    reset start_point
    freq 2_000_000

    org 0
    start_point mov !rb,#0
    clr rb
    sleep

    The only problem is when I load the program the LED is very dim. When the reset button is hit the program restarts and the LED stays on. Whenever I turn the power off and turn it back on the LED does not come on at all even when hitting the reset button. When I take the SX Key out of the board and plug it back in the LED turns on at its normal brightness, but when the reset button is hit it goes off.

    LED only comes on right after program is loaded or after SX key has been removed and replaced.

    LED is very dull right after program is loaded.

    Reset button only works right after the program was loaded.

    Chip does not retain program after turned off, or at least it doesn't run it.

    I have power from a 7.5v wall adaptor and the power led is always fully on (its not dim).
  • BeanBean Posts: 8,129
    edited 2005-03-13 13:48
    Are you using the SX Tech board ? If not do you have MCLR tied high ?
    Try "GOTO $" instead of "SLEEP"
    Try using a brownout option on the device line "BOR42" if using a +5V supply.
    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Check out· the "SX-Video Display Module"

    www.sxvm.com
    ·
  • Armored CarsArmored Cars Posts: 172
    edited 2005-03-13 18:26
    I am using the SX Tech board, and wandering what RTCC and MCLR was anyway, so no I don't have MCLR tied high.
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-03-13 19:31
    the MCLR is the reset pin, if your using the the tech board, this is already handled for you with the pullup resistor and the reset button. I was going to chime in earlier, but I couldn't really make sense of your program. Now that Ive disected your program I am a little suprised it worked at all. You load the port configuration register with 0, but you dont specify what the mode of the configuration register is. You may have been relying upon this phrase in the SX User's manual:

    "Upon reset, the MODE register is initialized to 0Fh for the SX18/20/28AC and SX18/20/28AC75 or to 1Fh for the SX48/52BD. This makes the port direction registers write-accessible to the "MOV !rx,W" instructions."

    But I would not rely upon this behavior, explictly declare it: mov m,#$0F before the mov !rb, #0. Also try bean's suggestion (the assembly equivalent is "jmp $"), sleep causes the SX to go into powerdown mode, it probably shouldn't effect the behavior of the I/O pin's state, but test it to make sure. Also if the watchdog timer is enabled it could effect the behavior of your program, though theoretically it shouldn't. Lastly what is the value for the current limiting resistor your using? measure the voltage at the port pin, across the resistor, across the LED and the current flowing through the two, and report back your findings.



    <EDIT> On further inspection of the users manual the mode is always intialized to $0F, the leads me to believe the core of your program is correct, that it is something to do with your external circuit, Is your diode in the correct polarity? Follow Gunther's first program example starting on page 17 of this document http://www.parallax.com/dl/docs/books/ProgSXExcerpt.pdf·and see if it works. </EDIT>

    Post Edited (Paul Baker) : 3/13/2005 7:45:52 PM GMT
  • Armored CarsArmored Cars Posts: 172
    edited 2005-03-13 20:59
    I messed around with it some more today and I found the problem with my program. I am going through the Exploring the SX Microcontroller with Assembely and BASIC Programming and it uses sleep to end a similar program, the only problem is when in sleep mode the pins must go off or something because with the sleep command removed and "guess jmp guess" put in its place the LED turns on.

    The only thing that worries me is when the power is turned off or the SX key is removed the chip looses its program. I can't figure out why this is happening.
  • KenMKenM Posts: 657
    edited 2005-03-13 21:55
    How are you programming the SX?

    My understanding is if you use RUN > RUN, it runs only from the SX Key.

    To program the device to run stand alone, use RUN > PROGRAM

    k
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-03-13 22:05
    I doubt that the program is "lost", it is most likely due to something else. When you remove the SX key, do you remember to replace the resonator? Also I believe if you still have the SX-Key connected and power cycle, the program in the SX will not run. The SX-Key takes its power from your tech board and it is powered down as well, so when the power is reapplied, the SX-Key starts up and places itself in a state where its waiting for instructions from your computer on what to do, ie its not driving the oscillator for your SX.
  • Armored CarsArmored Cars Posts: 172
    edited 2005-03-14 18:35
    I figured it out, you both were right. I changed the resonator settings and used RUN>PROGRAM and it works now. Thanks for the help.
  • Guenther DaubachGuenther Daubach Posts: 1,321
    edited 2005-03-16 16:20
    Hi all,

    no matter in which mode you run an SX program - it is always executed in the chip (this is also true for the "Run- Run" mode). IOW, first, the program must be transferred into the SX-internal EEPROM. "Run-Run" means that the SX-Key supplies the clock for the SX.

    After having tested a program on the SX with the debugger, it is important to "Run - Program" it before disconnecting the SX-Key and connecting the Resonator/Xtal, RC-Network, or using the SX-internal RC clock generator. It will not run "stand alone", when the debug version is still in the EEPROM as this contains additional code to communicate between the SX and the SX-Key.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Greetings from Germany,

    G
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-03-16 16:36
    I have never used Run-Run, but that is definitely some useful advice, thanks G
Sign In or Register to comment.