This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F280049: LCD2004 display problems

Part Number: TMS320F280049
Other Parts Discussed in Thread: C2000WARE, PCF8574

Init.h

#include "F28x_Project.h"
#include "Init.h"

void main(void)
{
    // 初始化系统控制、GPIO和I2C
    InitSysCtrl();
    Init_GPIO();
    Init_I2C();

    // 设置I2C从机地址
    I2caRegs.I2CSAR.all = 0x27; // 修正为0x27

    // 设置光标到第二行的第一个位置
    I2caRegs.I2CCNT = 1;
    I2caRegs.I2CDXR.all = 0xC0; // 设置地址为0xC0

    // 发送字符 A 到 LCD
    I2caRegs.I2CCNT = 1;
    I2caRegs.I2CDXR.all = 'A'; // 发送字符 A

    // 设置I2C传输模式
    I2caRegs.I2CMDR.bit.MST = 1;
    I2caRegs.I2CMDR.bit.TRX = 1;
    I2caRegs.I2CMDR.bit.STT = 1;

    // 等待传输完成
    while (I2caRegs.I2CSTR.bit.BB == 1) {}

    // 停止I2C传输
    I2caRegs.I2CMDR.bit.STP = 1;

    // 此处可以添加其他操作或循环

    while (1) {}
}

HI,I have a few questions to ask about LCD2004 with PCF8574T communication to F280049 use I2C, we want to send a letter or numbers from F280049 GPIO26(SDA)、GPIO27(SCL) to let it display on screen of LCD2004, but we notice that there is no library of LCD to use in C2000,so I give it a try, but nothing happened, could it be possible the problem is in the PCF8574T? and below is my code,can you help me to find out where are the problems or something I need to add in the code,thanks! (IF there is anything we can take it as a reference,please tell me,thanks!)

//main.c

#include "F28x_Project.h"
#include "Init.h"

void main(void)
{
// Initialize system control, GPIO, and I2C
InitSysCtrl();
Init_GPIO();
Init_I2C();

// Set I2C slave address
I2caRegs.I2CSAR.all = 0x27; // Corrected to 0x27

// Set cursor to the first position of the second line
I2caRegs.I2CCNT = 1;
I2caRegs.I2CDXR.all = 0xC0; // Set address to 0xC0

// Send character 'A' to the LCD
I2caRegs.I2CCNT = 1;
I2caRegs.I2CDXR.all = 'A'; // Send character 'A'

// Set I2C transfer mode
I2caRegs.I2CMDR.bit.MST = 1;
I2caRegs.I2CMDR.bit.TRX = 1;
I2caRegs.I2CMDR.bit.STT = 1;

// Wait for transfer completion
while (I2caRegs.I2CSTR.bit.BB == 1) {}

// Stop I2C transmission
I2caRegs.I2CMDR.bit.STP = 1;

// Additional operations or loops can be added here

while (1) {}
}

  • Hello,

    We do not have libraries for communicating with an LCD screen using I2C. There are existing examples for I2C in C2000Ware_5_02_00_00\driverlib\f28004x\examples\i2c within C2000Ware. You can use those examples as templates to set up the I2C peripheral and communicate with it.

    Unfortunately there is not enough information provided in your post for me to help further. You will need to thoroughly debug your program, the communication transmit/receive frame, etc. to find out why the LCD is not responding to I2C communication, this is not something I can verify on my side. Verify that the SCL and SDA are what you expect, look for NACKs, watch status bits, and perform other debug steps before proceeding. Once you have narrowed down the source of the problem let me know.

  • Hi Wang,

    Omar mentions to debug i2C peripheral use CCS register view and consult x49c MCU Technical Resource Manual (TRM) to properly configure i2C for PCF8574. About the graphics character generator, may require some C programming, not just port letter 'A" serial data to i2C remote port. The below article link may help to answer some questions. 

    Arduino LCD 20x4 I2C Example (LCD 2004 I2C Tutorial) (deepbluembedded.com)

  • Thanks for the advice, by the way I've seen the example like this before, but I don't find any of the valid address for me to let the sentence display on the screen of the LCD(because they are all for arduino, I don't know whether is useful or not ).

  • Hello Mr. Amir,

    Thank you for your advice. We have researched some information and made revisions to some of the code. Additionally, we have checked the status of the register and discovered that GPIO27 and GPIO26 contain data (GMUX and MUX, which determine the function of the GPIO, specifically I2C SDA and I2C SCL). However, despite this, nothing is displaying on the LCD screen.

    We suspect the issue may lie with the address, as we have not informed the LCD where to display the information. Upon examining other examples of Arduino LCD usage, we found that they all utilize the cursor library. In cases where it is not used, they still initialize the cursor prior to inputting the displayed value or data.

    Do you have any suggestions on how to set the cursor without using the library, or how to inform the LCD where to display the data in the designated location?

    Additionally, we are unsure how to verify if the LCD has indeed received the data and in the correct order. Since the LCD only has four pins (VCC, GND, SDA, SCL), we are unable to check without the display, which is our primary challenge at the moment.

    and here the datasheet it might be useful:

    PCF8574 Remote 8-Bit I/O Expander for I2C Bus datasheet (Rev. J)

    TMS320F28004x Real-Time Microcontrollers Technical Reference Manual (Rev. G)

    TMS320F28004x Real-Time Microcontrollers datasheet (Rev. G)

    Thank you for your time and helping, Mr. Amir.

    I2C_retry.zip

  • Hello Wang,

    To expand on what I had stated in my initial post, unless there is a problem with the I2C peripheral or the F28004x device itself, there is no support TI can provide. The LCD2004 and PCF8574T are not TI products and as such we have no active support for them.

    If you believe the problem lies with the I2C communication itself, then you need to use a communication analyzer to verify how the I2C peripheral is behaving incorrectly. Let me know if you are able to verify this, otherwise you will need to get support from a more general engineering forum as E2E is focused on support for TI devices themselves.

  • I think you need to import functions via character library CCS project. Github has the library open source, likely written C++ so it may take some rewrites in some functions. The PCF8574 only converts serial data for the LCD input parallel address matrix, it does not contain predefined ASCII character cells. Hence LCD needs input from MCU to form each letter by turning on/off each dot. Code can then output simple text using a string or single letters as you are trying to do above but call the function in the imported library.