Hi all,
I've just got hold of a copy David Lincolin's book on the picaxe (second Edition) and attached is the file for the I2C I/O expansion test routine, it complies ok but the when I run the simulator I get the error shown in the photo. Any ideas?
I've just got hold of a copy David Lincolin's book on the picaxe (second Edition) and attached is the file for the I2C I/O expansion test routine, it complies ok but the when I run the simulator I get the error shown in the photo. Any ideas?
Code:
'I2C I/O expantion MCP23017 - Test Routine
#picaxe 18X
#freq m4
#gosubs 256
#no_data
symbol MCP23017 = %01000000 'Address code for MCP23017, address 000
symbol IOCON0 = $0A 'I/O control register address for bank = 0 (PowerOn default)
symbol GPIOA = $09 'GP I/O port register
symbol GPPU = $06 'GP port pull-ups
symbol IPOL = $01 'Input port polarity
symbol GPIOB = $19 'Port B data register in 8-bit mode
symbol IODIRB = $10 'Port B direction register in 8-bit mode
symbol BANK1 = %10000000 'Bank bit for 8-bit mode
symbol i2c_data = b0 'Working register for I2C data
i2cwrite IOCON0, (BANK1) 'Set the Bank bit in IOCON for 8-bit mode
i2cwrite IODIRB, (0) 'Set port B to outputs
i2cwrite GPPU, ($FF) 'Set port A pull-ups on
i2cwrite IPOL, ($FF) 'Set port A polarity
do 'Read byte from Port A and copy to Port B
i2cread GPIOA, (i2c_data) 'Read Port A
i2cwrite GPIOB, (i2c_data) 'Write the data to port B
loop
Attachments
-
310.3 KB Views: 14
Last edited: