Hi! Spent long time and no result with seemingly simple issue. I am talking to MPR121 and trying to get at least something to work I2C communication works, chips acknowledges any requests to address 0x5A. But whatever registers I read, result is zero. All I2C stack I use is known to work for writing data. I include oscillogram, maybe someone can spot something just obviously wrong. I am trying to read register 0x5D because it must be non-zero by default. I tried also read all registers from 0 to 255 and nothing returns any bits.
HalTouchSelect();
while(1) {
uint8 pBuf2;
bool r2= HalSensorReadReg(0x5D, &pBuf2,1);
ST_HAL_DELAY(3000);
// char buf[20];
// sprintf(buf," %3d %d %3d ",pBuf2,r2,i++);
// OLED_text(buf,0,0) ;
}
Same thing enlarged:
Chip is alive and sends acknowledges but never returns any data. Ideas?
EDIT: Have tried to insert delays, change communication speed, re-read everything. No help. Then I attached Arduino with some sample code to same bus and MPR121 register 0x5D instantly read 0000 0100. So hardware problems possibly ruled out.
解決済! 解決策の投稿を見る。
Hi Tõnu,
You are not able to read from the MPR021 because you send the stop condition (a LOW to HIGH transition of SDA while SCL is HIGH) instead of sending the repeated start condition. You will have to modify your I2C read routine so that SDA transitiones to HIGH before the SCL goes HIGH (in order to eliminate the stop condition) that is indicated in the waveform.
I hope it helps.
Regards,
Tomas
Thanks! I have been spending hours here and at first sight you seem to have correct answer. Simple things can be complicated to solve sometime.
You are very welcome, Tõnu and thanks for using our community.
Regards,
Tomas
Hi Tõnu,
You are not able to read from the MPR021 because you send the stop condition (a LOW to HIGH transition of SDA while SCL is HIGH) instead of sending the repeated start condition. You will have to modify your I2C read routine so that SDA transitiones to HIGH before the SCL goes HIGH (in order to eliminate the stop condition) that is indicated in the waveform.
I hope it helps.
Regards,
Tomas