This is what I get on SDA and SCL with that short program.
This is what I get on SDA and SCL with that short program.
I put a label at the end of my i2C write statement to flash an LED if there is no acknowledge from the chip.
there is NO acknowledge...the LED is flashing. So that's a result I will work with. I have extra port expanders (all pretested) and 16F887s.
Update:
Changed out port expanders: no change
Changed out 16F887: no change
Changed SDA and SCL port from PortC.4 and PortC.3 to PortA.5 and PortA.4: works. Acknowledge led is OFF>
Any insight into why PortC didn't work but PortA does? ON the LabX1, C.4 and C.3 are designated for I2C.
Last edited by queenidog; - 24th May 2018 at 17:01.
for what its worth
this works for me
Code:sda VAR PORTA.1 scl VAR PORTA.2 trisa.5=0 ' pause 2000 ' Debug "Start",13 ,10 addr var byte ;mcp control address reg var byte ;mcp register da var byte ;gpioa data da=$f8 addr = $40 reg=0 I2CWRITE SDA,SCL,addr,reg,[$00] 'set gpioa all output reg=9 LOOOP: I2CWRITE SDA,SCL,addr,reg,[da] pause 500 da=da+1 GOTO LOOOP
Warning I'm not a teacher
Despite the superiority of PBP and Mecanique IDE, working with the i2c commands is a bear! Struggled for a week on it, still no go. Went back to Arduino, and still cursing at all the syntax. However, a quick hookup and I have 80 LEDS spread across 5 boards (PCB above), running all kinds of patterns in COLOR without issue. It's basically the code I submitted (for Arduino) except the CS.digitalWrite is repeated 5 times, once for each board. I've got 20 pages of code done in Arduino, couldn't get one light to light up consistently with PBP.
Thanks anyway. Going to the Arduino forum now to find out how to create functions (subroutines) to make my code trim and proper.
would you care to provide some code to demonstrate a i2cread/write command that exhibits some problemworking with the i2c commands is a bear!
I find it always works as documented .
I suspect that you have no idea of what the centipede library actually does behind the scenes and that
you are attempting pbp code based on that total lack of understanding. maybe if you posted some code
help would be offered all we have seen so far is just totally wrong.
good luck with your endeavours on the Arduino forum , they just love posts with no code
Warning I'm not a teacher
I also found that they get arsy if you give them too much. I didn't get much joy from the three arduino forums I posted on when porting my thermostat code to the platform. They also don't provide code for you if you're stuck, they expect you to work that part out when they've told you what to do, and if you are new to the platform and still find the syntax strange.
I found the guys on this forum a lot more friendlier and supportive. It's just a shame that PBP lacks the native support for most modern things - but I2C is one of the basics and I've never had issues when using it to talk to LED driver chips etc.
Deleted, reformulated with complete code in next post.
Last edited by Demon; - 4th October 2024 at 04:59.
My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.
Not as dumb as yesterday, but stupider than tomorrow!
I cleaned my code up, so it's really apparent what I'm trying to do.
I still won't blink the 16 LEDs.
Code:#CONFIG __config _CONFIG1, _FEXTOSC_OFF & _RSTOSC_HFINT32 & _CLKOUTEN_OFF & _CSWEN_OFF & _FCMEN_ON __config _CONFIG2, _MCLRE_ON & _PWRTE_OFF & _LPBOREN_OFF & _BOREN_ON & _BORV_LO & _ZCD_OFF & _PPS1WAY_OFF & _STVREN_ON & _DEBUG_OFF __config _CONFIG3, _WDTCPS_WDTCPS_11 & _WDTE_OFF & _WDTCWS_WDTCWS_7 & _WDTCCS_LFINTOSC __config _CONFIG4, _WRT_OFF & _SCANE_available & _LVP_OFF __config _CONFIG5, _CP_OFF & _CPD_OFF #ENDCONFIG DEFINE OSC 32 define CCP1_REG 0 ' Must clear unused CCP pins or else unpredictable results DEFINE CCP1_BIT 0 define CCP2_REG 0 DEFINE CCP2_BIT 0 DEFINE CCP3_REG PORTB DEFINE CCP3_BIT 5 define CCP4_REG 0 DEFINE CCP4_BIT 0 define CCP5_REG 0 DEFINE CCP5_BIT 0 ANSELA = %00000000 ANSELB = %00000000 ANSELC = %00000000 ANSELD = %00000000 ANSELE = %00000000 TRISA = %00000000 TRISB = %00000000 TRISC = %00000000 TRISD = %00000000 TRISE = %00001000 PinSCL2 VAR PortB.1 PinSDA2 VAR PortB.2 HPWM 3, 8, 1953 addr var byte : addr = %01000000 ' $40 IOCONreg var byte : IOCONreg = $05 IOCONdat var byte : IOCONdat = %10110000 ' bit 7 1 = The registers associated with each port are separated into different banks. ' bit 6 0 = The INT pins are not connected. INTA is associated with PORTA and INTB is associated with PORTB ' bit 5 1 = Sequential operation disabled, address pointer does not increment. ' bit 4 1 = Slew rate disabled ' bit 3 0 = Disables the MCP23S17 address pins. ' bit 2 0 = Active driver output (INTPOL bit sets the polarity.) ' bit 1 0 = Active-low ' bit 0 Unimplemented: Read as ‘0’ I2CWRITE PinSDA2,PinSCL2,addr,IOCONreg,[IOCONdat] IODIRAreg var byte : IODIRAreg = $00 IODIRAdat var byte : IODIRAdat = %00000000 I2CWRITE PinSDA2,PinSCL2,addr,IODIRAreg,[IODIRAdat] 'set GPIOA all output IODIRBreg var byte : IODIRBreg = $10 IODIRBdat var byte : IODIRBdat = %00000000 I2CWRITE PinSDA2,PinSCL2,addr,IODIRBreg,[IODIRBdat] 'set GPIOB all output GPIOAreg var byte : GPIOAdat var byte GPIOBreg var byte : GPIOBdat var byte LOOOP: GPIOAreg = $09 : GPIOAdat = %00000000 I2CWRITE PinSDA2,PinSCL2,addr,GPIOAreg,[GPIOAdat] GPIOBreg = $19 : GPIOBdat = %00000000 I2CWRITE PinSDA2,PinSCL2,addr,GPIOBreg,[GPIOBdat] pause 250 GPIOAreg = $09 : GPIOAdat = %11111111 I2CWRITE PinSDA2,PinSCL2,addr,GPIOAreg,[GPIOAdat] GPIOBreg = $19 : GPIOBdat = %11111111 I2CWRITE PinSDA2,PinSCL2,addr,GPIOBreg,[GPIOBdat] pause 250 GOTO LOOOP end
The HPWM is for a IRFZ44N that i use to pulse the LED grounds. I have a simple LED on it to confirm that it's operating.
My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.
Not as dumb as yesterday, but stupider than tomorrow!
Tried with OLAT registers, no joy.
Code:#CONFIG __config _CONFIG1, _FEXTOSC_OFF & _RSTOSC_HFINT32 & _CLKOUTEN_OFF & _CSWEN_OFF & _FCMEN_ON __config _CONFIG2, _MCLRE_ON & _PWRTE_OFF & _LPBOREN_OFF & _BOREN_ON & _BORV_LO & _ZCD_OFF & _PPS1WAY_OFF & _STVREN_ON & _DEBUG_OFF __config _CONFIG3, _WDTCPS_WDTCPS_11 & _WDTE_OFF & _WDTCWS_WDTCWS_7 & _WDTCCS_LFINTOSC __config _CONFIG4, _WRT_OFF & _SCANE_available & _LVP_OFF __config _CONFIG5, _CP_OFF & _CPD_OFF #ENDCONFIG DEFINE OSC 32 define CCP1_REG 0 ' Must clear unused CCP pins or else unpredictable results DEFINE CCP1_BIT 0 define CCP2_REG 0 DEFINE CCP2_BIT 0 DEFINE CCP3_REG PORTB DEFINE CCP3_BIT 5 define CCP4_REG 0 DEFINE CCP4_BIT 0 define CCP5_REG 0 DEFINE CCP5_BIT 0 ANSELA = %00000000 ANSELB = %00000000 ANSELC = %00000000 ANSELD = %00000000 ANSELE = %00000000 TRISA = %00000000 TRISB = %00000000 TRISC = %00000000 TRISD = %00000000 TRISE = %00001000 PinSCL2 VAR PortB.1 PinSDA2 VAR PortB.2 HPWM 3, 8, 1953 addr var byte : addr = %01000000 ' $40 IOCONreg var byte : IOCONreg = $05 IOCONdat var byte : IOCONdat = %10110000 ' bit 7 1 = The registers associated with each port are separated into different banks. ' bit 6 0 = The INT pins are not connected. INTA is associated with PORTA and INTB is associated with PORTB ' bit 5 1 = Sequential operation disabled, address pointer does not increment. ' bit 4 1 = Slew rate disabled ' bit 3 0 = Disables the MCP23S17 address pins. ' bit 2 0 = Active driver output (INTPOL bit sets the polarity.) ' bit 1 0 = Active-low ' bit 0 Unimplemented: Read as ‘0’ I2CWRITE PinSDA2,PinSCL2,addr,IOCONreg,[IOCONdat] IODIRAreg var byte : IODIRAreg = $00 IODIRAdat var byte : IODIRAdat = %00000000 I2CWRITE PinSDA2,PinSCL2,addr,IODIRAreg,[IODIRAdat] 'set GPIOA all output IODIRBreg var byte : IODIRBreg = $10 IODIRBdat var byte : IODIRBdat = %00000000 I2CWRITE PinSDA2,PinSCL2,addr,IODIRBreg,[IODIRBdat] 'set GPIOB all output OLATAreg var byte : OLATAdat var byte OLATBreg var byte : OLATBdat var byte LOOOP: OLATAreg = $0A : OLATAdat = %00000000 I2CWRITE PinSDA2,PinSCL2,addr,OLATAreg,[OLATAdat] OLATBreg = $1A : OLATBdat = %00000000 I2CWRITE PinSDA2,PinSCL2,addr,OLATBreg,[OLATBdat] pause 250 OLATAreg = $0A : OLATAdat = %11111111 I2CWRITE PinSDA2,PinSCL2,addr,OLATAreg,[OLATAdat] OLATBreg = $1A : OLATBdat = %11111111 I2CWRITE PinSDA2,PinSCL2,addr,OLATBreg,[OLATBdat] pause 250 GOTO LOOOP end
My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.
Not as dumb as yesterday, but stupider than tomorrow!
It won't let me add info to my previous post above:
16F18877
MCP23017
Using 1K/130pF on SCL/SDA as mentioned on p.5 of datasheet (they use 135pF).
Last edited by Demon; - 4th October 2024 at 05:16.
My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.
Not as dumb as yesterday, but stupider than tomorrow!
Bookmarks