I need to configure an i2c lcd unit using a repeated start procedure in a non interrupt mode.
I have looked at the i2c driverlib examples and still do not have a clear direction
On the MSP432P401R processor, i used the following driverlib code.
void LCDinit(void)
{
// Put the Slave Address on the bus for Write
MAP_I2CMasterSlaveAddrSet(I2C2_BASE, SlaveAddress, false);
// Set Master to transmit mode
MAP_I2C_setMode(EUSCI_B1_BASE, EUSCI_B_I2C_TRANSMIT_MODE);
my48Mdelayms(40); // Delay for 40ms upon power up or reset
MAP_I2C_masterSendMultiByteStart(EUSCI_B1_BASE, 0x00); // Send start, address and Command mode byte (0x40)
MAP_I2C_masterSendMultiByteNext(EUSCI_B1_BASE, 0x38); //Function set - 8 bit, 2 line display 5x8, inst table 0
my48Mdelayms(10);
MAP_I2C_masterSendMultiByteNext(EUSCI_B1_BASE, 0x39); //Function set - 8 bit, 2 line display 5x8, inst table 1
my48Mdelayms(10);
MAP_I2C_masterSendMultiByteNext(EUSCI_B1_BASE, 0x14); // Set bias - 1/5
MAP_I2C_masterSendMultiByteNext(EUSCI_B1_BASE, 0x78); // Set contrast low
MAP_I2C_masterSendMultiByteNext(EUSCI_B1_BASE, 0x5E); // ICON disp on, Contrast high byte
MAP_I2C_masterSendMultiByteNext(EUSCI_B1_BASE, 0x6D); // Follower circuit (internal), amp ratio (6)
my48Mdelayms(300);
MAP_I2C_masterSendMultiByteNext(EUSCI_B1_BASE, LCDDISP_ON); // Display on, cursor on 0x0E
MAP_I2C_masterSendMultiByteNext(EUSCI_B1_BASE, CLEAR_DISPLAY); // Clear display
my48Mdelayms(2);
MAP_I2C_masterSendMultiByteNext(EUSCI_B1_BASE, 0x06); // Entry mode set - increment
my48Mdelayms(2);
MAP_I2C_masterSendMultiByteStop(EUSCI_B1_BASE); // End Transmission
}
Without using the FIFO
Can i implement it as follows?
DEVICE_DELAY_US(40000); // 40000us = 40ms
I2C_setSlaveAddress(I2CA_BASE, LCD_SLAVE_ADDRESS); // Setup slave address: LCD_SLAVE_ADDRESS defined as 0x78
I2C_setDataCount(I2CA_BASE, 1); // Setup number of bytes to send msgBuffer and address
I2C_putData(I2CA_BASE, 0x00); // Send start, address and Command mode byte (0x00)
I2C_setConfig(I2CA_BASE, I2C_MASTER_SEND_MODE | I2C_REPEAT_MODE);
I2C_sendStartCondition(I2CA_BASE);
- Will the following automatically complete the process:
I2C_putData(I2CA_BASE, 0x38); //Function set - 8 bit, 2 line display 5x8, inst table 0
while(I2C_isBusBusy(I2CA_BASE)); // Wait until transfer done
DEVICE_DELAY_US(10000); // Delay 10000us = 10ms
I2C_putData(I2CA_BASE, 0x39); //Function set - 8 bit, 2 line display 5x8, inst table 1
while(I2C_isBusBusy(I2CA_BASE)); // Wait until transfer done
DEVICE_DELAY_US(10000); // Delay 10000us = 10ms
............................
and finally:
I2C_putData(I2CA_BASE, 0x06); // Entry mode set - increment
while(I2C_isBusBusy(I2CA_BASE)); // Wait until transfer done
DEVICE_DELAY_US(2000); // Delay 2000us = 2ms
I2C_sendStopCondition(I2CA_BASE);
OR i have to be using " I2C_sendStartCondition(I2CA_BASE);" after each "I2C_putData(I2CA_BASE, ...)
function call.
Thanks
David Nyarko