I tried GCBASIC with great satisfaction using the Microchip Pikit2 and a PIC 16F690. I/O and analog inputs works as expected, and it is very simple to learn GCbasic.
The only problem I have is in driving LCD display. The LCD remains always blank, both in 4 and 8 bit configuration. i tried also on a breadboard and different display with no results.
Do you have some suggestions?
Thanks
Luca.
This is the code for the 8 bit version:
'User Settings
'Hardware settings
#chip 16F690, 8
#config FCMEN = OFF 'Fail-Safe Clock Monitor Enabled bit
#config IESO = OFF 'IESO: Internal External Switchover bit
#config BOR = OFF 'Brown-out Reset Selection bits
#config CPD = OFF 'Data Code Protection bit
#config CP = OFF 'Code Protection bit
#config MCLRE = OFF 'MCLR Pin Function Select bit
#config PWRTE = OFF 'Power-up Timer Enable bit
#config WDT = OFF 'Watchdog Timer Enable bit
#config Osc = INTOSC 'Oscillator Selection bits
and this is the .asm ( sorry, I don't know assembler):
;Program compiled by Great Cow BASIC (0.9 14/4/2008)
;Need help? See the GCBASIC forums at http://sourceforge.net/forum/?group_id=169286,
;check the documentation or email hconsidine@bigpond.com.
;Start of the main program
movlw 1
movwf SysWaitTempS
call Delay_S
MAIN
movlw low SYSSTRINGPARAM1
movwf SysStringB
movlw high SYSSTRINGPARAM1
movwf SysStringB_H
movlw low StringTable1
movwf SysStringA
movlw high StringTable1
movwf SysStringA_H
call SysReadString
movlw low SYSSTRINGPARAM1
movwf SysPRINTDATAHandler
movlw high SYSSTRINGPARAM1
movwf SysPRINTDATAHandler_H
call PRINT46
movlw 1
movwf SysWaitTempS
call Delay_S
call CLS
movlw 1
movwf SysWaitTempS
call Delay_S
goto MAIN
BASPROGRAMEND
sleep
goto $
;********************************************************************************
;Subroutines included in program
;********************************************************************************
Yes, I tried to connect the contrast pin also to ground (as seen in some diagrams) with no results. Anyway, with one display 16x1, the half right row shows eight black squares. With the others (one 16x1 and one 16x2) I can see the dot matrix when touch the contrast pot.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You have the low pin count demo board, and RC3:RC0 are multiplexed with the led's. Go back to 4 bit mode or cut the traces at the jumper locations. Also assuming you are not trying to power the led backlight with the Pickit 2, and if powered seperately, are the grounds connected.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for suggestions, but I just cut the traces as described. Moreover, to avoid problems with hidden traces, I replicate the circuit on my breadboard with the same results.
Someone has tested the code with success on a 16F690?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It works as expected in 4 bit mode, didn't try 8 bit mode, don't want to cut my traces. Using low pin count board with Pickit 2, LCD (no backlight) powered by Pickit 2, with menu item VDD Pickit 2 ON box checked. Please note that the MCLRE = ON in the setup, this comes in handy for resets after programming, could be a startup clock issue? Double check your data lines from the lcd, make sure you are coming off DB4-DB7 for 4 bit mode, if you decide to use it.
'Hardware settings
#chip 16F690, 8
#config FCMEN = OFF 'Fail-Safe Clock Monitor Enabled bit
#config IESO = OFF 'IESO: Internal External Switchover bit
#config BOR = OFF 'Brown-out Reset Selection bits
#config CPD = OFF 'Data Code Protection bit
#config CP = OFF 'Code Protection bit
#config MCLRE = ON 'MCLR Pin Function Select bit
#config PWRTE = OFF 'Power-up Timer Enable bit
#config WDT = OFF 'Watchdog Timer Enable bit
#config Osc = INTOSC 'Oscillator Selection bits
The problem seems related to the use of MCLRE. With MCLRE set to ON all works as expected.
Now I have another problem, with 2x16 display all is perfect, but with 1x16 display only the first characters are diaplayed. Is not a problem caused by a defective display, because I tried two different displays.
I will investigate, then if necessary I will open a new thread.
Thanks again
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I tried GCBASIC with great satisfaction using the Microchip Pikit2 and a PIC 16F690. I/O and analog inputs works as expected, and it is very simple to learn GCbasic.
The only problem I have is in driving LCD display. The LCD remains always blank, both in 4 and 8 bit configuration. i tried also on a breadboard and different display with no results.
Do you have some suggestions?
Thanks
Luca.
This is the code for the 8 bit version:
'User Settings
'Hardware settings
#chip 16F690, 8
#config FCMEN = OFF 'Fail-Safe Clock Monitor Enabled bit
#config IESO = OFF 'IESO: Internal External Switchover bit
#config BOR = OFF 'Brown-out Reset Selection bits
#config CPD = OFF 'Data Code Protection bit
#config CP = OFF 'Code Protection bit
#config MCLRE = OFF 'MCLR Pin Function Select bit
#config PWRTE = OFF 'Power-up Timer Enable bit
#config WDT = OFF 'Watchdog Timer Enable bit
#config Osc = INTOSC 'Oscillator Selection bits
'Port setting
'LCD connection settings
#define LCD_IO 8
#define LCD_RS PORTB.4
#define LCD_RW PORTB.5
#define LCD_Enable PORTB.6
#define LCD_DATA_PORT PORTC
WAIT 1 S
Main:
PRINT "Hello World"
Wait 1 sec
CLS
Wait 1 sec
goto Main
and this is the .asm ( sorry, I don't know assembler):
;Program compiled by Great Cow BASIC (0.9 14/4/2008)
;Need help? See the GCBASIC forums at http://sourceforge.net/forum/?group_id=169286,
;check the documentation or email hconsidine@bigpond.com.
;********************************************************************************
;Set up the assembler options (Chip type, clock source, other bits and pieces)
LIST p=16F690, r=DEC
#include <P16F690.inc>
__CONFIG _FCMEN_OFF & _IESO_OFF & _BOR_OFF & _CPD_OFF & _CPD_OFF & _MCLRE_OFF & _PWRTE_OFF & _WDT_OFF & _INTOSCIO
;********************************************************************************
;Set aside memory locations for variables
SYSSTRINGPARAM1 equ 345 ;Array
DELAYTEMP equ 32
DELAYTEMP2 equ 33
LCDBYTE equ 34
LCDREADY equ 35
PRINTLEN equ 36
SYSCALCTEMPA equ 37
SYSCALCTEMPA_H equ 38
SYSLCDTEMP equ 39
SYSPRINTTEMP equ 40
SYSSTRINGLENGTH equ 41
StringPointer equ 42
SysPRINTDATAHandler equ 43
SysPRINTDATAHandler_H equ 44
SysStringA equ 45
SysStringA_H equ 46
SysStringB equ 47
SysStringB_H equ 48
SysWaitTemp10US equ 49
SysWaitTempMS equ 50
SysWaitTempMS_H equ 51
SysWaitTempS equ 52
;********************************************************************************
;Jump to initialisation code when PIC is reset
ORG 0
call INITSYS
goto SystemInitialise
;********************************************************************************
;Interrupt vector
ORG 4
;Various initialisation routines, automatically called by GCBASIC
SystemInitialise
call INITLCD
;********************************************************************************
;Start of the main program
movlw 1
movwf SysWaitTempS
call Delay_S
MAIN
movlw low SYSSTRINGPARAM1
movwf SysStringB
movlw high SYSSTRINGPARAM1
movwf SysStringB_H
movlw low StringTable1
movwf SysStringA
movlw high StringTable1
movwf SysStringA_H
call SysReadString
movlw low SYSSTRINGPARAM1
movwf SysPRINTDATAHandler
movlw high SYSSTRINGPARAM1
movwf SysPRINTDATAHandler_H
call PRINT46
movlw 1
movwf SysWaitTempS
call Delay_S
call CLS
movlw 1
movwf SysWaitTempS
call Delay_S
goto MAIN
BASPROGRAMEND
sleep
goto $
;********************************************************************************
;Subroutines included in program
;********************************************************************************
CLS
bcf PORTB,4
movlw 1
movwf LCDBYTE
call LCDWRITEBYTE
movlw 2
movwf SysWaitTempMS
clrf SysWaitTempMS_H
call Delay_MS
movlw 128
movwf LCDBYTE
call LCDWRITEBYTE
movlw 10
movwf SysWaitTemp10US
call Delay_10US
return
;********************************************************************************
Delay_10US
D10US_START
movlw 6
movwf DELAYTEMP
D10US_LOOP
decfsz DELAYTEMP, F
goto D10US_LOOP
decfsz SysWaitTemp10US, F
goto D10US_START
return
;********************************************************************************
Delay_MS
incf SysWaitTempMS_H, F
DMS_START
movlw 10
movwf DELAYTEMP2
DMS_OUTER
movlw 66
movwf DELAYTEMP
DMS_INNER
decfsz DELAYTEMP, F
goto DMS_INNER
decfsz DELAYTEMP2, F
goto DMS_OUTER
decfsz SysWaitTempMS, F
goto DMS_START
decfsz SysWaitTempMS_H, F
goto DMS_START
return
;********************************************************************************
Delay_S
DS_START
movlw 232
movwf SysWaitTempMS
movlw 3
movwf SysWaitTempMS_H
call Delay_MS
decfsz SysWaitTempS, F
goto DS_START
return
;********************************************************************************
FN_LCDREADY
clrf LCDREADY
bcf SYSLCDTEMP,2
btfsc PORTB,4
bsf SYSLCDTEMP,2
bsf PORTB,5
bcf PORTB,4
bsf PORTB,6
movlw 5
movwf SysWaitTemp10US
call Delay_10US
movlw 255
banksel TRISC
movwf TRISC
banksel PORTC
btfsc PORTC,7
goto ENDIF1
movlw 255
movwf LCDREADY
ENDIF1
bcf PORTB,6
movlw 25
movwf SysWaitTemp10US
call Delay_10US
bcf PORTB,4
btfsc SYSLCDTEMP,2
bsf PORTB,4
return
;********************************************************************************
INITLCD
banksel TRISB
bcf TRISB,4
bcf TRISB,5
bcf TRISB,6
movlw 10
banksel SYSWAITTEMPMS
movwf SysWaitTempMS
clrf SysWaitTempMS_H
call Delay_MS
SysWaitLoop1
call FN_LCDREADY
movf LCDREADY,F
btfsc STATUS,Z
goto SysWaitLoop1
bcf PORTB,4
movlw 56
movwf LCDBYTE
call LCDWRITEBYTE
bcf PORTB,4
movlw 6
movwf LCDBYTE
call LCDWRITEBYTE
movlw 5
movwf SysWaitTemp10US
call Delay_10US
movlw 12
movwf LCDBYTE
call LCDWRITEBYTE
movlw 5
movwf SysWaitTemp10US
call Delay_10US
call CLS
return
;********************************************************************************
INITSYS
movlw 112
banksel OSCCON
iorwf OSCCON,F
banksel ADCON0
bcf ADCON0,ADON
bcf ADCON0,ADFM
banksel ANSEL
clrf ANSEL
clrf ANSELH
banksel PORTA
clrf PORTA
clrf PORTB
clrf PORTC
return
;********************************************************************************
LCDWRITEBYTE
SysWaitLoop2
call FN_LCDREADY
movf LCDREADY,F
btfsc STATUS,Z
goto SysWaitLoop2
bcf PORTB,5
banksel TRISC
clrf TRISC
banksel LCDBYTE
movf LCDBYTE,W
movwf PORTC
bsf PORTB,6
movlw 5
movwf SysWaitTemp10US
call Delay_10US
bcf PORTB,6
movlw 5
movwf SysWaitTemp10US
call Delay_10US
clrf PORTC
return
;********************************************************************************
;PRINT (STRING)
PRINT46
movf SysPRINTDATAHandler,W
movwf FSR
bcf STATUS, IRP
btfsc SysPRINTDATAHandler_H,0
bsf STATUS, IRP
movf INDF,W
movwf PRINTLEN
movlw 0
subwf PRINTLEN,W
btfsc STATUS, Z
return
bsf PORTB,4
clrf SYSPRINTTEMP
SysForLoop1
incf SYSPRINTTEMP,F
movf SYSPRINTTEMP,W
addwf SysPRINTDATAHandler,W
movwf FSR
bcf STATUS, IRP
btfsc SysPRINTDATAHandler_H,0
bsf STATUS, IRP
movf INDF,W
movwf LCDBYTE
call LCDWRITEBYTE
movf PRINTLEN,W
subwf SYSPRINTTEMP,W
btfss STATUS, C
goto SysForLoop1
return
;********************************************************************************
SYSREADSTRING
movf SYSSTRINGB, W
movwf FSR
bcf STATUS, IRP
btfsc SYSSTRINGB_H, 0
bsf STATUS, IRP
call SYSSTRINGTABLES
movwf SYSCALCTEMPA
movwf INDF
addwf SYSSTRINGB, F
goto SYSSTRINGREADCHECK
SYSREADSTRINGPART
movf SYSSTRINGB, W
movwf FSR
bcf STATUS, IRP
btfsc SYSSTRINGB_H, 0
bsf STATUS, IRP
call SYSSTRINGTABLES
movwf SYSCALCTEMPA
addwf SYSSTRINGLENGTH,F
addwf SYSSTRINGB,F
SYSSTRINGREADCHECK
movf SYSCALCTEMPA,F
btfsc STATUS,Z
return
SYSSTRINGREAD
call SYSSTRINGTABLES
incf FSR, F
movwf INDF
decfsz SYSCALCTEMPA, F
goto SYSSTRINGREAD
return
;********************************************************************************
; String Lookup Table
SysStringTables
movf SysStringA_H,W
movwf PCLATH
movf SysStringA,W
incf SysStringA,F
btfsc STATUS,Z
incf SysStringA_H,F
movwf PCL
StringTable1
retlw 11
retlw 72 ;H
retlw 101 ;e
retlw 108 ;l
retlw 108 ;l
retlw 111 ;o
retlw 32 ;
retlw 87 ;W
retlw 111 ;o
retlw 114 ;r
retlw 108 ;l
retlw 100 ;d
END
Have you got the contrast pin set to the wiper on a 10k pot referenced between 5+V and ground?
Yes, I tried to connect the contrast pin also to ground (as seen in some diagrams) with no results. Anyway, with one display 16x1, the half right row shows eight black squares. With the others (one 16x1 and one 16x2) I can see the dot matrix when touch the contrast pot.
You have the low pin count demo board, and RC3:RC0 are multiplexed with the led's. Go back to 4 bit mode or cut the traces at the jumper locations. Also assuming you are not trying to power the led backlight with the Pickit 2, and if powered seperately, are the grounds connected.
Thanks for suggestions, but I just cut the traces as described. Moreover, to avoid problems with hidden traces, I replicate the circuit on my breadboard with the same results.
Someone has tested the code with success on a 16F690?
It works as expected in 4 bit mode, didn't try 8 bit mode, don't want to cut my traces. Using low pin count board with Pickit 2, LCD (no backlight) powered by Pickit 2, with menu item VDD Pickit 2 ON box checked. Please note that the MCLRE = ON in the setup, this comes in handy for resets after programming, could be a startup clock issue? Double check your data lines from the lcd, make sure you are coming off DB4-DB7 for 4 bit mode, if you decide to use it.
'Hardware settings
#chip 16F690, 8
#config FCMEN = OFF 'Fail-Safe Clock Monitor Enabled bit
#config IESO = OFF 'IESO: Internal External Switchover bit
#config BOR = OFF 'Brown-out Reset Selection bits
#config CPD = OFF 'Data Code Protection bit
#config CP = OFF 'Code Protection bit
#config MCLRE = ON 'MCLR Pin Function Select bit
#config PWRTE = OFF 'Power-up Timer Enable bit
#config WDT = OFF 'Watchdog Timer Enable bit
#config Osc = INTOSC 'Oscillator Selection bits
'Port setting
'LCD connection settings
#define LCD_IO 4
#define LCD_RS PORTB.4
#define LCD_RW PORTB.5
#define LCD_Enable PORTB.6
'#define LCD_DATA_PORT PORTC
#DEFINE LCD_DB4 PORTC.4
#DEFINE LCD_DB5 PORTC.5
#DEFINE LCD_DB6 PORTC.6
#DEFINE LCD_DB7 PORTC.7
WAIT 1 S
Main:
PRINT "Hello World"
Wait 3 sec
CLS
Wait 1 sec
goto Main
THANKS, IT WORKS!
The problem seems related to the use of MCLRE. With MCLRE set to ON all works as expected.
Now I have another problem, with 2x16 display all is perfect, but with 1x16 display only the first characters are diaplayed. Is not a problem caused by a defective display, because I tried two different displays.
I will investigate, then if necessary I will open a new thread.
Thanks again