![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
muahaha98 Guest
|
about mark's lcd program |
Posted: Wed Oct 12, 2005 9:33 am |
|
|
I see the marks program and I add the first line -typedef char BYTE- but computer still has a lot of errors which are as
C:\savas\a.c:18:Warning [2058] call of function without prototype
C:\savas\a.c:19:Warning [2058] call of function without prototype
C:\savas\a.c:20:Error [1105] symbol 'PIN_A1' has not been defined
C:\savas\a.c:20:Warning [2058] call of function without prototype
C:\savas\a.c:21:Warning [2058] call of function without prototype
C:\savas\a.c:22:Error [1105] symbol 'PIN_A1' has not been defined
C:\savas\a.c:22:Warning [2058] call of function without prototype
Code: |
typedef char BYTE;
#define use_PICDEM2_lcd TRUE
#if defined use_PICDEM2_lcd
#define lcd_en PIN_A1
#define lcd_rw PIN_A2
#define lcd_rs PIN_A3
#define lcd_type 2 // 0=5x7, 1=5x10, 2=2 lines
#define lcd_line_two 0x40 // LCD RAM address for the second line
#define d_cycle 1
#endif
void lcd_send_nibble( BYTE n ) {
n=n&0x0f; //Strip off the top 4 bits.. This only sends bit 3:0
output_d(n);
delay_cycles(d_cycle);
output_high(lcd_en);
delay_us(20);
output_low(lcd_en);
}
BYTE lcd_read_byte() {
BYTE low,high;
output_high(lcd_rw);
delay_cycles(d_cycle);
output_high(lcd_en);
delay_cycles(d_cycle);
high = input_d(); //using d0:d3 for 4 bit data bus
output_low(lcd_en);
delay_cycles(d_cycle);
output_high(lcd_en);
delay_us(1);
low = input_d(); //using d0:d3 for 4 bit data bus
output_low(lcd_en);
return((high<<4) | low);
}
void lcd_send_byte( BYTE A0, BYTE n ) { //A0: 0=instruction, 1=Data
output_low(lcd_rs);
while ( bit_test(lcd_read_byte(),7) ) ; // wait until busy flag is low
if (A0==0){ output_low(lcd_rs);} //0=Instruction and 1=Data
if (A0==1){output_high(lcd_rs);} //0=Instruction and 1=Data
delay_cycles(d_cycle);
output_low(lcd_rw);
delay_cycles(d_cycle);
output_low(lcd_en);
lcd_send_nibble(n >> 4);
lcd_send_nibble(n & 0xf);
}
void lcd_init() {
BYTE const LCD_INIT_STRING[4] = {0x20 | (lcd_type << 2), 0xc, 1, 6};
// These bytes need to be sent to the LCD for initialization.
BYTE i;
//fprintf(debug,"Init!!\n\r");
output_low(lcd_rs);
output_low(lcd_rw);
output_low(lcd_en);
delay_ms(15);
for(i=1;i<=3;++i) {
lcd_send_nibble(3);
delay_ms(5);
}
lcd_send_nibble(2);
for(i=0;i<=3;++i){
lcd_send_byte(0,LCD_INIT_STRING[i]);
}
}
void lcd_gotoxy( BYTE x, BYTE y) {
BYTE Data;
if(y!=1)
Data=lcd_line_two;
else
Data=0;
Data+=x-1;
lcd_send_byte(0,0x80|Data);
}
void lcd_putc( char c) {
switch (c) {
case '\f' :
lcd_send_byte(0,1);
delay_ms(2);
break;
case '\n' :
lcd_gotoxy(1,2);
break;
case '\b' :
lcd_send_byte(0,0x10);
break;
default :
lcd_send_byte(1,c);
break;
}
}
char lcd_getc( BYTE x, BYTE y) {
char value;
lcd_gotoxy(x,y);
while ( bit_test(lcd_read_byte(),7) ); // wait until busy flag is low
output_high(lcd_rs);
value = lcd_read_byte();
output_low(lcd_rs);
return(value);
}
|
|
|
![](templates/subSilver/images/spacer.gif) |
treitmey
Joined: 23 Jan 2004 Posts: 1094 Location: Appleton,WI USA
|
|
Posted: Wed Oct 12, 2005 9:54 am |
|
|
This compiles.
you need to have your functions physically before main().
OR use prototypes
Code: | #INCLUDE <18F452.H>
#CASE
#USE DELAY(CLOCK=16000000) //********************************* ! ! ! ! ! !
#FUSES HS,NOWDT,NOPROTECT,NOLVP
#DEFINE VER_MAJOR 0
#DEFINE VER_MINOR 01
#USE RS232(BAUD=19200,XMIT=PIN_E0,INVERT,STREAM=DEBUG)
#ZERO_RAM
#define use_PICDEM2_lcd TRUE
#if defined use_PICDEM2_lcd
#define lcd_en PIN_A1
#define lcd_rw PIN_A2
#define lcd_rs PIN_A3
#define lcd_type 2 // 0=5x7, 1=5x10, 2=2 lines
#define lcd_line_two 0x40 // LCD RAM address for the second line
#define d_cycle 1
#endif
void lcd_send_nibble( BYTE n ) {
n=n&0x0f; //Strip off the top 4 bits.. This only sends bit 3:0
output_d(n);
delay_cycles(d_cycle);
output_high(lcd_en);
delay_us(20);
output_low(lcd_en);
}
BYTE lcd_read_byte() {
BYTE low,high;
output_high(lcd_rw);
delay_cycles(d_cycle);
output_high(lcd_en);
delay_cycles(d_cycle);
high = input_d(); //using d0:d3 for 4 bit data bus
output_low(lcd_en);
delay_cycles(d_cycle);
output_high(lcd_en);
delay_us(1);
low = input_d(); //using d0:d3 for 4 bit data bus
output_low(lcd_en);
return((high<<4) | low);
}
void lcd_send_byte( BYTE A0, BYTE n ) { //A0: 0=instruction, 1=Data
output_low(lcd_rs);
while ( bit_test(lcd_read_byte(),7) ) ; // wait until busy flag is low
if (A0==0){ output_low(lcd_rs);} //0=Instruction and 1=Data
if (A0==1){output_high(lcd_rs);} //0=Instruction and 1=Data
delay_cycles(d_cycle);
output_low(lcd_rw);
delay_cycles(d_cycle);
output_low(lcd_en);
lcd_send_nibble(n >> 4);
lcd_send_nibble(n & 0xf);
}
void lcd_init() {
BYTE const LCD_INIT_STRING[4] = {0x20 | (lcd_type << 2), 0xc, 1, 6};
// These bytes need to be sent to the LCD for initialization.
BYTE i;
//fprintf(debug,"Init!!\n\r");
output_low(lcd_rs);
output_low(lcd_rw);
output_low(lcd_en);
delay_ms(15);
for(i=1;i<=3;++i) {
lcd_send_nibble(3);
delay_ms(5);
}
lcd_send_nibble(2);
for(i=0;i<=3;++i){
lcd_send_byte(0,LCD_INIT_STRING[i]);
}
}
void lcd_gotoxy( BYTE x, BYTE y) {
BYTE Data;
if(y!=1)
Data=lcd_line_two;
else
Data=0;
Data+=x-1;
lcd_send_byte(0,0x80|Data);
}
void lcd_putc( char c) {
switch (c) {
case '\f' :
lcd_send_byte(0,1);
delay_ms(2);
break;
case '\n' :
lcd_gotoxy(1,2);
break;
case '\b' :
lcd_send_byte(0,0x10);
break;
default :
lcd_send_byte(1,c);
break;
}
}
char lcd_getc( BYTE x, BYTE y) {
char value;
lcd_gotoxy(x,y);
while ( bit_test(lcd_read_byte(),7) ); // wait until busy flag is low
output_high(lcd_rs);
value = lcd_read_byte();
output_low(lcd_rs);
return(value);
}
void main(void)
{
setup_adc_ports(NO_ANALOGS);
set_tris_a(0);set_tris_b(0);set_tris_c(0);set_tris_d(0);set_tris_e(0);
fprintf(DEBUG,"STARTING CRI Test.\n\r");
fprintf(DEBUG,"FIRMWARE VERSION %u.%02u\n\r",VER_MAJOR,VER_MINOR);
lcd_init();
printf(lcd_putc,"FIRMWARE VERSION %u.%02u\n\r",VER_MAJOR,VER_MINOR);
while (TRUE)
{
}
}
|
|
|
![](templates/subSilver/images/spacer.gif) |
muahaha98 Guest
|
to treitmey |
Posted: Wed Oct 12, 2005 10:11 am |
|
|
I added these codes which you said
but computer still systax error
Executing: "c:\mcc18\bin\mcc18.exe" -p=18F452 "a.c" -fo="a.o" /i"C:\mcc18\h" -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa-
C:\savas\a.c:1:Error: syntax error
Halting build on first failure as requested.
[/code] |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Oct 12, 2005 10:17 am |
|
|
You need to buy the CCS compiler to use code that has CCS functions.
You can't use code that calls built-in CCS functions with the C18 compiler. |
|
![](templates/subSilver/images/spacer.gif) |
muahaha98 Guest
|
which compiler? |
Posted: Wed Oct 12, 2005 10:26 am |
|
|
which compiler shoolud is used?
please tell programm ne? |
|
![](templates/subSilver/images/spacer.gif) |
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Wed Oct 12, 2005 11:01 am |
|
|
C18 has their own LCD functions. |
|
![](templates/subSilver/images/spacer.gif) |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|