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.

[参考译文] TMS320F280025C:16 x 2第一行显示黑色框、而不显示消息

Guru**** 2392905 points
Other Parts Discussed in Thread: TMS320F280025C

请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1380273/tms320f280025c-16-by-2-first-row-show-black-boxes-and-not-show-message

器件型号:TMS320F280025C

工具与软件:

您好!

具有 TMS320F280025C 控制器的16 x 2 LCD 显示屏。 我附上了一个电路供您参考。 给出给 LCD 的电源电压为+5VDC。 但 LCD 完全空白、第一行显示黑盒。 背光工作正常。 用于调节对比度的电位计为1k。 请提供任何帮助。 我在这里编写代码供您参考。

#include "F28x_Project.h"
#include "common.h"
#include "extern.h"
#include "math.h"

void main(void)
{
    //
    // Initialize device clock and peripherals
    //
    InitSysCtrl();

    //
    // Initialize GPIO
    //
    InitGpio();

     //
    // Disable CPU interrupts
    //
    DINT;

    //
    // Initialize the PIE control registers to their default state.
    // The default state is all PIE interrupts disabled and flags
    // are cleared.
    //
    InitPieCtrl();

    //
    // Disable CPU interrupts and clear all CPU interrupt flags:
    //
    IER = 0x0000;
    IFR = 0x0000;

    //
    // Initialize the PIE vector table with pointers to the shell Interrupt
    // Service Routines (ISR).
    //
    InitPieVectTable();
 
   lcd_init();

    EALLOW;

    //
    // Enable PIE interrupt
    //
    PieCtrlRegs.PIEIER1.bit.INTx1 = 1;

    //
    // Enable global Interrupts and higher priority real-time debug events:
    //
    IER |= M_INT1;  // Enable group 1 interrupts

    EINT;           // Enable Global interrupt INTM
    ERTM;           // Enable Global realtime interrupt DBGM


    while(1)
    {
        send_string("Hello, LCD!");
        DELAY_US(1000); // Delay for 1 second
    }
}

void lcd_init(void)
{
    GpioCtrlRegs.GPBMUX1.bit.GPIO40 = 0;
    GpioCtrlRegs.GPBDIR.bit.GPIO40 = 1;
    GpioCtrlRegs.GPBMUX1.bit.GPIO41 = 0;
    GpioCtrlRegs.GPBDIR.bit.GPIO41 = 1;
    GpioCtrlRegs.GPAMUX2.bit.GPIO23 = 0;
    GpioCtrlRegs.GPADIR.bit.GPIO23 = 1;
    GpioCtrlRegs.GPAMUX2.bit.GPIO22 = 0;
    GpioCtrlRegs.GPADIR.bit.GPIO22 = 1;
    // Configure LCD control pins as outputs
    GpioCtrlRegs.GPAMUX1.bit.GPIO1 = 0;   // RS
    GpioCtrlRegs.GPAMUX1.bit.GPIO0 = 0;   // EN
    GpioCtrlRegs.GPADIR.bit.GPIO1 = 1;    // RS
    GpioCtrlRegs.GPADIR.bit.GPIO0 = 1;    // EN

    DELAY_US(15000);      // 15000us...0.015 seconds
    DELAY_US(4100);       // 4100us
    DELAY_US(100);
    send_command(0x33);       // 4 bit mode
    send_command(0x32);       // 4 bit mode
    DELAY_US(4100);
    send_command(0x28);       // 4 bit mode
    DELAY_US(40);
    send_command(0x0E);       // display on cursor on
    DELAY_US(40);
    send_command(0x01);       // clear the screen
    DELAY_US(40);
    send_command(0x06);       // increment cursor
    DELAY_US(1640);
    send_command(0x80);       // row 1 column 1
    DELAY_US(4100);
}

void send_command(unsigned char cmd)
{
    GpioDataRegs.GPACLEAR.bit.GPIO1 = 1; // RS = 0 (command mode)

    GpioDataRegs.GPASET.bit.GPIO0 = 1;  // EN = 1 (enable high)
    GpioDataRegs.GPBDAT.bit.GPIO40 = (cmd >> 4) & 0x01;
    GpioDataRegs.GPADAT.bit.GPIO23 = (cmd >> 5) & 0x01;
    GpioDataRegs.GPBDAT.bit.GPIO41 = (cmd >> 6) & 0x01;
    GpioDataRegs.GPADAT.bit.GPIO22 = (cmd >> 7) & 0x01;
    GpioDataRegs.GPACLEAR.bit.GPIO0 = 1; // EN = 0 (enable low)

    DELAY_US(2000);   // Delay required for command execution

    GpioDataRegs.GPASET.bit.GPIO0 = 1;   // EN = 1 (enable high)
    GpioDataRegs.GPBDAT.bit.GPIO40 = cmd & 0x01;
    GpioDataRegs.GPADAT.bit.GPIO23 = (cmd >> 1) & 0x01;
    GpioDataRegs.GPBDAT.bit.GPIO41 = (cmd >> 2) & 0x01;
    GpioDataRegs.GPADAT.bit.GPIO22 = (cmd >> 3) & 0x01;
    GpioDataRegs.GPACLEAR.bit.GPIO0 = 1; // EN = 0 (enable low)
    DELAY_US(2000);
}


void send_string(char *s)
{
    while(*s)
      {
        send_data(*s);
        s++;
      }
}

void send_data(unsigned char data)
{
    GpioDataRegs.GPASET.bit.GPIO1 = 1;     // RS = 1 (Data mode)

    GpioDataRegs.GPASET.bit.GPIO0 = 1;  // EN = 1 (enable high)
    GpioDataRegs.GPBDAT.bit.GPIO40 = (data >> 4) & 0x01;
    GpioDataRegs.GPADAT.bit.GPIO23 = (data >> 5) & 0x01;
    GpioDataRegs.GPBDAT.bit.GPIO41 = (data >> 6) & 0x01;
    GpioDataRegs.GPADAT.bit.GPIO22 = (data >> 7) & 0x01;
    GpioDataRegs.GPACLEAR.bit.GPIO0 = 1; // EN = 0 (enable low)

    DELAY_US(2000);   // Delay required for command execution

    GpioDataRegs.GPASET.bit.GPIO0 = 1;   // EN = 1 (enable high)
    GpioDataRegs.GPBDAT.bit.GPIO40 = data & 0x01;
    GpioDataRegs.GPADAT.bit.GPIO23 = (data >> 1) & 0x01;
    GpioDataRegs.GPBDAT.bit.GPIO41 = (data >> 2) & 0x01;
    GpioDataRegs.GPADAT.bit.GPIO22 = (data >> 3) & 0x01;
    GpioDataRegs.GPACLEAR.bit.GPIO0 = 1; // EN = 0 (enable low)

    DELAY_US(2000);
}



  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好!

    您的原理图显示使用了5V 电源。 请注意、F28002x GPIO 仅为3.3V 逻辑、而不是5V。

    您是否已通过探测 GPIO 正确切换?

    此致!

    Kevin