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.

[参考译文] LAUNCHXL-F280039C:LAUNCHXL-F280039C

Guru**** 2527510 points
Other Parts Discussed in Thread: LAUNCHXL-F280039C

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

https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1234734/launchxl-f280039c-launchxl-f280039c

器件型号:LAUNCHXL-F280039C

您好!

我正在尝试将20x4 LCD 显示屏与 LAUNCHXL-F280039C 进行交互

很遗憾、我无法在显示屏上打印任何字符、显示屏仅在第一行和第三行显示框。

连接图根据下图完成

//#############################################################################
//
// FILE:   empty_driverlib_main.c
//
//! \addtogroup driver_example_list
//! <h1>Empty Project Example</h1>
//!
//! This example is an empty project setup for Driverlib development.
//!
//
//#############################################################################
//
//
// $Copyright:
// Copyright (C) 2023 Texas Instruments Incorporated - http://www.ti.com/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
//   Redistributions of source code must retain the above copyright
//   notice, this list of conditions and the following disclaimer.
//
//   Redistributions in binary form must reproduce the above copyright
//   notice, this list of conditions and the following disclaimer in the
//   documentation and/or other materials provided with the
//   distribution.
//
//   Neither the name of Texas Instruments Incorporated nor the names of
//   its contributors may be used to endorse or promote products derived
//   from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// $
//#############################################################################

//RS = GPIO2
//Enable = GPIO3
//D4 = GPIO10
//D5 = GPIO11
//D6 = GPIO33
//D7 = GPIO48

//
// Included Files
//
#include "driverlib.h"
#include "device.h"
#include "board.h"
#include "c2000ware_libraries.h"
#include <stdint.h>
#include <stdbool.h>
#include <string.h>


void lcdGoToXY(char x, char y);
void lcdGoToAddr(char addr);
void lcdInit();
void lcdClear();
void lcdWriteText(char *text);
void sendCommand(char opCode);
void sendCommand4Bit(char opCode);

int LOW=0;
int HIGH=1;


//
// Main
//
void main(void)
     {

    //
    // Initialize device clock and peripherals
    //
    Device_init();

    //
    // Disable pin locks and enable internal pull-ups.
    //
    Device_initGPIO();

    //
    // Initialize PIE and clear PIE registers. Disables CPU interrupts.
    //
    Interrupt_initModule();

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

    //
    // PinMux and Peripheral Initialization
    //
    Board_init();

    //
    // C2000Ware Library initialization
    //
    C2000Ware_libraries_init();

    //
    // Enable Global Interrupt (INTM) and real time interrupt (DBGM)
    //
    EINT;
    ERTM;

    lcdInit();
    lcdWriteText("--> Hello world! <--");
    lcdGoToXY(1,3);
    lcdWriteText("">http://morf.lv");
    lcdGoToXY(2,4);
    lcdWriteText("Rastro-Mania");
    lcdGoToXY(3,0);
    lcdWriteText("Coding & Engineering");



    while(1)
    {


    }
}



void lcdGoToXY(char x, char y)
{
  char addr;
  switch(x)
  {
     case 0: addr = 0x00; break; //Starting address of 1st line
     case 1: addr = 0x40; break; //Starting address of 2nd line
     case 2: addr = 0x14; break; //Starting address of 3rd line
     case 3: addr = 0x54; break; //Starting address of 4th line
     default: ;
  }

  addr +=y;

  lcdGoToAddr(addr);
}

void lcdGoToAddr(char addr)
{
    char cmd = 0x80 | addr;
    GPIO_writePin(RS_pin, LOW);
    sendCommand4Bit(cmd);
}

void lcdInit()
{
  //Set all the control pins to logic Zero
  GPIO_writePin(RS_pin, 0);
  GPIO_writePin(Enable_pin, 0);


  //Do the wake up call
  DEVICE_DELAY_US(20);
  sendCommand(0x30);
  DEVICE_DELAY_US(20);
  sendCommand(0x30);
  DEVICE_DELAY_US(20);
  sendCommand(0x30);
  DEVICE_DELAY_US(20);
  sendCommand(0x20);  //Let's make it 4 bit mode
  DEVICE_DELAY_US(10);
  //That's it LCD is initialized in 4 bit mode.


  sendCommand4Bit(0x28); //N = 1 (2 line display) F = 0 (5x8 characters)
  sendCommand4Bit(0x08); //Display on/off control D=0,C=0, B=0
  sendCommand4Bit(0x01); //Clear Display
  sendCommand4Bit(0x06); //Entry mode set - I/D = 1 (increment cursor) & S = 0 (no shift)
  sendCommand4Bit(0x0C); //Display on/off control. D = 1, C and B = 0. (Cursor and blink, last two bits)
}

void lcdClear()
{
   GPIO_writePin(RS_pin, LOW);
   sendCommand4Bit(0x01);
}

 void lcdWriteText(char *text)
 {

    while( *text)
    {
                GPIO_writePin(RS_pin,HIGH);
        sendCommand4Bit(*text++);
    }
 }


void sendCommand(char opCode)
{
  GPIO_writePin(D4, opCode & 0x10);
  GPIO_writePin(D5, opCode & 0x20);
  GPIO_writePin(D6, opCode & 0x40);
  GPIO_writePin(D7, opCode & 0x80);
}

void sendCommand4Bit(char opCode)
{
  GPIO_writePin(D4, opCode & 0x10);
  GPIO_writePin(D5, opCode & 0x20);
  GPIO_writePin(D6, opCode & 0x40);
  GPIO_writePin(D7, opCode & 0x80);
  GPIO_writePin(Enable_pin,HIGH);
  GPIO_writePin(Enable_pin,LOW);
  GPIO_writePin(D4, opCode & 0x01);
  GPIO_writePin(D5, opCode & 0x02);
  GPIO_writePin(D6, opCode & 0x04);
  GPIO_writePin(D7, opCode & 0x08);
  GPIO_writePin(Enable_pin,HIGH);
  GPIO_writePin(Enable_pin,LOW);
}




//
// End of File
//

我是一名非常新的员工、正在研究微控制器、因此如果我犯了一些愚蠢的错误、请纠正我

谢谢你  

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

    您好、Vishal、

    您将哪款 TI 器件用作您的微控制器? 您的帖子显示的是 F28003x、但您的图表使用的是 MSP 器件(MSP 和 C2000是不同的系列)。 此外、当您说无法显示字符时、需要说明具体情况;该 LCD 是 TI 生产的产品吗?

    如果不是、 并且您确定问题在于 MCU 而不是 LCD、那么您能否验证 GPIO 的输出以确认您正在输出预期值? 如果预计不到 GPIO 正在输出的信号、请 在 CCS 调试模式>寄存器中确认 GPIO 寄存器配置。

    此致、

    Omer Amir

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

    您好、Omer:

    实际上、连接与 MSP 器件映像相同、但我使用的是  F28003x、而不是 MSP 器件( 以参考进行连接)。

     GPIO 引脚的初始化和连接是 不同的。

    感谢您建议我检查 GPIO 引脚、现在 LCD 显示屏运行良好。