I2C interface Problem with I/O port [Solved]
Posted: Tue Dec 06, 2016 5:04 pm
Hi
I am building some battery operated radio synchronised clocks for Christmas presents (and its getting close!). I abandonned this a couple of years ago because excessive clock time errors + the effects of noise + excessive coding complexity (especially the last one!) stopped it being fun. Now, with a new clock chip and better algorithms and coding clarity from Flowcode, its nearly finished.
I'm using the 18F45K22.
The clock has three seven-segment displays for time and other data; these are driven by I2C chips (PCF8577C) and these work fine. It also has an LED array that can display calendar and other data in BCD format; these are driven by I2C chips (PCA9555DB) and I cannot get data into them. The chips return a zero after they have been addressed suggesting to me that I am using the correct address. I have previously managed to have this interface working fine using Mikro C, using:
I2C2_Start();
I2C2_Wr(0b01000000); // send device address + Write (integrated circuit U5)
I2C2_Wr(0x02); // address of next word (portA output)
I2C2_Wr(IO0); // data output to bank 0
I2C2_Wr(IO1); // data output to bank 1
I2C2_Repeated_Start();
I2C2_Wr(0b01000010); // send device address + Write (integrated circuit U7)
I2C2_Wr(0x02); // address of next word
I2C2_Wr(IO2); // data output to bank 0
I2C2_Wr(IO3); // data output to bank 1
I2C2_Stop();
Loading from Flowcode into a known working MikroC-programmed clock also does not work (so its not the hardware).
I have completely re-written the program in Flowcode (attached), which has a test loop near the beginning of Main().
It all works except for the LED array.
The I2C code near the end of paintLCDDisplay() (to send data to the LCDs) and that near the end of collectMSFDateTimeCode() (loads date/time into the real time clock chip DS3231) both work fine.
The only real difference in structure is that the LED control uses I2C2, whereas the others use I2C1.
Can anyone help, please?
Jim
I am building some battery operated radio synchronised clocks for Christmas presents (and its getting close!). I abandonned this a couple of years ago because excessive clock time errors + the effects of noise + excessive coding complexity (especially the last one!) stopped it being fun. Now, with a new clock chip and better algorithms and coding clarity from Flowcode, its nearly finished.
I'm using the 18F45K22.
The clock has three seven-segment displays for time and other data; these are driven by I2C chips (PCF8577C) and these work fine. It also has an LED array that can display calendar and other data in BCD format; these are driven by I2C chips (PCA9555DB) and I cannot get data into them. The chips return a zero after they have been addressed suggesting to me that I am using the correct address. I have previously managed to have this interface working fine using Mikro C, using:
I2C2_Start();
I2C2_Wr(0b01000000); // send device address + Write (integrated circuit U5)
I2C2_Wr(0x02); // address of next word (portA output)
I2C2_Wr(IO0); // data output to bank 0
I2C2_Wr(IO1); // data output to bank 1
I2C2_Repeated_Start();
I2C2_Wr(0b01000010); // send device address + Write (integrated circuit U7)
I2C2_Wr(0x02); // address of next word
I2C2_Wr(IO2); // data output to bank 0
I2C2_Wr(IO3); // data output to bank 1
I2C2_Stop();
Loading from Flowcode into a known working MikroC-programmed clock also does not work (so its not the hardware).
I have completely re-written the program in Flowcode (attached), which has a test loop near the beginning of Main().
It all works except for the LED array.
The I2C code near the end of paintLCDDisplay() (to send data to the LCDs) and that near the end of collectMSFDateTimeCode() (loads date/time into the real time clock chip DS3231) both work fine.
The only real difference in structure is that the LED control uses I2C2, whereas the others use I2C1.
Can anyone help, please?
Jim