What about the whole code?
What about the whole code?
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
this is very roufe. Im still debugging and playing.
'
' PIC Defines
' -----------
@ DEVICE pic16F628, INTRC_OSC_NOCLKOUT ' System Clock Options Saves A6, A7
@ DEVICE pic16F628, WDT_ON ' Watchdog Timer
@ DEVICE pic16F628, PWRT_ON ' Power-On Timer
@ DEVICE pic16F628, MCLR_OFF ' Master Clear Options (Internal) Saves A5
@ DEVICE pic16F628, BOD_ON ' Brown-Out Detect
@ DEVICE pic16F628, LVP_OFF ' Low-Voltage Programming
@ DEVICE pic16F628, CPD_OFF ' Data Memory Code Protect
@ DEVICE pic16F628, PROTECT_OFF ' Program Code Protection
VRCON = 0 ' A/D Voltage reference disabled
CMCON = 7 ' disable analog comparators on almost any PIC so equipped
TRISA=%00000000 ' Or TRISA = 0 sets all the PORTA pins to outputs
TRISB=%01000000
Include "modedefs.bas" ' Include serial modes
' Ports
pLcd_dat var PORTA ' LCD 8 bit data bus
pRS Var PORTB.0 ' RS
pE VAR PORTB.4 ' E
pCs1 VAR PORTB.7 ' Cable Select 1
pLed Var PORTB.3 ' Status LED
GoTo init '****** jump past the routines below ******
send:
pCs1 = 0 ' TODO Change
'pause 1
pRS = gRS
pause 2
'pause 42
pLcd_dat = glcd_dat
PORTB.6 = glcd_dat.4
PORTB.5 = glcd_dat.5
'pause 1
pE = 1
'pauseUS 10
'pause 100
pause 2
'pause 60
pE = 0
'pause 1
pRS = 0
pCs1 = 1
'pCs2 = 1
'pCs3 = 1
pause 7
'pause 140
Return
init: 'Initialization
' H
for i=0 to 4
LOOKUP2 i,[$7F,$08,$08,$08,$7F],glcd_dat
GoSub send
Next
goto init
mmm what about if you use HIGH/LOW instead of Myvar=0, Myvar=1???
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
>> Ports in question are
>> RA4
>> RB6
>> RB7
---
RA4 is multiplexed with T0CKI and CMP2. You've already taken care of CMP2 with the CMCON = 7. The T0CKI input is controlled by the T0CS bit in the OPTION_REG which defaults to 1 (Timer0 input is T0CKI). You can turn this off by setting OPTION_REG.5 = 0. However This will not affect the operation of RA4 as an output, which appears to be the problem.
RA4 is an open collector type output. It requires a Pull-Up resistor on the output to be used as a normal digital output.
---
RB6 is multiplexed with T1OSO, T1CKI and PGC. T1OSO and T1CKI are controlled by T1CON bits 1 (TMR1CS) and 3 (T1OSCEN). Both of these bits default to 0, which means that the multiplexed functions are disabled. PGC is only used during programming, but if you leave a programmer connected during operation, you may have problems.
However, in your program you have ...
TRISB=%01000000
With a 1 in the bit 6 position, RB6 is set to INPUT. As we found out in your other thread, you want RB6 to be an output.
---
RB7 is multiplexed with T1OSO and PGD. Again, T1OSO is disabled by default (T1OSCEN). and the previous mention of the programmer applies here too.
It may be that you grabbed an old file for this post. But the correction from the "other" thread is incorrect in this listing.
pLcd_dat = glcd_dat
PORTB.6 = glcd_dat.4
PORTB.5 = glcd_dat.5
change to
pLcd_dat = glcd_dat
PORTB.6 = glcd_dat.6
PORTB.5 = glcd_dat.7
---
Also, like mat says, RA5 is input only, so it will have to be moved to a different pin.
HTH,
Darrel
thanks so much for your help.
I found a sample that had a pull up on A5. This i tested and it fixed the problem.
The TRISB=%01000000 was a mistake on my part. I thought it was %01234567 and i your saying that it should be 76543210
I need B1 as a input so i chnaged to TRISB=%00000010
Oviously i have much to learn.
Bookmarks