Hello,
About 1 month ago i ask your help for initializing an round display for a smartwatch.
Now i am trying to make the touchscreen work but i had no luck.
Its datasheet is not very explicit. I am using I2C for it, but i have some questions:
Its address is : 1000100, with a R/W bit, R=0,W=1 and 8 bits after that should be the read value.
I will attach the datasheet.
My code is a little bit complex (got over 2500 lines) so it doesn t make sense to post it all.
My touchscreen is connected to PB2 and PB3. So its I2C0 module.
#define SLAVE_ADDRESS 0x8C void I2C_Init() { ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); //Enable GPIOB// this line is not actually here, its in the main ROM_SysCtlPeripheralEnable (SYSCTL_PERIPH_I2C0); GPIOPinTypeI2CSCL(GPIO_PORTB_BASE, GPIO_PIN_2); GPIOPinTypeI2C(GPIO_PORTB_BASE, GPIO_PIN_3); GPIOPinConfigure (GPIO_PB2_I2C0SCL); GPIOPinConfigure (GPIO_PB3_I2C0SDA); I2CMasterInitExpClk(I2C0_BASE, SysCtlClockGet(), false); //DE CE TRUW!?!?!? I2CMasterEnable (I2C0_BASE); } uint32_t I2CReceive(uint32_t slave_addr, uint8_t reg) { //specify that we are writing (a register address) to the //slave device I2CMasterSlaveAddrSet(I2C0_BASE, slave_addr, false); //specify register to be read I2CMasterDataPut(I2C0_BASE, reg); //send control byte and register address byte to slave device I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_SINGLE_SEND); //wait for MCU to finish transaction while(I2CMasterBusy(I2C0_BASE)); //specify that we are going to read from slave device I2CMasterSlaveAddrSet(I2C0_BASE, slave_addr, true); //send control byte and read from the register we //specified I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_SINGLE_RECEIVE); //wait for MCU to finish transaction while(I2CMasterBusy(I2C0_BASE)); //return data pulled from the specified register return I2CMasterDataGet(I2C0_BASE); }
This function I2CReceive(SLAVE_ADDRESS,reg); returns always the same value no matter where i touch the CTP (Capacitive Touchscreen Panel). Can anyone help me? Some ideas?
Thank you! I don t have an oscilloscope right now so i can view the signals.