Fortunately, I was able to spare the Port C pins on my project for the LCD so all was fine and happy for me. Perhaps, if you need to use the pin assignment you have above, then this is something Hugh could work into the next version of GCBasic?
Hope this helps,
Grant
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have been trying to get a LCD to work for a couple of days, having checked all the wiring etc but think I may be missing something basic. The pin connections are:
That would be very nice. I'm using 9.3.0 with no problem. I wanted to use PORTB for all the pins but since I have an ICSP circuit attached I don't want to deal with all the interfacing issues (isolation circuitry etc). And i'm reserving the other PORTC pins for RS232 which I plan on adding soon. So for now i'll stick with 9.3.0. Thanks for the help!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It's most likely some alteration I made to the string handling recently. However, I have no trouble compiling it with the newest version of GCBASIC - I've just updated http://gcbasic.sourceforge.net/newfiles/update.zip
I've no idea why there would be any trouble using pins on different ports with the LCD routines. Certainly in the past I've used a mix of PORTC and PORTD pins without any sign of trouble. Still, I'll try some different combinations when I get time and see if any strange problems occur.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I just tried the update and i'm still having problems with the PRINT command. I tried compiling with different chips and the same problem still occurs. I don't think there is a problem using different pins, as it works with 9.3.0.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I've double checked the update.zip file, and the lcd.h in it was a few days older than the one I'm using. update.zip now has exactly the same system.h, lcd.h and gcbasic.exe that I'm using, which hopefully will work.
If it still doesn't work, could you please post the entire asm file?
Also, the newest source code (gcbasic.bas) is now in update.zip.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Not so obvious, taking into account that most example code (and some header/library's) out there assumes that the port pins are set to digital output. As just mentioned in the 'blink led 16f84a post', GCBasic is not initializing the I/O pins for the 16f84, 16f84a as digital output. On POR, Pic devices default to analog inputs. Use 'dir PortB out' and you should be good to go.
For this series of PIC devices, user's will need to explicitly set the direction port/pins as outputs; at least until the compiler code gets fixed.
Unless there is a specific reason for creating a string variable, just use Print "hello world".
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
O.K. looked at the assembler and the lcd.h does indeed set the PortB pins as outputs, so that was not the problem. Never hurts to put a delay in your code, otherwise the screen writes so fast it can appear to be a blur.
Main:
(code here)
wait 1 sec ;Wait some delay period
goto main
Another culprit could be the lcd contrast is not set right. If you have say a 10k pot then high side pin to Vdd, wiper to lcd contrast pin, low side to Vss. Don't have a 16f84 to see what else might be the problem.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
'General hardware configuration
#chip 16F876A, 20
#config HS_OSC, WDT_OFF, LVP_OFF
'LCD connection settings
#define LCD_IO 4
#define LCD_DB4 PORTB.0
#define LCD_DB5 PORTB.1
#define LCD_DB6 PORTB.2
#define LCD_DB7 PORTB.3
#define LCD_RS PORTC.0
#define LCD_Enable PORTC.1
#define LCD_RW PORTC.2
dir PORTC.3 OUT
PRINT "Hello World"
Using the latest update the following code generates problems.
compiled.asm:389:Error [113] Symbol not previously defined (SYSSTRINGLENGTH).
As stated looking in the asm file, SYSSTRINGLENGTH is not defined.
If given the latest source code I could try to fix this problem in my spare time.
I had the same problem the first time I used an LCD (on a 16F690). For me, the answer was to have all of the LCD pins on the same port. i.e.
#define LCD_IO 4
#define LCD_DB4 PORTC.0
#define LCD_DB5 PORTC.1
#define LCD_DB6 PORTC.2
#define LCD_DB7 PORTC.3
#define LCD_RS PORTC.4
#define LCD_RW PORTC.5
#define LCD_Enable PORTC.6
Fortunately, I was able to spare the Port C pins on my project for the LCD so all was fine and happy for me. Perhaps, if you need to use the pin assignment you have above, then this is something Hugh could work into the next version of GCBasic?
Hope this helps,
Grant
I have been trying to get a LCD to work for a couple of days, having checked all the wiring etc but think I may be missing something basic. The pin connections are:
Pins
Chip LCD
==== ===
7 (RB1) 4 (RS)
8 (RB2) 5 (RW)
9 (RB3) 6 (E)
10 (RB4) 11
11 (RB5) 12
12 (RB6) 13
13 (RB6) 14
and my program is:
' "Hello world" on a LED display.
#chip 16F84, 20
#define LCD_IO 4
#define LCD_RS PORTb.1
#define LCD_RW PORTb.2
#define LCD_Enable PORTb.3
#define LCD_DB4 PORTb.4
#define LCD_DB5 PORTb.5
#define LCD_DB6 PORTb.6
#define LCD_DB7 PORTb.7
hello = "hello world"
PRINT hello
locate 1,0
PRINT hello
All that appears is a row of black blocks which, reading other posts, means that the system is working but not receiving correct data.
Anything obvious?
Philip
That would be very nice. I'm using 9.3.0 with no problem. I wanted to use PORTB for all the pins but since I have an ICSP circuit attached I don't want to deal with all the interfacing issues (isolation circuitry etc). And i'm reserving the other PORTC pins for RS232 which I plan on adding soon. So for now i'll stick with 9.3.0. Thanks for the help!
Problem still there after only using one port.
'General hardware configuration
#chip 16F876A, 20
#config HS_OSC, WDT_OFF, LVP_OFF
'LCD connection settings
#define LCD_IO 4
#define LCD_DB4 PORTB.0
#define LCD_DB5 PORTB.1
#define LCD_DB6 PORTB.2
#define LCD_DB7 PORTB.3
#define LCD_RS PORTB.4
#define LCD_Enable PORTB.5
#define LCD_RW PORTB.6
So its not that... Must be something new that broke support.
It's most likely some alteration I made to the string handling recently. However, I have no trouble compiling it with the newest version of GCBASIC - I've just updated http://gcbasic.sourceforge.net/newfiles/update.zip
I've no idea why there would be any trouble using pins on different ports with the LCD routines. Certainly in the past I've used a mix of PORTC and PORTD pins without any sign of trouble. Still, I'll try some different combinations when I get time and see if any strange problems occur.
I just tried the update and i'm still having problems with the PRINT command. I tried compiling with different chips and the same problem still occurs. I don't think there is a problem using different pins, as it works with 9.3.0.
In addition, the compiled executable from 9.3.0 with the updated core and system.h files compiles the file correctly.
I've double checked the update.zip file, and the lcd.h in it was a few days older than the one I'm using. update.zip now has exactly the same system.h, lcd.h and gcbasic.exe that I'm using, which hopefully will work.
If it still doesn't work, could you please post the entire asm file?
Also, the newest source code (gcbasic.bas) is now in update.zip.
Everything works great now! Thanks!
Not so obvious, taking into account that most example code (and some header/library's) out there assumes that the port pins are set to digital output. As just mentioned in the 'blink led 16f84a post', GCBasic is not initializing the I/O pins for the 16f84, 16f84a as digital output. On POR, Pic devices default to analog inputs. Use 'dir PortB out' and you should be good to go.
For this series of PIC devices, user's will need to explicitly set the direction port/pins as outputs; at least until the compiler code gets fixed.
Unless there is a specific reason for creating a string variable, just use Print "hello world".
Thanks. Have altered program and no difference, so there must/may also be a problem in my programmer settings.
Philip
O.K. looked at the assembler and the lcd.h does indeed set the PortB pins as outputs, so that was not the problem. Never hurts to put a delay in your code, otherwise the screen writes so fast it can appear to be a blur.
Main:
(code here)
wait 1 sec ;Wait some delay period
goto main
Another culprit could be the lcd contrast is not set right. If you have say a 10k pot then high side pin to Vdd, wiper to lcd contrast pin, low side to Vss. Don't have a 16f84 to see what else might be the problem.