Part Number: TMS320F280049
Other Parts Discussed in Thread: C2000WARE, PCF8574
#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) {}
}