Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

strange problem with loop for-next

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
luizabbadia

Bascom Member



Joined: 11 Dec 2007
Posts: 112
Location: rio de janeiro

brazil.gif
PostPosted: Sat Jan 31, 2015 2:47 pm    Post subject: strange problem with loop for-next Reply with quote

Hello all!

I was trying to run an old program to dump eeprom contents and found a strange result.
I was able to dump only the first line , and after some inspection I noticed that the loop for-next is not working , or I am not seeing the real problem.
Bellow I provide a code fragment and please note that I replaced eeprom instructions for dummy byte only for checking purposes. I can see that thereīs neither bufferout overflow nor Contagem2 loop performing..
When run in simulator you see only the first line printed...
Using last version 2.0.7.8

$regfile = "m1284pdef.dat"
$crystal = 18432000 ' 18.432 MHz
$baud = 38400
$baud1 = 38400
$hwstack = 350
$swstack = 350
$framesize = 350

Dim Strtime As String * 9
Dim Bufferout As String * 120
Dim Contagem1 As Word
Dim Contagem2 As Word
Dim D As Byte
Dim Mes As Byte

'---------- DUMP ------------------------

For Contagem2 = 0 To 32767 Step 16
Bufferout = ""
Strtime = "0000" + Hex(contagem2 )
Strtime = Right(strtime , 4)
Bufferout = Strtime + " "
For D = 0 To 15
Contagem1 = Contagem2 + D
'Readeeprom Mes , Contagem1
Mes = 49
Bufferout = Bufferout + Hex(mes) + " "
Next

Bufferout = Bufferout + "| "
For D = 0 To 15
Contagem1 = Contagem2 + D
'Readeeprom Mes , Contagem1
Mes = 49
If Mes < 32 Then
Mes = 32
End If
Bufferout = Bufferout + Chr(mes)
Next
Print Bufferout

Next


Thanx for your attention...

(BASCOM-AVR version : 2.0.7.8 )
Back to top
View user's profile MSN Messenger
luizabbadia

Bascom Member



Joined: 11 Dec 2007
Posts: 112
Location: rio de janeiro

brazil.gif
PostPosted: Sat Jan 31, 2015 2:52 pm    Post subject: Reply with quote

Ok....I found the problem....replaced WORD for INTEGER on those 2 variables Contagem2 and Contagem2


Thanx
Back to top
View user's profile MSN Messenger
luizabbadia

Bascom Member



Joined: 11 Dec 2007
Posts: 112
Location: rio de janeiro

brazil.gif
PostPosted: Sat Jan 31, 2015 4:14 pm    Post subject: Reply with quote

But anyway, itīs better to use " Do......loop until Contagem2<32768
Back to top
View user's profile MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum