I2C send only address bytes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2010-08-12 9:36 AM
I2C send only address bytes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 5:02 AM
>>What do I wrong? Is there a bug?
Probably a bug in your code, the I2C buses work fine. Try providing some code examples and the chip you are communicating with.Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 5:02 AM
The ST32 communicate with the component PCA9633 (it is a LED driver)
I have my code very simplified to find the root cause: void I2CInit(void) { RCC->APB1ENR |= 0x00400000; // Pheripherie Clk für I2C1 RCC->APB2ENR |= 0x00000008; // Pheripherie Clock für PortB freischaltenI2C2->CR1 |= 0x8000; // SWRST
I2C2->CR1 &= ~0x8000; // SWRSTI2C2->CR1 |= 0x0001; // I/O Pins für I2C einschalten (PE)
I2C2->CR2 |= 0x00000024; // FREQ = 36MHz I2C2->CCR |= 0x000000B4; // Busfrequenz = 100kHz I2C2->CR1 |= 0x0400; // ACK }-------------------------------------------------------------------------------------
int main (void) { // Slave component: PCA9633 // PB10 = SCL // PB11 = SDAI2CInit();
stm32_Init (); /* STM32 setup */ for (counter = 0; counter <=255; counter++) {I2C2->CR1 |= 0x0100; // I2C Send I2C start
delay(50000); delay(50000); I2C2->DR = 0x02; // PCA9633 slave address temp = I2C2->SR1; // Read SR register to clear ADDR temp += temp; temp = I2C2->SR2; // Read SR register to clear ADDR temp += temp;delay(50000);
delay(50000);I2C2->DR = 0x03; // PCA9633 control register
delay(50000); delay(50000);I2C2->DR = counter; // Brightness control LED0 Register
delay(50000);
delay(50000); I2C2->CR1 |= 0x0200; // I2C send stop delay(50000); delay(50000);}
}- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 5:02 AM
Hi born,
I have some proposal : - Are you sure that GPIO are correctly configured ( AF Open drain). - When communication crashs, check if flag errors(ARLO,OVR,AF,BERR) are set or no. - Change delay by waiting until TXE flag is set ( after sending one byte wait until TXE flag is equal to 1 after that send the next byte). I have some recommendation while using I2C IP : you should after each operation check if related flag are set or no to correctly manage the communication. Good Bye.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 5:02 AM
Hi,
I wrote several codes using I2C bus and I2C bus works just fine. Try to use Standardd Peripheral Examples which you can download on st.com.
Cheers,
Dragan
