BasicMicro - Forums

www.basicmicro.com
It is currently Mon May 21, 2012 12:30 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: New to Nano, having issues
PostPosted: Mon Apr 19, 2010 9:32 am 
Offline
Guru

Joined: Mon Apr 19, 2010 9:13 am
Posts: 63
I started with a much larger byte, but have reduced the code to this little nibble. It is still not working correctly. in0 is tied to SW2. My guess is that on planet earth the counter variable would increase by 1 for each press of sw2. I may be missing something though. Is the "animate" function buggy? What about the debugging function in general? I have also had several hangs where I had to re-download the program just to get the the debugger reading again. I am using Studio 1.0.0.15 with a Nano 40 on a Nano Dev Board. Computer is Intel C2 6600 @ 2.4GHz, 3.37GB Ram, Win XP Pro SP3. I have replaced the batteries with brand new ones, with a total voltage over 6V.

Code:
cr      con   13                  ;carriage return
counter   var   byte               ;counter variable

counter = 0                     ;set counter to 0

Main
   if (in0 = 0) then Mode_State   ;check for button press
Goto Main

Mode_State
   counter = counter + 1         ;increase counter for each button press
debounce
   if (in0 = 0) then debounce      ;debounce button press
   pause 30
   debug [dec3 counter, cr]      ;display counter
return


Multiple button presses return...
Code:

2

3
1

2
1

_________________
Studio 2.0.0.16 on Win 7 Home x64 updated daily - Original Roboclaw 5A V1.3.9
Mostly a Nano40 for prototyping, but I have others in my bins


Top
 Profile  
 
 Post subject: Re: New to Nano, having issues
PostPosted: Mon Apr 19, 2010 11:17 am 
Offline
Guru

Joined: Mon Apr 19, 2010 9:13 am
Posts: 63
I updated Studio to 1.0.0.24 and was still having the same issues.

I think I might have figured it out though.

if (in0 = 0) then GOSUB Mode_State

that GOSUB makes a big difference. as in, returning the program to the line below the calling command instead of the top. I'm not sure why it ran so funny, but I was able to count well above 20 on this last iteration.

_________________
Studio 2.0.0.16 on Win 7 Home x64 updated daily - Original Roboclaw 5A V1.3.9
Mostly a Nano40 for prototyping, but I have others in my bins


Top
 Profile  
 
 Post subject: Re: New to Nano, having issues
PostPosted: Mon Apr 19, 2010 12:41 pm 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 11:00 am
Posts: 903
Location: Temecula, CA
If you don't use the gosub in the if then it does a goto instead.

if (in0 = 0) then mode_state ;if in0 equals 0 then goto mode_state

When you then tried to return from mode_state the return jumped to some random/garbage address causing you rprogram to crash/do weird things..

_________________
Tech Support
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

phpBB SEO