错误:标识符“LCD_E_PORT”未定义

时间:2015-04-06 11:31:41

标签: c

为什么我收到错误:此代码中标识符“LCD_E_PORT”未定义

#include <msp430f5438a.h>
#include "IO_functions.h"
#define LCD_E_PORT   PORT_6
#define LCD_E        PIN_4

#include "LCD1602.h"

int main(void)
{
WDTCTL = WDTPW + WDTHOLD;      // Stop watchdog timer
P4DIR = 0x03;
P4OUT = 0x00;

output_bit(PORT_4, PIN_7, 1);
output_bit(PORT_4, PIN_7, 0);
lcd_send_nibble(0x0f);

while(1)
{
  P4OUT ^= BIT0;
  __delay_cycles(500000);
}
}

由于我在代码的顶部定义了LCD_E_PORT,因此我不明白这个错误的来源。

这是LCD1602.c,我在其中使用LCD_E_PORT:

#include <msp430f5438a.h>
#include "LCD1602.h"
#include "IO_functions.h"


void lcd_send_nibble(unsigned char nibble)
{
   output_bit(LCD_DB4_PORT, LCD_DB4, !!(nibble & 1));
   output_bit(LCD_DB5_PORT, LCD_DB5, !!(nibble & 2));
   output_bit(LCD_DB6_PORT, LCD_DB6, !!(nibble & 4));
   output_bit(LCD_DB7_PORT, LCD_DB7, !!(nibble & 8));
   __delay_cycles(8);
   output_bit(LCD_E_PORT, LCD_E, 1);
   __delay_cycles(16);
   output_bit(LCD_E_PORT, LCD_E, 0);
 }

void lcd_send_byte(unsigned char data_instr, unsigned char data)
{
   output_bit(LCD_RS_PORT, LCD_RS, 0);
   __delay_cycles(480);
   if(data_instr == DATA)
      output_bit(LCD_RS_PORT, LCD_RS, 1);
   else
      output_bit(LCD_RS_PORT, LCD_RS, 0);
   __delay_cycles(8);
   output_bit(LCD_E_PORT, LCD_E, 0);
   lcd_send_nibble(data >> 4);
   lcd_send_nibble(data & 0x0F);
}

void lcd_init(void)
{
   unsigned char i;
   output_bit(LCD_RS_PORT, LCD_RS, 0);
   output_bit(LCD_E_PORT, LCD_E, 0);
   __delay_cycles(120000);
   for(i=0 ;i < 3; i++)
   {
      lcd_send_nibble(0x03);
      __delay_cycles(25000);
   }
   lcd_send_nibble(0x02);
   lcd_send_byte(INSTR, 0x28);
   __delay_cycles(25000);
   lcd_send_byte(INSTR, 0x0C);
   __delay_cycles(25000);
   lcd_send_byte(INSTR, 0x01);
   __delay_cycles(25000);
   lcd_send_byte(INSTR, 0x06);
    __delay_cycles(25000);
   }

1 个答案:

答案 0 :(得分:0)

根据更新的代码,LCD_E_PORT文件中无法显示LCD1602.c的定义。

您可能希望在头文件中添加#defineLCD1602.h或您选择的任何其他文件)本身,这将包含在使用该宏的所有源文件中。