Below is modified code.
After re-reading (tfm) the spec i noticed that the 23016 requires: adress, command,adress (again), data, data,....
No on reset I get the no i2c ack display and I see on my oscope that there aren't quite enough bits on the data line. Then the next time the loop executes I get all expected bits on the data line, but the last two byte which I expect to be reflective of the I/O pins on the 23016 never change and are always low?
Here is the full code again:
INTCON = %10100000 ' Enable TMR0 interrupts
INTCON2 = %01000000 ' ENABLES PORTB PULL UPS
T0CON = %11010101 ' ENABLES TM0 AND SET PRESCALER
RCON = %00000000 ' IPEN RCON.7 INTERUPT PRIORITY LEVEL DISABLED
ADCON0 = %00010001 ' ATOD CH 4 CONVERTER ENABLED
ADCON1 = %00001010 ' VSS AND VDD REF LEVELS A0-A4 ANALOG A5-A12 DIG
'ADCON2 = %10000110 ' RIGHT JUST RESULT 0 TAD FOSC/64
'define I2C_SCLOUT 1 ' just messing around trying to see if I can get it to work. No change with this line included
'DEFINE I2C_HOLD 1 ' just messing around trying to see if I can get it to work. No change with this line included
DEFINE LCD_DREG PORTD ' PortD is the data port
DEFINE LCD_DBIT 0 ' PORTD.4
DEFINE LCD_RSREG PORTE ' PortE contains the Reset/Enable port
DEFINE LCD_RSBIT 0 ' PORTE.0 = reset bit
DEFINE LCD_EREG PORTE ' PortE contains the Reset/Enable port
DEFINE LCD_EBIT 1 ' PORTE.1 = ENABLE BIT
Low PORTE.2 ' LCD R/W line low (W)
Pause 500 ' Wait for LCD to start up
DEFINE ADC_BITS 10 ' Set number of bits in result
INSin var word
insin = 0
addr var byte
addr = 0
'i2cwrite portc.4, portc.3, %01000000, insin, noitwoc
LOOP:
i2cWRITE portc.4, portc.3, %01000001, $00, %01000001, insin, noitwoc
pause 10
LCDOUT $FE, 1
lcdout "IM ALIVE"
lcdout $fe, $c0
lcdout dec insin
'output porte.6
HIGH PORTJ.1
pause 250
low PORTJ.1
HIGH PORTJ.0
PAUSE 250
LOW PORTJ.0
HIGH PORTJ.2
PAUSE 250
LOW PORTJ.2
HIGH PORTJ.3
PAUSE 250
LOW PORTJ.3
HIGH PORTJ.4
PAUSE 250
LOW PORTJ.4
HIGH PORTJ.5
PAUSE 250
LOW PORTJ.5
HIGH PORTJ.6
PAUSE 250
LOW PORTJ.6
HIGH PORTJ.7
PAUSE 250
LOW PORTJ.7
HIGH PORTE.6
PAUSE 250
LOW PORTE.6
HIGH PORTE.7
PAUSE 250
LOW PORTE.7
HIGH PORTE.5
PAUSE 250
LOW PORTE.5
HIGH PORTE.4
PAUSE 250
LOW PORTE.4
HIGH PORTE.3
PAUSE 250
LOW PORTE.3
GOTO LOOP
noitwoc:
lcdout $fe, 1
lcdout "no i2c ack"
pause 2000
goto loop
END
Bookmarks