Searching \ for '[SX] SX/B Toggle behavior' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/ubicom/languages.htm?key=sx
Search entire site for: 'SX/B Toggle behavior'.

Exact match. Not showing close matches.
PICList Thread
'[SX] SX/B Toggle behavior'
2006\04\11@054531 by Dunnseptn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Dunnsept wrote:

I have a really simple program with a timer in the ISR that increments secs, mins, and hrs. This code is right from the examples for clocks.

Then what I tried to do is make an LED blink every second.

To accomplish this I am using result = secs // 2 if result = 0 then
  toggle rb.0 endif

The issue is that the LED behaves oddly. I did read in the SX/B help that toggle can have results other than what you expect. I tried that solution too but to no avail.

What the LED does is it goes from off to dim to bright to dim to off. then repeats:

off - dim - bright - dim - off - dim - bright - dim.

if I replace the above code with something like:

if result = 0 then
low rb.0
else
high rb.0
endif

it works as expected.  I tried the toggle.sxb example and it works fine. Is something in the getting in the way? or is there some stupid little issue I missed.

thanks!

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=120096
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)

2006\04\11@063136 by Jon Williamsn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Jon Williams wrote:

I'm not sure what's happening with your LED, but you can simplify the program like this:

Main:
 RB.0 = secs.0
 GOTO Main

TOGGLE and HIGH and LOW all set the pin to an output state -- you've already done that with LOW RB.0 in the Setup section so there's no need to repeat that when you can write the odd bit of seconds (secs.0) directly to the LED pin.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=120096#m120098
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)

2006\04\11@064057 by Dunnseptn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Dunnsept wrote:

Thanks Jon.
obviously it works.  worked too with the if then else but this is obviously more compact.
I took the original code, removed the ISR and just put in INC SECS and it works just fine with TOGGLE..
seems to be something goofy in my ISR. but heck if I can figure it out. I think I might start from scratch again, just to see if I can figure out why it doesn't work.
gonna drive me nuts all day if I can't find it
---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=120096#m120100
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)

2006\04\11@064953 by beann/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, bean wrote:

Dunnsept,
 The reason it is "dim" is because when secs = 0 the LED will be toggled EVERY time it loops. When secs changes to non-zero if the LED was off, it stays off. If the LED was on it stays on.

I would use:

Main:
result = secs // 2
RB.0 = result
GOTO Main
BTW: "RB.0 = ~RB.0" is much faster than "TOGGLE RB.0" if the pin is already setup as an output.

Bean.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=120096#m120102
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)

2006\04\11@065038 by Jon Williamsn/a
flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Jon Williams wrote:

What fun would programming be if it didn't drive us nuts once in a while? ;)
---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=120096#m120103
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)

2006\04\11@070525 by Dunnseptn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Dunnsept wrote:

exactly...   and a big DUH from me... now I get it.  I made the stupid assumption that my main loop is following along at the same pace..
turning out that the biggest obstacle so far is trying to not let PC/X86 programming cloud my thinking  (at least that's my excuse and I'm sticking with it)
thanks guys.. I think I'll go let C++ and win32 drive me nuts for a while now instead  ;-)
---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=120096#m120104
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)

More... (looser matching)
- Last day of these posts
- In 2006 , 2007 only
- Today
- New search...