Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Nzoka

Pages: [1]
1
Posting this to help others trying to use this LCD.

This was my setup as per page 4 of the LCD Data sheet,
I have C = 1uF, 16V. 
R (The pullups) on SDA and SCL are 10kohms each.
I have a 1kohm pullup on RST and a 1kohm resistor from the Anode of the backlight to the 3.19V power supply.
I have a 0.1uF bypass capacitor across Vdd and Vss.

SDA is connected to P6.4 of the Launchpad
SCL is connected to P6.5 of the Launchpad
I set up my board to run at 48Mhz
After setting up EUSCI_B1_BASE,
the following can be used:
*********************************
// I2C LCD Slave address
#define SLAVE_ADDRESS   0x3C    // 0x3C = (0x78<<1) since i2c sends 7 bit address

#define LCDCOMMANDMODE   0x00
#define LCDDATAMODE      0x40

#define LINEONE         0x00
#define LINETWO         0xC0

unsigned char text1[]={"NEWHAVEN DisplayXXXX"};
unsigned char text2[]={"2x20 LCD Module XXXX"};


void LCDinit();
void LCDsendLinenum(unsigned char linenum);
void LCDsendData( unsigned int bufferlength, unsigned char *buffer);
void LCDsendCommand( unsigned int bufferlength, unsigned char *buffer);

void my48Mdelayms(unsigned int x); // Crude millisecond delay function based on MCLK of 48Mhz

void LCDinit()
{
        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, 0x0E);  // Display on, cursor on 0x0C
        MAP_I2C_masterSendMultiByteNext(EUSCI_B1_BASE, 0x01);  // 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


}

void LCDsendCommand( unsigned int bufferlength, unsigned char *buffer)
{
    unsigned int i;
    MAP_I2C_masterSendMultiByteStart(EUSCI_B1_BASE, LCDCOMMANDMODE); // Send start, address and Command mode byte
    for(i = 0 ; i < bufferlength; i++)
    {
        MAP_I2C_masterSendMultiByteNext(EUSCI_B1_BASE, buffer);
    }
    MAP_I2C_masterSendMultiByteStop(EUSCI_B1_BASE);  // End Transmission

}

void LCDsendData( unsigned int bufferlength, unsigned char *buffer)
{
    unsigned int i;
    MAP_I2C_masterSendMultiByteStart(EUSCI_B1_BASE, LCDDATAMODE); // Send start, address and Data mode byte
    for(i = 0 ; i < bufferlength; i++)
    {
        MAP_I2C_masterSendMultiByteNext(EUSCI_B1_BASE, buffer);
    }
    MAP_I2C_masterSendMultiByteStop(EUSCI_B1_BASE);  // End Transmission

}



void LCDsendLinenum(unsigned char linenum)
{
    unsigned char buff[1];
    buff[0] = linenum;

    LCDsendCommand(1, buff);

}




void my48Mdelayms(unsigned int x)
{
    unsigned int i;

    for (i = 0; i< x; i++)
    {
        __delay_cycles(48000) ;
    }

}


main()
{
-- Initialize launchpad
-- Initialize IC2 and enable it for transmit mode.

    LCDinit();  // I2C LCD initialization

    LCDsendLinenum(LINEONE);    // Start displaying at line 1
    LCDsendData( 20, text1);

    LCDsendLinenum(LINETWO);    // Start displaying at line 2
    LCDsendData( 20, text2);


}

2
Hi,
First time using i2C.  As per page 4 of the Data sheet,
I have C = 1uF, 16V. 
R (The pullups) on SDA and SCL are 10kohms each.
I have a 1kohm pullup on RST and a 1kohm resistor from the Anode of the backlight to the 3.19V power supply.
I have a 0.1uF bypass capacitor across Vdd and Vss.

I am single stepping through my code and have a breakpoint set at 'line 1)' below

#define SLAVE_ADDRESS        0x78
....................................
 1)   MAP_I2C_masterSendSingleByte(EUSCI_B1_BASE, SLAVE_ADDRESS);
  2)  MAP_I2C_masterSendSingleByte(EUSCI_B1_BASE, 0x00);

When i step through at line 1, program does not exit to line 2
On halting, the code is hung up at last line in the module segment shown below.
*************
void I2C_masterSendSingleByte(uint32_t moduleInstance, uint8_t txData)
{
    //Store current TXIE status
    uint16_t txieStatus = EUSCI_B_CMSIS(moduleInstance)->rIE.r & UCTXIE;

    //Disable transmit interrupt enable
    BITBAND_PERI(EUSCI_B_CMSIS(moduleInstance)->rIE.r,UCTXIE_OFS) = 0;

    //Send start condition.
    EUSCI_B_CMSIS(moduleInstance)->rCTLW0.r |= UCTR + UCTXSTT;

    //Poll for transmit interrupt flag.
    while (!(EUSCI_B_CMSIS(moduleInstance)->rIFG.r & UCTXIFG))
        ;

    //Send single byte data.
    EUSCI_B_CMSIS(moduleInstance)->rTXBUF.r = txData;

    //Poll for transmit interrupt flag.
    while (!(EUSCI_B_CMSIS(moduleInstance)->rIFG.r & UCTXIFG))
        ;
*******************
Attached is a screenshot when i execute line 1 (MAP_I2C_masterSendSingleByte(EUSCI_B1_BASE, SLAVE_ADDRESS);)
Top plot is SCL
Bottom plot is SDA


These are voltage measurements
RST (Pin1)  3.187 V
VDD (Pin5) 3.188 V
VOUT (Pin6) 2.82 V
C1+ (Pin7) 3.17 V
C1- (Pin8) 0.015 V

A - 2.5 V
K - 0 V




Pages: [1]