Shop OBEX P1 Docs P2 Docs Learn Events
SX Programming and interface questions — Parallax Forums

SX Programming and interface questions

T'SaavikT'Saavik Posts: 60
edited 2007-02-16 19:13 in General Discussion
Hey all! Not only am i a noob to the SX series, i'm a noob to micro controllers in general! be warned!

A good friend gave me a sx programmer and a bunch of sx28 chips on little cards. I have alot of info about it here:
www.hellspark.com/dm/ebench/sx/howto.html

The pinout is as follows:
sxpinout-dave.jpg

I hooked the positive terminals of a 11-led "bar graph" display to the entire right side (all of RC and RB5-7). I connected their negative terminals all together to a single resistor then to ground.To make sure it worked i hacked up the "pause.sxb" example program and made a little "cylon" style flasher, it worked perfectly!

I figured since i can't use the debugger these leds would be handy for trying to diag problems in the future. I could re-use this chip for different projects and have the 11 leds for handy diags (or just fancy heartbeats atleast, lol).

I then marched merrily forward with my first REAL project, a little explorer robot. I am getting some weirdness! Every time i power up the chip different LEDs light. Even 2 that should NEVER light (rc.7 and rc.6)!. i don't have ANYTHING plugged into the chip other then the bar graph diag and power. The motor controller and ir emitter/detector are not connected. i DO have a 9v battery driven 5v regulated power supply with .1uf ceramic, 10uf tantalum as close to the chip's power as i can.

I'll attach the code here, i would appreciate ANY constructive comments, PLEASE don't flame me too hard, I'm a noob and need nurturing. I know the code is VERY lame, i should use functions, i should use more constants, but I'm trying to get it working before i make it pretty, don't worry, i WILL make it prettier it was hard to resist.

Post Edited By Moderator (Chris Savage (Parallax)) : 2/15/2007 11:09:47 PM GMT

Comments

  • Sparks-R-FunSparks-R-Fun Posts: 388
    edited 2007-02-15 20:37
    tsaavik,

    The problem with the LEDs on RC.6 and RC.7 is likely a result of applying the pull-up resistors to these pins. These resistors connect internally to the positive supply to try to weakly “pull up” the pin to +5V. Connecting LEDs to these pins exposes them to +5V as well. Apparently this is enough to cause them to light.

    I did not look further for other problems.

    - Sparks
  • T'SaavikT'Saavik Posts: 60
    edited 2007-02-15 21:20
    Doh!! Thank you Sparks. Whats the best way of leaving those unused (but connected to leds) pins? Mark them as outputs and just not use them? Or should i set them to 0 for safety? I remember reading about some golden rule of always making unused IO pins inputs that are pulled up by resistors, but i guess my definition of unused needed refinement. Note to self, led present but ignored != unused [noparse]:D[/noparse]
  • Sparks-R-FunSparks-R-Fun Posts: 388
    edited 2007-02-16 01:51
    tsaavik,

    It is generally a good idea to tie unused inputs to one state or the other. This is most important with a device that is likely to alter its output based upon a possible state change of its “unused” and otherwise unconnected inputs. You really have to watch for this when using discrete logic. With the SX, you can get away with having unconnected inputs as long as your code never bases any decisions upon the state of those inputs.

    Pull-up resistors are often used for pins that are connected to switches since the open state of the switch leaves the pin otherwise unconnected. You can not be sure that you can predict the state of an unconnected input pin. So if it is possible that a pin can affect the state of your circuit, make sure it is always connected to something and not left floating in an unconnected and therefore unknown state!

    In your case, I would recommend leaving the unused pins as inputs but not enabling the pull-up resistors. The pins should see a logic low signal through the LED and the LED resistor to ground. Again, with the SX you can even leave the unused pins completely unconnected as long as your program never looks to see if they are in a high or low state.

    - Sparks
  • T'SaavikT'Saavik Posts: 60
    edited 2007-02-16 19:13
    Thanks, the SX is operating sanely now. Not how i want, but its doing what i told it to so my fault [noparse]:D[/noparse]
Sign In or Register to comment.