![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
muahaha95 Guest
|
where is the mistake? |
Posted: Thu Oct 13, 2005 2:19 pm |
|
|
hi all
my code is
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)
{ lcd_putc("savas");
lcd_putc();
}
but compuer said
Error[51] C:\savas\a.c 123 : A numeric expression must appear here
Halting build on first failed translation as user preferences indicate.
please help me |
|
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Oct 13, 2005 2:27 pm |
|
|
Quote: | Error[51] C:\savas\a.c 123 : A numeric expression must appear here |
Which line in your program is line 123 ? |
|
![](templates/subSilver/images/spacer.gif) |
muahaha95 Guest
|
lcd_putc(); |
Posted: Thu Oct 13, 2005 2:29 pm |
|
|
lcd_putc(); |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Oct 13, 2005 2:35 pm |
|
|
lcd_putc() requires a parameter.
Change your program to look like this:
Code: | void main(void)
{
lcd_init();
lcd_putc("savas");
while(1);
} |
|
|
![](templates/subSilver/images/spacer.gif) |
MUAHAHA95 Guest
|
THANK YOU PIC PROGRAMMER |
Posted: Thu Oct 13, 2005 2:39 pm |
|
|
THANKS |
|
![](templates/subSilver/images/spacer.gif) |
muahaha95 Guest
|
to PIC PROGRAMMER |
Posted: Thu Oct 13, 2005 2:47 pm |
|
|
hEY MY Friend I ask a last question
I build the program but compuer said that
No Errors
Halting build on first failed translation as user preferences indicate.
BUILD FAILED: Thu Oct 13 23:44:52 2005
what is problem ? |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
![](templates/subSilver/images/spacer.gif) |
muahaha95 Guest
|
only led work |
Posted: Thu Oct 13, 2005 3:01 pm |
|
|
HEY MY FRIEND PROGRAM WORK BUT LCD DONT WORK ONLY LED WORK
WHAT DO YOU THINK ABOUT IT? |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Oct 13, 2005 3:06 pm |
|
|
What board are you using to test the LCD ? Are you using a
Microchip PicDem2-Plus board, or something else ? |
|
![](templates/subSilver/images/spacer.gif) |
muahaha95 Guest
|
About Board |
Posted: Thu Oct 13, 2005 3:08 pm |
|
|
I used PICDEM2 PLUS |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Oct 13, 2005 3:32 pm |
|
|
That driver doesn't work. (sorry treitmey).
Use this one. It works. I tested it just now with a 18F452 on a PicDem2-
Plus board. It requires no changes. Just drop it in.
http://www.ccsinfo.com/forum/viewtopic.php?t=24661 |
|
![](templates/subSilver/images/spacer.gif) |
MUAHAHA95 Guest
|
thanks |
Posted: Thu Oct 13, 2005 3:36 pm |
|
|
thanks for all things PIC PROG.... |
|
![](templates/subSilver/images/spacer.gif) |
treitmey
Joined: 23 Jan 2004 Posts: 1094 Location: Appleton,WI USA
|
|
Posted: Thu Oct 13, 2005 3:42 pm |
|
|
What doesn't work? Perhaps I should update the driver.
This little test worked.
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
#include "picdem2.c"
int8 data;
//======================= MAIN ============================//
void main(void)
{
setup_adc_ports(NO_ANALOGS);
set_tris_a(0);set_tris_b(0);set_tris_c(0);set_tris_d(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,"TEST");
while(TRUE){
}
}
|
Code: | ///////////////////////////////////////////////////////////////////////////
//// PICDEM2_LCD.C ////
//// Driver for common PICDEM2 PLUS LCD modules ////
//// ////
//// lcd_init() Must be called before any other function. ////
//// ////
//// lcd_putc(c) Will display c on the next position of the LCD. ////
//// The following have special meaning: ////
//// \f Clear display ////
//// \n Go to start of second line ////
//// \b Move back one position ////
//// ////
//// lcd_gotoxy(x,y) Set write position on LCD (upper left is 1,1) ////
//// ////
//// lcd_getc(x,y) Returns character at position x,y on LCD ////
//// ////
///////////////////////////////////////////////////////////////////////////
#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);
}
|
Last edited by treitmey on Thu Oct 13, 2005 4:08 pm; edited 1 time in total |
|
![](templates/subSilver/images/spacer.gif) |
to PCM programmer Guest
|
about last code |
Posted: Thu Oct 13, 2005 3:45 pm |
|
|
Hey my friend
second program which you send only run led lamps but lcd is not work
I think main program is not enough
void main(void)
{
lcd_init();
lcd_putc("savas");
while(1);
}
what do you think about it? |
|
![](templates/subSilver/images/spacer.gif) |
to TREITNEY Guest
|
about main |
Posted: Thu Oct 13, 2005 3:52 pm |
|
|
hey TREITNEY
thanks for main code
but still LCD doesnt work only led lamps work
I dont know where is the my mistake |
|
![](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
|