AnsweredAssumed Answered

I2C with MCCOG21605B6W 16 Character LCD

Question asked by tan.yu_ang on Jan 8, 2014
Latest reply on Feb 20, 2014 by tan.yu_ang
Hello all,

I am using the STM32VLDISCOVERY board which has a STM32F10x controller. I am trying to communcate with the LCD, but I am facing problems. Here is my code:

// Master mode
I2C1->CR2 |= 8;                 // 8MHz min frequency
I2C1->CCR |= I2C_CCR_FS;        // Clock control register
I2C1->CCR |= 350;               // Clock control register
I2C1->TRISE = 9;                // Rise time register
I2C1->CR1 |= I2C_CR1_PE;        // Enable peripheral
 
 
// Start transmission
I2C1->CR1 |= I2C_CR1_START;
while (!(I2C1->SR1 & I2C_SR1_SB)) ;
 
//EV5 - Read SR1 followed by writing address to DR register
(void) I2C1->SR1;  
I2C1->DR = 124;
 
//EV6 - ADDR = 1
// Read SR1 followed by SR2
while (!(I2C1->SR2 & I2C_SR1_ADDR)) ;
(void) I2C1->SR1;   //EV6
(void) I2C1->SR2;   //EV6
 
// EV8 - TxE = 1
// Write Data1 in DR register
while (!(I2C1->SR1 & I2C_SR1_TXE)) ;
I2C1->DR = data_i2c3;
 
// EV8_1 - TxE = 1
// Write into DR register
while (!(I2C1->SR1 & I2C_SR1_TXE)) ; /*<--Stuck at this line-->*/
I2C1->DR = data_i2c3;
 
I2C1->CR1 |= I2C_CR1_STOP;


The code always stalls at the waiting loop at EV8_1. Looking into the scope, it appears that Data1 was not transmitted at all. Only the address byte was sent and acknowledged. Am I overlooking something?
It's been a long day trying to troubleshoot this problem; any form of help would be greatly appreciated. Thanks in advance.
     
I2CTtrace.jpg

Outcomes