Part Number: EK-TM4C123GXL
I'm trying to configure my TM4C as a slave to use with a Raspberry Pi 3 master for I2C. I'm using direct register access instead of TivaWare. I can't find any documentation on this. I used the following code but it isn't writing to the I2C registers in the debugger. I tried writing to the SCSR register to enable it as a slave but it remains 0. Is there something I am missing in initialization?
// I2C0SCL connected to PB2
// I2C0SDA connected to PB3
void I2C_Slave_Init(void){
SYSCTL_RCGCI2C_R |= 0x0001; // activate I2C0
SYSCTL_RCGCGPIO_R |= 0x0002; // activate port B
while((SYSCTL_PRGPIO_R&0x0002) == 0){};// ready?
GPIO_PORTB_AFSEL_R |= 0x0C; // 3) enable alt funct on PB2,3
GPIO_PORTB_ODR_R |= 0x08; // 4) enable open drain on PB3 only
GPIO_PORTB_DEN_R |= 0x0C; // 5) enable digital I/O on PB2,3
// 6) configure PB2,3 as I2C
GPIO_PORTB_PCTL_R = (GPIO_PORTB_PCTL_R&0xFFFF00FF)+0x00003300;
GPIO_PORTB_AMSEL_R &= ~0x0C; // 7) disable analog functionality on PB2,3
I2C0_SCSR_R |= 0x01; // enable slave
I2C0_SOAR_R = (I2C0_SOAR_R & ~0x7F)| 0x3C; // 9) slave address
}