CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

where is the mistake?
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
muahaha95
Guest







where is the mistake?
PostPosted: Thu Oct 13, 2005 2:19 pm     Reply with quote

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
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Oct 13, 2005 2:27 pm     Reply with quote

Quote:
Error[51] C:\savas\a.c 123 : A numeric expression must appear here

Which line in your program is line 123 ?
muahaha95
Guest







lcd_putc();
PostPosted: Thu Oct 13, 2005 2:29 pm     Reply with quote

lcd_putc();
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Oct 13, 2005 2:35 pm     Reply with quote

lcd_putc() requires a parameter.

Change your program to look like this:

Code:
void main(void)
{
lcd_init();
lcd_putc("savas");
 
while(1);
}
MUAHAHA95
Guest







THANK YOU PIC PROGRAMMER
PostPosted: Thu Oct 13, 2005 2:39 pm     Reply with quote

THANKS
muahaha95
Guest







to PIC PROGRAMMER
PostPosted: Thu Oct 13, 2005 2:47 pm     Reply with quote

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 ?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Oct 13, 2005 2:52 pm     Reply with quote

Look at Mark's reply at the end of this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=21983&highlight=halting+build+first+failed+translation
muahaha95
Guest







only led work
PostPosted: Thu Oct 13, 2005 3:01 pm     Reply with quote

HEY MY FRIEND PROGRAM WORK BUT LCD DONT WORK ONLY LED WORK

WHAT DO YOU THINK ABOUT IT?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Oct 13, 2005 3:06 pm     Reply with quote

What board are you using to test the LCD ? Are you using a
Microchip PicDem2-Plus board, or something else ?
muahaha95
Guest







About Board
PostPosted: Thu Oct 13, 2005 3:08 pm     Reply with quote

I used PICDEM2 PLUS
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Oct 13, 2005 3:32 pm     Reply with quote

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
MUAHAHA95
Guest







thanks
PostPosted: Thu Oct 13, 2005 3:36 pm     Reply with quote

thanks for all things PIC PROG....
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message Visit poster's website

PostPosted: Thu Oct 13, 2005 3:42 pm     Reply with quote

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
to PCM programmer
Guest







about last code
PostPosted: Thu Oct 13, 2005 3:45 pm     Reply with quote

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?
to TREITNEY
Guest







about main
PostPosted: Thu Oct 13, 2005 3:52 pm     Reply with quote

hey TREITNEY
thanks for main code

but still LCD doesnt work only led lamps work

I dont know where is the my mistake
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
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