Discussion forum for the BasicX family of microcontroller chips.
For next loop hangs - "wimn.rm" - Sep 24 2:56:08 2008
Can someone help telling me why my for-next loop hangs?
See the following:
sub WOL()
dim i as Byte
dim dataBuffer(1 to 110) as Byte
'Make MagicPacket
call beep()
for i = 1 to 6
dataBuffer(i) = &HFF
next
call beep()
end sub
Sub beep() 'Make a sound of 0.5 sec.
Call putpin(Beeper,bxOutputHigh)
call sleep(0.5)
Call putpin(Beeper,bxOutputLow)
call sleep(0.5)
end sub
It never comes to the second call beep()
------------------------------------
______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.
(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: For next loop hangs - "wimn.rm" - Sep 24 4:36:53 2008
I have to add something.
Maybe my way of programming is not right.
The main program uses a do loop in which is is testing an I/O pin is
changing state.
This is a very fast "tight" loop.
I noticed when I insert a debug.print "Start loop" just before
the loop it will print just the S.
It should print Start loop.
Can a do loop freeze the BX24?
Wim
------------------------------------
______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.
(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: For next loop hangs - "wimn.rm" - Sep 24 5:07:41 2008
Found the following "strange" thing.
The following works fine.
sub WOL()
dim i as byte
dim dataBuffer(1 to 57) as Byte
'Make MagicPacket
call beep()
debug.print "Het Magic Packet"
for i = 1 to 6
databuffer(i) = &HFF
next
call beep()
debug.print "FF gevuld."
end sub
But when I increase the size of the databuffer by 1 the problem is
there!
dim dataBuffer(1 to 58) as byte
Also the debug.print "Het Magic Packet" becomes corrupted.
It than shows: Hft Nagjc Qaclet
Who has an idea?
------------------------------------

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: For next loop hangs - "wimn.rm" - Sep 24 6:07:08 2008
Looks like I'm the only one responding to my own topic.
In the mean time I found that it is a problem of RAM shortage.
Reducing the size of other DIM's also solves the problem.
But I'm afraid running into trouble with my project.
I realy need to have a databuffer and a serial port buffer
of 6 + 16 * 6 = 102 bytes each in order to send a "MagicPacket" for my
WOL (Wake-On-Lan) subroutine.
Has someone a better idea for setting up this string which has to go to
my SitePlayer in order to prepare the WOL UDP packet?
Maybe I can place the string ready prepared into the siteplayer.
Wim
------------------------------------
______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.
(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: For next loop hangs - rosa...@aol.com - Sep 24 11:41:02 2008
Hi,
I checked your for loop and? it is okay. Try debug.print "loop =";cstr(i) inside the
loop.This is to check if you stayed in the loop. Should print 6 times. Also where did you
define the pin beeper. You can use the command call putpin(pin number, 1=high 0=low)
rosarite
-----Original Message-----
From: wimn.rm
To: b...@yahoogroups.com
Sent: Wed, 24 Sep 2008 1:55 am
Subject: [BasicX] For next loop hangs
Can someone help telling me why my for-next loop hangs?
See the following:
sub WOL()
dim i as Byte
dim dataBuffer(1 to 110) as Byte
'Make MagicPacket
call beep()
for i = 1 to 6
dataBuffer(i) = &HFF
next
call beep()
end sub
Sub beep() 'Make a sound of 0.5 sec.
Call putpin(Beeper,bxOutputHigh)
call sleep(0.5)
Call putpin(Beeper,bxOutputLow)
call sleep(0.5)
end sub
It never comes to the second call beep()
[Non-text portions of this message have been removed]
------------------------------------

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )Re: For next loop hangs - Clark Thomasson - Sep 24 12:47:25 2008
In the module called Make MagicPacket you are using the variable
i to incriment thru the loop, but in the very next line you are
assigning the value held in HFF to the same variable.
In the first passing of the loop i would contain the value of 1.
In the next line i recieves the value held in HFF. then in the
next line i is incrimented again. The only way your loop could
ever terminate would be in HFF were to equal 6. If you use a
different vaiable in the Databuffer argument, your problem
should magically (pun intended) go away.
Try this instead
sub WOL()
dim i as Byte
dim j as Byte
dim dataBuffer(1 to 110) as Byte
'Make MagicPacket
call beep()
for i = 1 to 6
dataBuffer(j) = &HFF
next
call beep()
end sub
Clark
---- On Wed, 24 Sep 2008, wimn.rm (w...@rocketmail.com) wrote:
Can someone help telling me why my for-next loop hangs?
See the following:
sub WOL()
dim i as Byte
dim dataBuffer(1 to 110) as Byte
'Make MagicPacket
call beep()
for i = 1 to 6
dataBuffer(i) = &HFF
next
call beep()
end sub
Sub beep() 'Make a sound of 0.5 sec.
Call putpin(Beeper,bxOutputHigh)
call sleep(0.5)
Call putpin(Beeper,bxOutputLow)
call sleep(0.5)
end sub
It never comes to the second call beep()
------------------------------------
______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.
(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: For next loop hangs - rosa...@aol.com - Sep 24 13:44:37 2008
Hi,
I think he is right. He is using the i as a index for the buffer. His buffer is 1? to 110.
So he is addressing the first 6 variable of the buffer and loading them with &ffH
rosarite
-----Original Message-----
From: Clark Thomasson
To: wimn.rm
Sent: Wed, 24 Sep 2008 8:12 am
Subject: Re: [BasicX] For next loop hangs
In the module called Make MagicPacket you are using the variable
i to incriment thru the loop, but in the very next line you are
assigning the value held in HFF to the same variable.
In the first passing of the loop i would contain the value of 1.
In the next line i recieves the value held in HFF. then in the
next line i is incrimented again. The only way your loop could
ever terminate would be in HFF were to equal 6. If you use a
different vaiable in the Databuffer argument, your problem
should magically (pun intended) go away.
Try this instead
sub WOL()
dim i as Byte
dim j as Byte
dim dataBuffer(1 to 110) as Byte
'Make MagicPacket
call beep()
for i = 1 to 6
dataBuffer(j) = &HFF
next
call beep()
end sub
Clark
---- On Wed, 24 Sep 2008, wimn.rm (w...@rocketmail.com) wrote:
Can someone help telling me why my for-next loop hangs?
See the following:
sub WOL()
dim i as Byte
dim dataBuffer(1 to 110) as Byte
'Make MagicPacket
call beep()
for i = 1 to 6
dataBuffer(i) = &HFF
next
call beep()
end sub
Sub beep() 'Make a sound of 0.5 sec.
Call putpin(Beeper,bxOutputHigh)
call sleep(0.5)
Call putpin(Beeper,bxOutputLow)
call sleep(0.5)
end sub
It never comes to the second call beep()
[Non-text portions of this message have been removed]
------------------------------------

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )Re: For next loop hangs - rosa...@aol.com - Sep 24 13:50:01 2008
Hi,
I modified your program like this and it's worked. You would see the red? light in the cpu
blinking.
rosarite
Option Explicit
public t as byte
???? Public? Sub? Main()
dim i as Byte
dim dataBuffer(1 to 110) as Byte
start:
t=0
Do
??? call beep()
??? ??? for i = 1 to 6
??? ??? ??? debug.print "loop";cstr(i)
??? ??? ??? dataBuffer(i) = &HFF
??? ??? next
??? call beep()
???? t = t + 1
Loop Until (t > 6)
delay( 2.0
goto start
End Sub
?Sub beep() 'Make a sound of 0.5 sec.
dim Beeper as byte
beeper=25
Call putpin(Beeper,bxOutputHigh)
call sleep(0.5)
Call putpin(Beeper,bxOutputLow)
call sleep(0.5)
?end sub
-----Original Message-----
From: r...@aol.com
To: b...@yahoogroups.com
Sent: Wed, 24 Sep 2008 10:40 am
Subject: Re: [BasicX] For next loop hangs
Hi,
I checked your for loop and? it is okay. Try debug.print "loop =";cstr(i) inside the
loop.This is to check if you stayed in the loop. Should print 6 times. Also where did you
define the pin beeper. You can use the command call putpin(pin number, 1=high 0=low)
rosarite
-----Original Message-----
From: wimn.rm
To: b...@yahoogroups.com
Sent: Wed, 24 Sep 2008 1:55 am
Subject: [BasicX] For next loop hangs
Can someone help telling me why my for-next loop hangs?
See the following:
sub WOL()
dim i as Byte
dim dataBuffer(1 to 110) as Byte
'Make MagicPacket
call beep()
for i = 1 to 6
dataBuffer(i) = &HFF
next
call beep()
end sub
Sub beep() 'Make a sound of 0.5 sec.
Call putpin(Beeper,bxOutputHigh)
call sleep(0.5)
Call putpin(Beeper,bxOutputLow)
call sleep(0.5)
end sub
It never comes to the second call beep()
[Non-text portions of this message have been removed]
[Non-text portions of this message have been removed]
------------------------------------

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )Re: Re: For next loop hangs - Clark Thomasson - Sep 24 15:28:01 2008
Good job. It is an easy mistake to make. I am sure you would
have caught it.
AS a rule if thumb I always save variables i for loops and never
use them for anything else.
Nested loops would be
for i = 1 to 10
for ii = 1 to 20
for iii = 1 to 10
next iii
next ii
next i
NOt sure if this context works with your language, but you get
the idea.
Just a lesson I learned from making the same exact mistake a few
times many years ago. :)
Clark
---- On Wed, 24 Sep 2008, r...@aol.com (r...@aol.com)
wrote:
Hi,
I modified your program like this and it's worked. You would see
the red? light in the cpu blinking.
rosarite
Option Explicit
public t as byte
???? Public? Sub? Main()
dim i as Byte
dim dataBuffer(1 to 110) as Byte
start:
t=0
Do
??? call beep()
??? ??? for i = 1 to 6
??? ??? ??? debug.print "loop";cstr(i)
??? ??? ??? dataBuffer(i) = &HFF
??? ??? next
??? call beep()
???? t = t + 1
Loop Until (t > 6)
delay( 2.0
goto start
End Sub
?Sub beep() 'Make a sound of 0.5 sec.
dim Beeper as byte
beeper=25
Call putpin(Beeper,bxOutputHigh)
call sleep(0.5)
Call putpin(Beeper,bxOutputLow)
call sleep(0.5)
?end sub
-----Original Message-----
From: r...@aol.com
To: b...@yahoogroups.com
Sent: Wed, 24 Sep 2008 10:40 am
Subject: Re: [BasicX] For next loop hangs
Hi,
I checked your for loop and? it is okay. Try debug.print "loop
=";cstr(i) inside the loop.This is to
check if you stayed in the loop. Should print 6 times. Also
where did you define the pin beeper. You
can use the command call putpin(pin number, 1=high 0=low)
rosarite
-----Original Message-----
From: wimn.rm
To: b...@yahoogroups.com
Sent: Wed, 24 Sep 2008 1:55 am
Subject: [BasicX] For next loop hangs
Can someone help telling me why my for-next loop hangs?
See the following:
sub WOL()
dim i as Byte
dim dataBuffer(1 to 110) as Byte
'Make MagicPacket
call beep()
for i = 1 to 6
dataBuffer(i) = &HFF
next
call beep()
end sub
Sub beep() 'Make a sound of 0.5 sec.
Call putpin(Beeper,bxOutputHigh)
call sleep(0.5)
Call putpin(Beeper,bxOutputLow)
call sleep(0.5)
end sub
It never comes to the second call beep()
[Non-text portions of this message have been removed]
[Non-text portions of this message have been removed]
------------------------------------
______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.
(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: For next loop hangs - Wim Nijntjes - Sep 25 2:36:01 2008
All has been solved!=A0=A0 It was RAM overflow.
With the program RAMALYZE of Don I found that my RAM usage was more than 40=
0 bytes.
So I solved it by taking out the large buffer holding the MagicPacket and m=
oved this to the SitePlayer.
Thanks all!!!!=20
--- On Wed, 9/24/08, r...@aol.com
wrote:
From: r...@aol.com
Subject: Re: [BasicX] For next loop hangs
To: b...@yahoogroups.com
Date: Wednesday, September 24, 2008, 5:40 PM
Hi,
I checked your for loop and? it is okay. Try debug.print "loop =3D";cstr(i)=
inside the loop.This is to check if you stayed in the loop. Should print 6=
times. Also where did you define the pin beeper. You can use the command c=
all putpin(pin number, 1=3Dhigh 0=3Dlow)
rosarite
-----Original Message-----
From: wimn.rm
To: basicx@yahoogroups. com
Sent: Wed, 24 Sep 2008 1:55 am
Subject: [BasicX] For next loop hangs
Can someone help telling me why my for-next loop hangs?
See the following:
sub WOL()
dim i as Byte
dim dataBuffer(1 to 110) as Byte
'Make MagicPacket
call beep()
for i =3D 1 to 6
dataBuffer(i) =3D &HFF
next
call beep()
end sub
Sub beep() 'Make a sound of 0.5 sec.
Call putpin(Beeper, bxOutputHigh)
call sleep(0.5)
Call putpin(Beeper, bxOutputLow)
call sleep(0.5)
end sub
It never comes to the second call beep()
[Non-text portions of this message have been removed]
=20
=20=20=20=20=20=20
[Non-text portions of this message have been removed]
------------------------------------
______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )