Mirroring I2C on PIC16LF18346
Hi
I'm trying to get an I2C signal mirrored to other pins using the CLC modules using assembly on a PIC16LF18346. Naively, I've configured each of the four input gates to use two inputs each that use the SCL2 for both inputs in CLC1 and SDA2 for both inputs in CLC2. The four gates are then fed into a 4-input AND gate and sent to RC6 or RC7. I thought this would be the best scenario to ensure that the signal is correct, even if heavily repetitive. I'm using MPLAB X IDE v5.25 and MCC to generate C code (haven't found how to get it to do assembly yet) that I've lifted and placed into my code. I've attached the graphical configuration for reference. The code it generates is as follows:
void CLC1_Initialize(void)
{
// Set the CLC1 to the options selected in the User Interface
// LC1G1POL not_inverted; LC1G2POL not_inverted; LC1G3POL not_inverted; LC1G4POL not_inverted; LC1POL not_inverted;
CLC1POL = 0x00;
// LC1D1S SCL2;
CLC1SEL0 = 0x14;
// LC1D2S SCL2;
CLC1SEL1 = 0x14;
// LC1D3S SCL2;
CLC1SEL2 = 0x14;
// LC1D4S SCL2;
CLC1SEL3 = 0x14;
// LC1G1D3N disabled; LC1G1D2N disabled; LC1G1D4N disabled; LC1G1D1T enabled; LC1G1D3T disabled; LC1G1D2T enabled; LC1G1D4T disabled; LC1G1D1N disabled;
CLC1GLS0 = 0x0A;
// LC1G2D2N disabled; LC1G2D1N disabled; LC1G2D4N disabled; LC1G2D3N disabled; LC1G2D2T enabled; LC1G2D1T enabled; LC1G2D4T disabled; LC1G2D3T disabled;
CLC1GLS1 = 0x0A;
// LC1G3D1N disabled; LC1G3D2N disabled; LC1G3D3N disabled; LC1G3D4N disabled; LC1G3D1T enabled; LC1G3D2T enabled; LC1G3D3T disabled; LC1G3D4T disabled;
CLC1GLS2 = 0x0A;
// LC1G4D1N disabled; LC1G4D2N disabled; LC1G4D3N disabled; LC1G4D4N disabled; LC1G4D1T enabled; LC1G4D2T enabled; LC1G4D3T disabled; LC1G4D4T disabled;
CLC1GLS3 = 0x0A;
// LC1EN enabled; INTN disabled; INTP disabled; MODE 4-input AND;
CLC1CON = 0x82;
}
void CLC2_Initialize(void)
{
// Set the CLC2 to the options selected in the User Interface
// LC2G1POL not_inverted; LC2G2POL not_inverted; LC2G3POL not_inverted; LC2G4POL not_inverted; LC2POL not_inverted;
CLC2POL = 0x00;
// LC2D1S SDA2;
CLC2SEL0 = 0x15;
// LC2D2S SDA2;
CLC2SEL1 = 0x15;
// LC2D3S SDA2;
CLC2SEL2 = 0x15;
// LC2D4S SDA2;
CLC2SEL3 = 0x15;
// LC2G1D3N disabled; LC2G1D2N disabled; LC2G1D4N disabled; LC2G1D1T enabled; LC2G1D3T disabled; LC2G1D2T enabled; LC2G1D4T disabled; LC2G1D1N disabled;
CLC2GLS0 = 0x0A;
// LC2G2D2N disabled; LC2G2D1N disabled; LC2G2D4N disabled; LC2G2D3N disabled; LC2G2D2T enabled; LC2G2D1T enabled; LC2G2D4T disabled; LC2G2D3T disabled;
CLC2GLS1 = 0x0A;
// LC2G3D1N disabled; LC2G3D2N disabled; LC2G3D3N disabled; LC2G3D4N disabled; LC2G3D1T enabled; LC2G3D2T enabled; LC2G3D3T disabled; LC2G3D4T disabled;
CLC2GLS2 = 0x0A;
// LC2G4D1N disabled; LC2G4D2N disabled; LC2G4D3N disabled; LC2G4D4N disabled; LC2G4D1T enabled; LC2G4D2T enabled; LC2G4D3T disabled; LC2G4D4T disabled;
CLC2GLS3 = 0x0A;
// LC2EN enabled; INTN disabled; INTP disabled; MODE 4-input AND;
CLC2CON = 0x82;
}
RC6PPS = 0x04; //RC6->CLC1:CLC1OUT;
RC7PPS = 0x05; //RC7->CLC2:CLC2OUT;
and this is to mirror SCL2 to RC6 and SDA2 to RC7. Now I'm confused as the user manual describes SCL2 and SDA2 to be 0x1A and 0x1B respectively according to page 163 and this is what I use in my program with I2C2 working as it should. I've tried both configurations to no avail.
My assembly configuration is:
banksel PORTC
movlw 0x00
movwf PORTC
banksel LATC
clrf LATC
banksel TRISC
movlw 0x00
movwf TRISC
banksel ANSELC
clrf ANSELC
banksel WPUC
movlw 0x00
movwf WPUC
banksel ODCONC
movlw 0x00
movwf ODCONC
; CLC Config
banksel CLC1POL
clrf CLC1POL
; movlw 0x14
movlw 0x1A
movwf CLC1SEL0
movwf CLC1SEL1
movwf CLC1SEL2
movwf CLC1SEL3
movlw 0x0A
movwf CLC1GLS0
movwf CLC1GLS1
movwf CLC1GLS2
movwf CLC1GLS3
movlw 0x82
movwf CLC1CON
banksel CLC2POL
clrf CLC2POL
; movlw 0x15
movlw 0x1B
movwf CLC2SEL0
movwf CLC2SEL1
movwf CLC2SEL2
movwf CLC2SEL3
movlw 0x0A
movwf CLC2GLS0
movwf CLC2GLS1
movwf CLC2GLS2
movwf CLC2GLS3
movlw 0x82
movwf CLC2CON
banksel RC6PPS
movlw 0x04
movwf RC6PPS
movlw 0x05
movwf RC7PPS
Just to be clear, I am getting correct communication signals from I2C2 but nothing is coming out of pins RC6/RC7. I can appreciate that on the surface there may be no inherent point in doing this; however, I'm trying to build a proof of concept so that I am able to mirror and show signals from other peripherals that I don't have direct access to via on-board test points.
Attached Image(s)
