Playing around with GCBasic and while translating the HELP file and checking some sample programs I encountered the following problems and difficulties:
Variabel pnx cant be used as port number designation
Please read the comment-lines in the program
#chip 16F877, 4
DIR portb OUT
dir porta.0 in
dir porta.3 in
tim1=100
pnx=0
Main:
if porta.0 = 0 then tim1= 255
if porta.3 = 0 then
pnx = pnx + 1
pulseout portb.pnx,100 msec 'doesnt work, portb2 blinks then cont
wait 250 ms ' pnx as pin no not accepted
if pnx > 7 then pnx = 0
end if
goto main ' lines 12 to 17 dont work
locate 1,1:print "11111111111111111111" '20 char--After reset it starts correctly
'at column 1, after wait xxx it jumps to
'row 2 with an offset of 1 digit, digit 20
'is posItioned in row 4 at position 1
locate 2,1:print "22222222222222222222" 'after reset it starts in row 3 instaed
'row 1, digit 20 is positioned in row 2
'column 1
wait 2 s '1cls and even some 10 ms delay are ok
goto main
Next:
'HOW TO SET WITH ONE STROKE ALL PORT PINS TO HI OR LO ???
Here is what I tried:
Plse read the comment lines in the program
'PIC Konfiguration
#chip 16F877, 4
'Bestimme PIN Richtung
#define prtB portb.0 ' OK
'dir PRTB out ' portb.0=out or =1 doesnt work
'dir portb.5 out
dir portb b11111111 ' all of portb direction is OUT
do
'PRTB = 1 ' 1 or 0 instead of ON or OFF is ok too
Wait 250 ms
'PRTB = 0
'portb.5 = 1 ' without set is ok but use '=' [portb.0=0]
'Wait 250 ms
'portb.5 = 0
' WORKS UP TO LINE 16
' CHECK THESE ALSO PLS:
set portb = b'11111111 ' 'PORTB = on OR portb = b11111111 dont work only
'portb.4 flashes pothers are dark
'portb = b'00000000' only portb.2 and 5-7 flash
wait 250 ms
set portb = b'00000000' 'all of portb ON
'HOW TO SET WITH ONE STROKE ALL PORT PIN HI OR LO ???
loop
END
I humbly admit that I have made some errors probably. If not can I expect that there will be in the near future some improvements. Regarding the LCD problems I downloaded the update file.
It's possible to address the LCD registers with hex values to make the following settings:
Print $FE, 1 erase display
Print $FE, 2 begin of line 1
Print $FE, $0C Cursor Off
Print $FE, $0E Cursor as Line
Print $FE, $0F Flashing Cursor On
Print $FE, $10 Move cursor to left
Print $FE, $14 Move cursor to right
Print $FE, $C0 Move cursor to begin of row 2
Print $FE, $94 Move cursor to begin of row 3
Print $FE, $D4 Move cursor to begin of row 4
Print $FE, 128 Cursor Home
Command with $ as hex symbol is not accepted by GCBasic. LCDhex : LCDhex produce character mismatch on the display. Using the above instructions are very convenient. How to realize this?
Thanks a lot for your efforts and help
Peter
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
For setting a Port all on, or off:
As you have found out setting the port to a binary, hex, decimal, or variable value works. It would be nice to be able to Set PortB On, or Off without getting the syntax error.
For hex commands in GCBasic:
Print 0xFE
Hope that at least gets some of your problems fixed.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Playing around with GCBasic and while translating the HELP file and checking some sample programs I encountered the following problems and difficulties:
Variabel pnx cant be used as port number designation
Please read the comment-lines in the program
#chip 16F877, 4
DIR portb OUT
dir porta.0 in
dir porta.3 in
tim1=100
pnx=0
Main:
if porta.0 = 0 then tim1= 255
if porta.3 = 0 then
pnx = pnx + 1
pulseout portb.pnx,100 msec 'doesnt work, portb2 blinks then cont
wait 250 ms ' pnx as pin no not accepted
if pnx > 7 then pnx = 0
end if
goto main ' lines 12 to 17 dont work
PULSEOUT portb.0, tim1 msec ' lines 19 to 30 are ok
PULSEOUT portb.1, tim1 msec
PULSEOUT portb.2, tim1 msec
PULSEOUT portb.3, tim1 msec
PULSEOUT portb.4, tim1 msec
PULSEOUT portb.5, tim1 msec
PULSEOUT portb.6, tim1 msec
PULSEOUT portb.7, tim1 msec
Wait 1 sec
goto Main
NEXT:
Locate and Print commands dont work properly. See comment-lines in the program
'LCD Test
#chip 16F877,4
main:
cls
cls 'LCD connection settings
#define LCD_IO 4 'using an ORION 4 lines 20 char Hitachi
#define LCD_DB4 PORTD.4 ‘44780 compatible LCD
#define LCD_DB5 PORTD.5
#define LCD_DB6 PORTD.6
#define LCD_DB7 PORTD.7
#define LCD_RS PORTD.3
#define LCD_Enable PORTD.2
#define lcd_no_rw '#define LCD_RW PORTD.1 disabled
locate 1,1:print "11111111111111111111" '20 char--After reset it starts correctly
'at column 1, after wait xxx it jumps to
'row 2 with an offset of 1 digit, digit 20
'is posItioned in row 4 at position 1
locate 2,1:print "22222222222222222222" 'after reset it starts in row 3 instaed
'row 1, digit 20 is positioned in row 2
'column 1
locate 3,1:print "33333333333333333333" 'starts in row 4, column 2, digit 20 row
'1, column 1
locate 4,1:print "44444444444444444444" '4 in row 3 resp row 2, 2 disappeared
wait 2 s '1cls and even some 10 ms delay are ok
goto main
Next:
'HOW TO SET WITH ONE STROKE ALL PORT PINS TO HI OR LO ???
Here is what I tried:
Plse read the comment lines in the program
'PIC Konfiguration
#chip 16F877, 4
'Bestimme PIN Richtung
#define prtB portb.0 ' OK
'dir PRTB out ' portb.0=out or =1 doesnt work
'dir portb.5 out
dir portb b11111111 ' all of portb direction is OUT
do
'PRTB = 1 ' 1 or 0 instead of ON or OFF is ok too
Wait 250 ms
'PRTB = 0
'portb.5 = 1 ' without set is ok but use '=' [portb.0=0]
'Wait 250 ms
'portb.5 = 0
' WORKS UP TO LINE 16
' CHECK THESE ALSO PLS:
set portb = b'11111111 ' 'PORTB = on OR portb = b11111111 dont work only
'portb.4 flashes pothers are dark
'portb = b'00000000' only portb.2 and 5-7 flash
wait 250 ms
set portb = b'00000000' 'all of portb ON
'HOW TO SET WITH ONE STROKE ALL PORT PIN HI OR LO ???
loop
END
I humbly admit that I have made some errors probably. If not can I expect that there will be in the near future some improvements. Regarding the LCD problems I downloaded the update file.
It's possible to address the LCD registers with hex values to make the following settings:
Print $FE, 1 erase display
Print $FE, 2 begin of line 1
Print $FE, $0C Cursor Off
Print $FE, $0E Cursor as Line
Print $FE, $0F Flashing Cursor On
Print $FE, $10 Move cursor to left
Print $FE, $14 Move cursor to right
Print $FE, $C0 Move cursor to begin of row 2
Print $FE, $94 Move cursor to begin of row 3
Print $FE, $D4 Move cursor to begin of row 4
Print $FE, 128 Cursor Home
Command with $ as hex symbol is not accepted by GCBasic. LCDhex : LCDhex produce character mismatch on the display. Using the above instructions are very convenient. How to realize this?
Thanks a lot for your efforts and help
Peter
For PortB.pnx, try an array like:
dim LedB(8), then
...
...
Led(1) = b'00000010'
Led(2) = b'00000100'
etc.
...
...
pnx = pnx + 1
PortB = Led(pnx)
wait 100 ms
PortB = 0
...
Perhaps a minor error here:
locate 2,1:print "22222222222222222222"
try?
locate 2,1 :print "22222222222222222222"
Or?
locate 2,1
print "22222222222222222222"
For setting a Port all on, or off:
As you have found out setting the port to a binary, hex, decimal, or variable value works. It would be nice to be able to Set PortB On, or Off without getting the syntax error.
For hex commands in GCBasic:
Print 0xFE
Hope that at least gets some of your problems fixed.