UPDATE:
I think the cct is wired up somewhere handy (non technical term). I was a bit unlucky in that I bought a ribbon cable for the job which had the finest wire inside I've ever seen, so had to solder some stiffer 'legs' on to all the wires which kept breaking off, grrr.
The LCD still shows the same 2 dark lines when the pot is turned.
I went for your PORTC option in the end mackrackit (@ DEVICE PICI6F684, MCLR_OFF wouldn't compile for one).
One thing, as Henrik said earlier:
I'm not 100% sure if the LCDOut commands automatically sets the TRIS registers for the Enable and RS bit of the LCD but it certanly doesn't hurt to do that "manually" just to be sure it's correct.
Right now I'm not sure what to set the TRIS registers to for this.
The only other thing I know I haven't done is transfer the GROUND - PIN2 - PIN2 from the PICKit1 (serin / out) to the LCD display.
Ok, here's the program as it stands:
Code:
ANSEL = %00000000 'Disable analog select so ports work as digital i/o.
CMCON0 = %00000111 'Disable analog comparators.
TRISA = %00000000 'Set PORTA as OUTPUT.
PORTA = %00000000 'Set PORTA pins all low.
TRISC = %00000000 'Set PORTC as OUTPUT.
PORTC = %00000000 'Set PORTC pins all low.
DEFINE LCD_DREG PORTC 'PORTC.0 WILL CONNECT TO DB4, PORTC3 TO DB7
DEFINE LCD_DBIT 0
DEFINE LCD_RSREG PORTC
DEFINE LCD_RSBIT 4 'PORTC.4 CONNECT TO LCD PIN4
DEFINE LCD_EREG PORTC
DEFINE LCD_EBIT 5 'PORTC.5 CONNECT TO LCD PIN6
DEFINE LCD_BITS 4
DEFINE LCD_LINES 4
DEFINE LCD_COMMANDUS 2000
DEFINE LCD_DATAUS 50
DEFINE OSC 4
NUM1 VAR BYTE
OP VAR BYTE
NUM2 VAR BYTE
TOTAL VAR BYTE
MAIN:
PAUSE 7000
SEROUT2 PORTA.0, 16780, ["Please send NUM1", 10, 13]
PAUSE 500
HIGH PORTA.5 'Shows data sent
PAUSE 1000
LOW PORTA.5
PAUSE 250
SERIN2 PORTA.2, 16780, [DEC NUM1]'MODE 16780 = 2400 BAUD INVERTED
PAUSE 500
HIGH PORTA.5 'Shows data arrived
PAUSE 1000
LOW PORTA.5
PAUSE 250
SEROUT2 PORTA.0, 16780, ["Please send Operator + - * /", 10, 13]
PAUSE 500
HIGH PORTA.5 'Shows data sent
PAUSE 1000
LOW PORTA.5
PAUSE 250
SERIN2 PORTA.2, 16780, [OP] 'MODE 16780 = 2400 BAUD INVERTED
PAUSE 500
HIGH PORTA.5 'Shows data arrived
PAUSE 1000
LOW PORTA.5
PAUSE 250
SEROUT2 PORTA.0, 16780, ["Please send NUM2", 10, 13]
PAUSE 500
HIGH PORTA.5 'Shows data sent
PAUSE 1000
LOW PORTA.5
PAUSE 250
SERIN2 PORTA.2, 16780, [DEC NUM2]'MODE 16780 = 2400 BAUD INVERTED
PAUSE 500
HIGH PORTA.5 'Shows data arrived
PAUSE 1000
LOW PORTA.5
Select case OP
CASE "+"
TOTAL = NUM1 + NUM2
CASE "-"
TOTAL = NUM1 - NUM2
CASE "*"
TOTAL = NUM1 * NUM2
CASE "/"
TOTAL = NUM1 / NUM2
END SELECT
pause 250
SEROUT2 PORTA.0, 16780, [DEC TOTAL, 10,13]
PAUSE 250
GOTO MAIN
Bookmarks