Ðăng Nhập

View Full Version : Lỗi khi biên dịch lcd_lib_4bits.c


huynhbkfet
19-03-2011, 10:42 PM
Em chào tất cả mọi người!
Tình hình em là người mới,lại cũng mới học về pic.Em đang phải làm bài tập lớn vi xử lý,nhưng,híc,hôm nay biên dịch file lcd_lib_4bits.c ở dưới
// lcd_lib_4bit.c
#include <stddef.h>

#define LCD_RS PIN_D2
//#define LCD_RW PIN_A1
#define LCD_EN PIN_D3

#define LCD_D4 PIN_D4
#define LCD_D5 PIN_D5
#define LCD_D6 PIN_D6
#define LCD_D7 PIN_D7

// misc display defines-
#define Line_1 0x80
#define Line_2 0xC0
#define Clear_Scr 0x01

// prototype statements
#separate void LCD_Init ( void );// ham khoi tao LCD
#separate void LCD_SetPosition ( unsigned int cX );//Thiet lap vi tri con tro
#separate void LCD_PutChar ( unsigned int cX );// Ham viet1kitu/1chuoi len LCD
#separate void LCD_PutCmd ( unsigned int cX) ;// Ham gui lenh len LCD
#separate void LCD_PulseEnable ( void );// Xung kich hoat
#separate void LCD_SetData ( unsigned int cX );// Dat du lieu len chan Data
// D/n Cong
#use standard_io ( B )
#use standard_io (A)

//khoi tao LCD**********************************************
#separate void LCD_Init ( void )
{
LCD_SetData ( 0x00 );
delay_ms(200);
output_low ( LCD_RS ); // Command mode
LCD_SetData ( 0x03 ); //
LCD_PulseEnable();
LCD_PulseEnable();
LCD_PulseEnable();
LCD_SetData ( 0x02 );
LCD_PulseEnable();
LCD_PutCmd ( 0x2C );
LCD_PutCmd ( 0b00001100);
LCD_PutCmd ( 0x06 );
LCD_PutCmd ( 0x01 );
}

#separate void LCD_SetPosition ( unsigned int cX )
{
/* this subroutine works specifically for 4-bit Port A */
LCD_SetData ( swap ( cX ) | 0x08 );
LCD_PulseEnable();
LCD_SetData ( swap ( cX ) );
LCD_PulseEnable();
}

#separate void LCD_PutChar ( unsigned int cX )
{
/* this subroutine works specifically for 4-bit Port A */
output_high ( LCD_RS );
LCD_PutCmd( cX );
output_low ( LCD_RS );
}

#separate void LCD_PutCmd ( unsigned int cX )
{
/* this subroutine works specifically for 4-bit Port A */
LCD_SetData ( swap ( cX ) ); /* send high nibble */
LCD_PulseEnable();
LCD_SetData ( swap ( cX ) ); /* send low nibble */
LCD_PulseEnable();
}
#separate void LCD_PulseEnable ( void )
{
output_high ( LCD_EN );
delay_us ( 3 ); // was 10
output_low ( LCD_EN );
delay_ms ( 3 ); // was 5
}

#separate void LCD_SetData ( unsigned int cX )
{
output_bit ( LCD_D4, cX & 0x01 );
output_bit ( LCD_D5, cX & 0x02 );
output_bit ( LCD_D6, cX & 0x04 );
output_bit ( LCD_D7, cX & 0x08 );
}
thì nó lại báo lỗi: error 128"student.c" Line18(2,10): A #DEVICE required before this line.
Huhu em chẳng biết khắc phục làm sao cả,đành gửi lên đây mong các bác giúp cho.
không đượct thì em đến phải đi chết mất

huynhbkfet
23-03-2011, 01:06 AM
sao chẳng ai giúp em thế?
mai là em phải nộp rồi các bác ạ,giúp em với nhé

tuananhk53
24-03-2011, 05:32 PM
à anh Huynh ĐT8 đây mà :))

hongquang9
23-04-2011, 02:31 AM
ban da sua duoc loi nay chua vay
minh cung gap ma khong biet sua the nao?

khienpzo
23-04-2011, 01:29 PM
Hai bạn đã cài CCS chưa ? Nếu chưa cài thì phải cài lên ... mà post bài lên thì có file mới chỉ được chứ .....

tanbka
24-04-2011, 12:43 AM
ban da sua duoc loi nay chua vay
minh cung gap ma khong biet sua the nao?
Mình nghĩ bạn chưa khai báo chip được sử dụng, hoặc phải khai báo trước khi include đoạn file này vào project, vấn đề lỗi ở ngay đoạn code khai báo sử dụng cổng mà.

thanchetcungyeu
01-05-2012, 10:31 AM
mình cũng bị thế. k biết sửa thế nào

orangho
01-05-2012, 08:07 PM
thì bạn phải đưa cả file "student.c" lên nữa chứ, mà sao lại tắt cái #define LCD_RW PIN_A1 đi thế ?, có thể file "student.c" cần nó !