I have a bunch of LEDs with anodes tied to Vcc through resistors. The cathodes are tied to the outputs of an MCP23107 port expander. I'm using the same setup I had for Arduino that worked, so I know this setup works.
Trying to get it going in Pic Basic Pro is not working. I have simplified my program to very, very basics to eliminate any "distractions". Here it is:
Code:
#config
__CONFIG _CONFIG1, _HS_OSC & _WDT_ON & _PWRTE_ON & _MCLRE_OFF & _CPD_OFF & _BOR_ON & _IESO_ON & _FCMEN_ON & _LVP_OFF
__CONFIG _CONFIG2, _BOR40V & _WRT_OFF
#endconfig
define LOADER_USED 1
DEFINE OSC 4 '4 MHz crystal on LabX1, not the processor speed
'TRISC = %00000000
SDA VAR PORTC.4 'i2c data line, 16F887
SCL VAR PORTC.3 'i2c clock line 16F887
addr var byte 'address of port expander
INIT:
addr = $42
I2CWRITE SDA,SCL,addr,[$00,$00] 'set for all output
MAIN:
I2CWRITE SDA,SCL,addr,[$09, $00]
pause 100
I2CWRITE SDA,SCL,addr,[$09, $ff]
pause 100
goto main
Why doesn't this blink the LEDs I have attached to the PE. When I check voltage, it never drops to zero. I've scoped my SDA and SCL lines and they are working fine. I have 5 volts (4.9 actually) on the chip, and the address for this one is $42 (address A1 is high).
I'm using a LabX1 with 16F887 mcu. I'm expecting all the lights to blink but none do. (I've played with the GPI0 register, making it $12 instead of $09)
What am I missing? Arduino spoiled me by providing me with libraries that did all the work!
Bookmarks