I can't get the routine that is in the "Help" files to work. The DisplayValue works fine. I am using a 16F84A_20. Also I am using the setup from GCBIDE. The first time I tried the routine I had added some other lines of code. The program would run, but when it was time to show "HELLO" the LED was blank. There was a pause, indicating that something was happening. Then my program would loop back and run again. Last night I typed in just the DisplayChar routine. When I ran it only segments a, b, and c were on and there was no indication of a loop (segments did not blink).
Any help would be appreciated..
Mel
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This is one of those bugs that is really strange! The DisplayValue and DisplayChar routines are pretty much identical in structure, the only difference is that one has a few more ifs in it.
The only thing that I can think of is that the pin directions aren't getting set properly. Try adding a Dir command to set the port used for the 7 segment display to an output. I'm not hopeful, but I'm really out of ideas. Sometimes alternate pin functions are the cause of this sort of thing, but there aren't any on PORTB of the '84A.
Could you please post the .asm file that GCBASIC is producing? It hopefully might reveal what is happening here!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hugh, thanks for the reply. I am not at home right now. Daughter-in-law had some major surgery. We are helping out for a while. As soon as we get home I will post the .asm file as you requested.(May be several days)
Thanks again,
Mel
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hugh, back home now so I will try to post the file/files so that you can have a look.
I will first post the .gcb file so that you can see how I set it up. I added the extra "HELLO" to see if I could do it and to give me a reference to tell if the PIC was runing and not locked up.
'******************************************************************************************************************
'*** THE CHIP MODEL & SETTINGS
'******************************************************************************************************************
#chip 16F84A, 20
'******************************************************************************************************************
'*** INCLUDE FILES
'******************************************************************************************************************
'******************************************************************************************************************
'*** DEFINE GENERAL CONSTANTS
'******************************************************************************************************************
#define StartUpDelay 10 ms
'******************************************************************************************************************
'*** PIN DIRECTIONS
'******************************************************************************************************************
Dir Pin1 OUT
Dir Pin2 OUT
Dir Pin3 OUT
'Pin4 = MCLR
'Pin5 = Vss
Dir Pin6 OUT
Dir Pin7 OUT
Dir Pin8 OUT
Dir Pin9 OUT
Dir Pin10 OUT
Dir Pin11 OUT
Dir Pin12 OUT
Dir Pin13 OUT
'Pin14 = Vdd
'Pin15 = OSC2
'Pin16 = OSC1
Dir Pin17 OUT
Dir Pin18 OUT
'******************************************************************************************************************
'*** INNITIALISATION CODE
'******************************************************************************************************************
Startup:
Wait StartUpDelay
'*** code to setup chip
'*** before running app code
'******************************************************************************************************************
'*** MAIN PROGRAM LOOP
'******************************************************************************************************************
Main:
#define DisplayPortA PortB
;********************************************************************************
;Subroutines included in program
;********************************************************************************
Looking at the assembly, the SysReadString sub is empty! This is used internally in GCBASIC to copy strings of text, and its absence certainly explains why the display isn't showing anything.
However, I'm not sure what has caused the sub to be empty. When I compile with the version of GCBASIC I've got here, it all compiles fine.
It's always possible that something in your GCBASIC installation isn't quite right. The first thing I'd try is replacing gcbasic.exe and system.h with the versions from whatever the last update you installed is. If this doesn't work, I've uploaded a copy of these 2 files exactly as they are on my PC to http://gcbasic.sourceforge.net/newfiles/gcbasic.zip . They're not tested well and might contain more bugs, but it's worth a try to see if they fix the trouble you're having.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks Hugh, I will give all this a try. Maybe a bad install is causing the other problems that I am having, LCD routines not compiling. Thinking maybe I should uninstall GCB and then install latest release. I will do some checking and get back with you.
Thanks again
...Mel
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Finally had the time to work on this. Yes re-installing some of the files fixed the problem. The routine runs as it should now. Now on to the LCD routines.
Thanks Hugh, for your help!!!
...Mel
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I can't get the routine that is in the "Help" files to work. The DisplayValue works fine. I am using a 16F84A_20. Also I am using the setup from GCBIDE. The first time I tried the routine I had added some other lines of code. The program would run, but when it was time to show "HELLO" the LED was blank. There was a pause, indicating that something was happening. Then my program would loop back and run again. Last night I typed in just the DisplayChar routine. When I ran it only segments a, b, and c were on and there was no indication of a loop (segments did not blink).
Any help would be appreciated..
Mel
This is one of those bugs that is really strange! The DisplayValue and DisplayChar routines are pretty much identical in structure, the only difference is that one has a few more ifs in it.
The only thing that I can think of is that the pin directions aren't getting set properly. Try adding a Dir command to set the port used for the 7 segment display to an output. I'm not hopeful, but I'm really out of ideas. Sometimes alternate pin functions are the cause of this sort of thing, but there aren't any on PORTB of the '84A.
Could you please post the .asm file that GCBASIC is producing? It hopefully might reveal what is happening here!
Hugh, thanks for the reply. I am not at home right now. Daughter-in-law had some major surgery. We are helping out for a while. As soon as we get home I will post the .asm file as you requested.(May be several days)
Thanks again,
Mel
Hugh, back home now so I will try to post the file/files so that you can have a look.
I will first post the .gcb file so that you can see how I set it up. I added the extra "HELLO" to see if I could do it and to give me a reference to tell if the PIC was runing and not locked up.
'******************************************************************************************************************
'*** THE CHIP MODEL & SETTINGS
'******************************************************************************************************************
#chip 16F84A, 20
'******************************************************************************************************************
'*** INCLUDE FILES
'******************************************************************************************************************
'******************************************************************************************************************
'*** DEFINE GENERAL CONSTANTS
'******************************************************************************************************************
#define StartUpDelay 10 ms
'******************************************************************************************************************
'*** DEFINE PORT NAMES
'******************************************************************************************************************
#define Pin1 PORTA.2
#define Pin2 PORTA.3
#define Pin3 PORTA.4
'Pin4 = MCLR
'Pin5 = Vss
#define Pin6 PORTB.0
#define Pin7 PORTB.1
#define Pin8 PORTB.2
#define Pin9 PORTB.3
#define Pin10 PORTB.4
#define Pin11 PORTB.5
#define Pin12 PORTB.6
#define Pin13 PORTB.7
'Pin14 = Vdd
'Pin15 = OSC2
'Pin16 = OSC1
#define Pin17 PORTA.0
#define Pin18 PORTA.1
'******************************************************************************************************************
'*** PIN DIRECTIONS
'******************************************************************************************************************
Dir Pin1 OUT
Dir Pin2 OUT
Dir Pin3 OUT
'Pin4 = MCLR
'Pin5 = Vss
Dir Pin6 OUT
Dir Pin7 OUT
Dir Pin8 OUT
Dir Pin9 OUT
Dir Pin10 OUT
Dir Pin11 OUT
Dir Pin12 OUT
Dir Pin13 OUT
'Pin14 = Vdd
'Pin15 = OSC2
'Pin16 = OSC1
Dir Pin17 OUT
Dir Pin18 OUT
'******************************************************************************************************************
'*** INNITIALISATION CODE
'******************************************************************************************************************
Startup:
Wait StartUpDelay
'*** code to setup chip
'*** before running app code
'******************************************************************************************************************
'*** MAIN PROGRAM LOOP
'******************************************************************************************************************
Main:
#define DisplayPortA PortB
Dim Message(10)
Message() = "HELLO "
for Counter = 0 to 6
DisplayChar 1, Message(Counter)
Wait 25 10ms
next
PortB = b'01110110'
Wait 1 sec
PortB = 0
Wait 25 10ms
PortB = b'01111001'
Wait 1 sec
PortB = 0
Wait 25 10ms
PortB = b'00111000'
Wait 1 sec
PortB = 0
Wait 25 10ms
PortB = b'00111000'
Wait 1 sec
PortB = 0
Wait 25 10ms
PortB = b'00111111'
Wait 1 sec
PortB = 0
Wait 1 sec
Goto Main
Now here is the .asm file
;********************************************************************************
;Set up the assembler options (Chip type, clock source, other bits and pieces)
LIST p=16F84A, r=DEC
#include <P16F84A.inc>
__CONFIG _HS_OSC & _WDT_OFF
;********************************************************************************
;Set aside memory locations for variables
MESSAGE equ 67 ;Array
COUNTER equ 12
DELAYTEMP equ 13
DELAYTEMP2 equ 14
DISPCHAR equ 15
DISPPORT equ 16
DISPTEMP equ 17
StringPointer equ 18
SysIFTemp equ 19
SysStringA equ 20
SysStringA_H equ 21
SysStringB equ 22
SysStringB_H equ 23
SysWaitTemp10MS equ 24
SysWaitTempMS equ 25
SysWaitTempMS_H equ 26
SysWaitTempS equ 27
T1CON equ 28
TMR0PRES equ 29
TMR0SOURCE equ 30
TMR1PRES equ 31
TMR1SOURCE equ 32
;********************************************************************************
;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
;********************************************************************************
;Start of the main program
banksel TRISA
bcf TRISA,2
bcf TRISA,3
bcf TRISA,4
bcf TRISB,0
bcf TRISB,1
bcf TRISB,2
bcf TRISB,3
bcf TRISB,4
bcf TRISB,5
bcf TRISB,6
bcf TRISB,7
bcf TRISA,0
bcf TRISA,1
STARTUP
movlw 10
banksel SYSWAITTEMPMS
movwf SysWaitTempMS
clrf SysWaitTempMS_H
call Delay_MS
MAIN
movlw low MESSAGE
movwf SysStringB
movlw high MESSAGE
movwf SysStringB_H
movlw low StringTable1
movwf SysStringA
movlw high StringTable1
movwf SysStringA_H
call SysReadString
movlw 255
movwf COUNTER
SysForLoop1
incf COUNTER,F
movlw 1
movwf DISPPORT
movlw low MESSAGE
addwf COUNTER,W
movwf FSR
movf INDF,W
movwf DISPCHAR
call DISPLAYCHAR
movlw 25
movwf SysWaitTemp10MS
call Delay_10MS
movlw 6
subwf COUNTER,W
btfss STATUS, C
goto SysForLoop1
movlw 118
movwf PORTB
movlw 1
movwf SysWaitTempS
call Delay_S
clrf PORTB
movlw 25
movwf SysWaitTemp10MS
call Delay_10MS
movlw 121
movwf PORTB
movlw 1
movwf SysWaitTempS
call Delay_S
clrf PORTB
movlw 25
movwf SysWaitTemp10MS
call Delay_10MS
movlw 56
movwf PORTB
movlw 1
movwf SysWaitTempS
call Delay_S
clrf PORTB
movlw 25
movwf SysWaitTemp10MS
call Delay_10MS
movlw 56
movwf PORTB
movlw 1
movwf SysWaitTempS
call Delay_S
clrf PORTB
movlw 25
movwf SysWaitTemp10MS
call Delay_10MS
movlw 63
movwf PORTB
movlw 1
movwf SysWaitTempS
call Delay_S
clrf PORTB
movlw 1
movwf SysWaitTempS
call Delay_S
goto MAIN
BASPROGRAMEND
sleep
goto $
;********************************************************************************
; 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 6
retlw 72 ;H
retlw 69 ;E
retlw 76 ;L
retlw 76 ;L
retlw 79 ;O
retlw 32 ;
;********************************************************************************
;Subroutines included in program
;********************************************************************************
DISPLAYCHAR
movlw 32
subwf DISPCHAR,W
btfss STATUS, Z
goto ENDIF2
clrf DISPTEMP
goto SHOWCHAR
ENDIF2
movlw 65
subwf DISPCHAR,W
btfss STATUS, C
return
movlw 96
movwf SysIFTemp
movf DISPCHAR,W
subwf SysIFTemp,W
btfsc STATUS, C
goto ENDIF4
movlw 32
subwf DISPCHAR,F
ENDIF4
movlw 90
movwf SysIFTemp
movf DISPCHAR,W
subwf SysIFTemp,W
btfss STATUS, C
return
movlw 65
subwf DISPCHAR,W
btfss STATUS, Z
goto ENDIF6
movlw 119
movwf DISPTEMP
ENDIF6
movlw 66
subwf DISPCHAR,W
btfss STATUS, Z
goto ENDIF7
movlw 124
movwf DISPTEMP
ENDIF7
movlw 67
subwf DISPCHAR,W
btfss STATUS, Z
goto ENDIF8
movlw 57
movwf DISPTEMP
ENDIF8
movlw 68
subwf DISPCHAR,W
btfss STATUS, Z
goto ENDIF9
movlw 94
movwf DISPTEMP
ENDIF9
movlw 69
subwf DISPCHAR,W
btfss STATUS, Z
goto ENDIF10
movlw 121
movwf DISPTEMP
ENDIF10
movlw 70
subwf DISPCHAR,W
btfss STATUS, Z
goto ENDIF11
movlw 113
movwf DISPTEMP
ENDIF11
movlw 71
subwf DISPCHAR,W
btfss STATUS, Z
goto ENDIF12
movlw 61
movwf DISPTEMP
ENDIF12
movlw 72
subwf DISPCHAR,W
btfss STATUS, Z
goto ENDIF13
movlw 118
movwf DISPTEMP
ENDIF13
movlw 73
subwf DISPCHAR,W
btfss STATUS, Z
goto ENDIF14
movlw 6
movwf DISPTEMP
ENDIF14
movlw 74
subwf DISPCHAR,W
btfss STATUS, Z
goto ENDIF15
movlw 14
movwf DISPTEMP
ENDIF15
movlw 75
subwf DISPCHAR,W
btfss STATUS, Z
goto ENDIF16
movlw 118
movwf DISPTEMP
ENDIF16
movlw 76
subwf DISPCHAR,W
btfss STATUS, Z
goto ENDIF17
movlw 56
movwf DISPTEMP
ENDIF17
movlw 77
subwf DISPCHAR,W
btfss STATUS, Z
goto ENDIF18
movlw 55
movwf DISPTEMP
ENDIF18
movlw 78
subwf DISPCHAR,W
btfss STATUS, Z
goto ENDIF19
movlw 55
movwf DISPTEMP
ENDIF19
movlw 79
subwf DISPCHAR,W
btfss STATUS, Z
goto ENDIF20
movlw 63
movwf DISPTEMP
ENDIF20
movlw 80
subwf DISPCHAR,W
btfss STATUS, Z
goto ENDIF21
movlw 115
movwf DISPTEMP
ENDIF21
movlw 81
subwf DISPCHAR,W
btfss STATUS, Z
goto ENDIF22
movlw 103
movwf DISPTEMP
ENDIF22
movlw 82
subwf DISPCHAR,W
btfss STATUS, Z
goto ENDIF23
movlw 80
movwf DISPTEMP
ENDIF23
movlw 83
subwf DISPCHAR,W
btfss STATUS, Z
goto ENDIF24
movlw 109
movwf DISPTEMP
ENDIF24
movlw 84
subwf DISPCHAR,W
btfss STATUS, Z
goto ENDIF25
movlw 7
movwf DISPTEMP
ENDIF25
movlw 85
subwf DISPCHAR,W
btfss STATUS, Z
goto ENDIF26
movlw 62
movwf DISPTEMP
ENDIF26
movlw 86
subwf DISPCHAR,W
btfss STATUS, Z
goto ENDIF27
movlw 62
movwf DISPTEMP
ENDIF27
movlw 87
subwf DISPCHAR,W
btfss STATUS, Z
goto ENDIF28
movlw 62
movwf DISPTEMP
ENDIF28
movlw 88
subwf DISPCHAR,W
btfss STATUS, Z
goto ENDIF29
movlw 118
movwf DISPTEMP
ENDIF29
movlw 89
subwf DISPCHAR,W
btfss STATUS, Z
goto ENDIF30
movlw 110
movwf DISPTEMP
ENDIF30
movlw 90
subwf DISPCHAR,W
btfss STATUS, Z
goto ENDIF31
movlw 27
movwf DISPTEMP
ENDIF31
SHOWCHAR
movlw 1
subwf DISPPORT,W
btfss STATUS, Z
goto ENDIF32
movf DISPTEMP,W
movwf PORTB
ENDIF32
return
;********************************************************************************
Delay_10MS
D10MS_START
movlw 10
movwf SysWaitTempMS
clrf SysWaitTempMS_H
call Delay_MS
decfsz SysWaitTemp10MS, F
goto D10MS_START
return
;********************************************************************************
Delay_MS
incf SysWaitTempMS_H, F
DMS_START
movlw 10
movwf DELAYTEMP2
DMS_OUTER
movlw 166
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
;********************************************************************************
INITSYS
clrf PORTA
clrf PORTB
return
;********************************************************************************
SYSREADSTRING
return
;********************************************************************************
END
Mel
Looking at the assembly, the SysReadString sub is empty! This is used internally in GCBASIC to copy strings of text, and its absence certainly explains why the display isn't showing anything.
However, I'm not sure what has caused the sub to be empty. When I compile with the version of GCBASIC I've got here, it all compiles fine.
It's always possible that something in your GCBASIC installation isn't quite right. The first thing I'd try is replacing gcbasic.exe and system.h with the versions from whatever the last update you installed is. If this doesn't work, I've uploaded a copy of these 2 files exactly as they are on my PC to http://gcbasic.sourceforge.net/newfiles/gcbasic.zip . They're not tested well and might contain more bugs, but it's worth a try to see if they fix the trouble you're having.
Thanks Hugh, I will give all this a try. Maybe a bad install is causing the other problems that I am having, LCD routines not compiling. Thinking maybe I should uninstall GCB and then install latest release. I will do some checking and get back with you.
Thanks again
...Mel
Finally had the time to work on this. Yes re-installing some of the files fixed the problem. The routine runs as it should now. Now on to the LCD routines.
Thanks Hugh, for your help!!!
...Mel