首页 > 解决方案 > 将 LCD Nokia 3310/5110 与微控制器 PIC16F877A 连接

问题描述

我编写了以下代码,用于将诺基亚 LCD 与微控制器 PIC16F877A 连接起来。

我已经从 Microelectronics 网站下载了库文件并粘贴到我的文件夹中。但是,我不断收到以下错误消息。

我正在为 PIC 7.5 使用 MicroC。

23 304  error: Unterminated string literal, skipped the line     
Nokia_3310_Write_Text("electrocardiogram?5,1); // write text
1 error in preprocessor. 
C:\Users\123\Desktop\New design with PIC16F877A and nOKIA 3310\my new design\PIC16F877AandNOKIA5110.c
21 324 Undeclared identifier 'Nokia_3310_LCD_Init' in expression PIC16F877AandNOKIA5110.c
22 324 Undeclared identifier 'Nokia_3310_LCD_Clear' in expression PIC16F877AandNOKIA5110.c
24 324 Undeclared identifier 'Nokia_3310_LCD_Clear' in expression PIC16F877AandNOKIA5110.c
25 324 Undeclared identifier 'Nokia_3310' in expression PIC16F877AandNOKIA5110.c
25 402 ; expected, but '_Image' found PIC16F877AandNOKIA5110.c
25 424 '}' expected ';' found PIC16F877AandNOKIA5110.c
33 312 Internal error '' PIC16F877AandNOKIA5110.c 0 102 Finished (with errors): 25 May 2021, 14:47:45 PIC16F877AandNOKIA5110.mcppi``
// Nokia 3310 or 5110 LCD pinout settings
sbit Nokia_3310_SCLK at RB4_bit;
sbit Nokia_3310_SDA at RB3_bit;
sbit Nokia_3310_DC at RB2_bit;

sbit Nokia_3310_CS at RB1_bit;
sbit Nokia_3310_REST at RB0_bit;

// Pin direction
sbit Nokia_3310_SCLK_dir at TRISB4_bit;
sbit Nokia_3310_SDA_dir at TRISB3_bit;
sbit Nokia_3310_DC_dir at TRISB2_bit;
sbit Nokia_3310_CS_dir at TRISB1_bit;
sbit Nokia_3310_REST_dir at TRISB0_bit;

unsigned short i = 0;
char *txt;

void short_to_String(unsigned short j) {
    txt[0] = j / 100;
    txt[1] = (j / 10) % 10;
    txt[2] = j % 10;
}

void main() {
    Nokia_3310_LCD_Init();// initialize the Nokia 3310 or 5110 LCD
    Nokia_3310_LCD_Clear();// Clear the Nokia 3310 or 5110 LCD
    Nokia_3310_Write_Text("electrocardiogram?5, 1); // write text
    Delay_ms(2000);
    Nokia_3310_LCD_Clear();// Clear the Nokia 3310 or 5110 LCD
    Nokia_3310 _Image(erste_Bild);// Draw picture
    Delay_ms(3000);
    Nokia_3310_LCD_Clear();// Clear the Nokia 3310 or 5110 LCD
    for (;;) {
        short_to_String(i); // convert short to string
        Nokia_3310_Write_Text(txt, 40, 3);//write text
        i++;
        Delay_ms(1500);
    }
}

标签: microcontrollerlcdmikroc

解决方案


推荐阅读