Temp = a
For i = 1 to 8
if Temp.0 on then gosub 1
if Temp.0 off then gosub 0
rotate Temp right
next
Temp is used because of the way that the Rotate command works in GCBASIC. There is no need to use dim to declare a byte variable - all byte variables used in GCBASIC commands are automatically recognized.
GCBASIC does not yet support else, so two ifs must be used. This is not entirely bad - the assembly code generated by the ifs in this program is much more efficient than the code produced by else would be.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
chip P16F628,20
#config HS_OSC, LVP_OFF, WDT_OFF
#define RecAHigh PORTB.2 ON
#define RecALow PORTB.2 OFF
InitSer (1, r9600, 1+WaitForStart, 8, 1, none, normal)
Main:
if Button pressed then Temp = 0
if Button released then Temp = 100
SerSend (1, Temp)
Wait 1 s
goto Main
Regards
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This is a bug that is in the update.zip file at the moment - I made a change to gcbasic.exe and rs232.h, but forgot to include the latest rs232.h. To make the program compile, add these lines to it:
Hello,
First off all, sorry for my english.
I'm going to try to write a little program but I have a problem.
Can you explain me how to extract bit after bit from a byte like this :
Dim i ' counter
Dim a(8) ' byte
For i = 1 to 8
if a(i) = 0 then
gosub 0
else
gosub 1
next i
Thank you for your help
Temp = a
For i = 1 to 8
if Temp.0 on then gosub 1
if Temp.0 off then gosub 0
rotate Temp right
next
Temp is used because of the way that the Rotate command works in GCBASIC. There is no need to use dim to declare a byte variable - all byte variables used in GCBASIC commands are automatically recognized.
GCBASIC does not yet support else, so two ifs must be used. This is not entirely bad - the assembly code generated by the ifs in this program is much more efficient than the code produced by else would be.
Ok thank you. I'm going to try to include this in my program and keep you informed if any problem.
Regards
Hello,
Can you give me explainations why I have errors :
CanGCBASIC error log for H:\GCBASIC\User\modele5.txt and included files.
GCBASIC version: 0.9 14/1/2007
rs232.h (251): Syntax Error
rs232.h (253): Syntax Error
rs232.h (256): Syntax Error
rs232.h (262): Syntax Error
rs232.h (264): Syntax Error
rs232.h (267): Syntax Error
when I try to compile this exemple
chip P16F628,20
#config HS_OSC, LVP_OFF, WDT_OFF
#define RecAHigh PORTB.2 ON
#define RecALow PORTB.2 OFF
InitSer (1, r9600, 1+WaitForStart, 8, 1, none, normal)
Main:
if Button pressed then Temp = 0
if Button released then Temp = 100
SerSend (1, Temp)
Wait 1 s
goto Main
Regards
This is a bug that is in the update.zip file at the moment - I made a change to gcbasic.exe and rs232.h, but forgot to include the latest rs232.h. To make the program compile, add these lines to it:
#define Ser_Links 1
#define SendAHigh nop
#define SendALow nop
Also, the chip directive needs a # in front of it. You'll need to replace
chip P16F628,20
with
#chip P16F628,20
#chip P16F628,20
#config HS_OSC, LVP_OFF, WDT_OFF
#define RecAHigh PORTB.2 ON
#define RecALow PORTB.2 OFF
'-------------------Modifs
#define Ser_Links 1
#define SendAHigh nop
#define SendALow nop
'-------------------Modifs
InitSer (1, r9600, 1+WaitForStart, 8, 1, none, normal)
Main:
if Button pressed then Temp = 0
if Button released then Temp = 100
SerSend (1, Temp)
Wait 1 s
goto Main
'Before modifs errors was :
'rs232.h (251): Syntax Error
'rs232.h (253): Syntax Error
'rs232.h (256): Syntax Error
'rs232.h (262): Syntax Error
'rs232.h (264): Syntax Error
'rs232.h (267): Syntax Error
'After mofifs errors are :
'GCBASIC error log for H:\GCBASIC\User\test-comm.txt and included files.
'GCBASIC version: 0.9 14/1/2007
'rs232.h (251): Syntax Error
'rs232.h (262): Syntax Error
Please download http://gcbasic.sourceforge.net/newfiles/update.zip - I have put the new rs232.h file into it, and the error is no longer appearing.