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

LCD.C compile error

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
oxxyfx



Joined: 24 May 2007
Posts: 97

View user's profile Send private message

LCD.C compile error
PostPosted: Wed May 05, 2010 3:14 pm     Reply with quote

I am trying to interface a 18F2550 with a 2 line 8 character LCD screen. The LCD has a KS0066 controller on it.

Anyway I have the following pins connected:

RC0 = E
RC1 = R/W
RC2 = RS

D4 = RB3
D5 = RB2
D6 = RB1
D7 = RB0

These are defined as:
Code:


#define LCD_ENABLE_PIN  PIN_C0
#define LCD_RS_PIN      PIN_C2
#define LCD_RW_PIN      PIN_C1
#define LCD_TYPE 1
#define LCD_DATA4       PIN_B3                                   
#define LCD_DATA5       PIN_B2                                   
#define LCD_DATA6       PIN_B1                                   
#define LCD_DATA7       PIN_B0
#include <lcd.c>


The program is really nothing I just want to see if I can display something on the LCD:

Code:

void main()
{



   setup_adc_ports(NO_ANALOGS|VSS_VDD);
   setup_adc(ADC_OFF);
   setup_spi(SPI_SS_DISABLED);
   setup_wdt(WDT_OFF);
   setup_timer_0(RTCC_INTERNAL);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);
   setup_oscillator(OSC_8MHZ|OSC_INTRC|OSC_31250|OSC_PLL_OFF);
//Setup_Oscillator parameter not selected from Intr Oscillator Config tab

   // TODO: USER CODE!!
   lcd_init();

   lcd_putc("\fReady...\n");

   while (TRUE) {
      k=kbd_getc();
      if(k!=0)
        if(k=='*')
          lcd_putc('\f');
        else
          lcd_putc(k);
   }
}

Whenever I am trying to compile this code it comes back with an error on the LCD.c - Unidentified identifier:

Line 133:
#byte lcdlat = LCD_DATA_PORT+9

I am not sure what I am doing wrong.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed May 05, 2010 3:59 pm     Reply with quote

Post a complete (but short) compilable program. Post the #include
for the PIC, #fuses, #use delay. Post all variable declarations.
For example, your code uses 'k' but is missing the declaration for it.
Post all #include lines, such as for kbd.c.

Also post your compiler version.
oxxyfx



Joined: 24 May 2007
Posts: 97

View user's profile Send private message

PostPosted: Wed May 05, 2010 5:55 pm     Reply with quote

Thank you, here is the H file:
Code:

#include <18F2550.h>
#device adc=8

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES WDT128                   //Watch Dog Timer uses 1:128 Postscale
#FUSES INTRC                      //Crystal osc <= 4mhz for PCM/PCH , 3mhz to 10 mhz for PCD
#FUSES NOPROTECT                //Code not protected from reading
#FUSES NOBROWNOUT               //No brownout reset
#FUSES BORV20                   //Brownout reset at 2.0V
#FUSES NOPUT                    //No Power Up Timer
#FUSES NOCPD                    //No EE protection
#FUSES STVREN                   //Stack full/underflow will cause reset
#FUSES NODEBUG                  //No Debug mode for ICD
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOWRT                    //Program memory not write protected
#FUSES NOWRTD                   //Data EEPROM not write protected
#FUSES IESO                     //Internal External Switch Over mode enabled
#FUSES FCMEN                    //Fail-safe clock monitor enabled
#FUSES PBADEN                   //PORTB pins are configured as analog input channels on RESET
#FUSES NOWRTC                   //configuration not registers write protected
#FUSES NOWRTB                   //Boot block not write protected
#FUSES NOEBTR                   //Memory not protected from table reads
#FUSES NOEBTRB                  //Boot block not protected from table reads
#FUSES NOCPB                    //No Boot Block code protection
#FUSES MCLR                     //Master Clear pin enabled
#FUSES LPT1OSC                  //Timer1 configured for low-power operation
#FUSES NOXINST                  //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#FUSES PLL12                    //Divide By 12(48MHz oscillator input)
#FUSES CPUDIV4                  //System Clock by 4
#FUSES USBDIV                   //USB clock source comes from PLL divide by 2
#FUSES VREGEN                   //USB voltage regulator enabled

#use delay(clock=8000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)


and here is the program:

Code:

#include "LCDTest.h"

#define LCD_ENABLE_PIN  PIN_C0
#define LCD_RS_PIN      PIN_C2
#define LCD_RW_PIN      PIN_C1
#define LCD_TYPE 2
#define LCD_DATA4       PIN_B3                                   
#define LCD_DATA5       PIN_B2                                   
#define LCD_DATA6       PIN_B1                                   
#define LCD_DATA7       PIN_B0
#include <lcd.c>

int k;

void main()
{
   setup_adc_ports(NO_ANALOGS|VSS_VDD);
   setup_adc(ADC_OFF);
   setup_spi(SPI_SS_DISABLED);
   setup_wdt(WDT_OFF);
   setup_timer_0(RTCC_INTERNAL);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);
   setup_oscillator(OSC_8MHZ|OSC_INTRC|OSC_31250|OSC_PLL_OFF);

   lcd_init();

   lcd_putc("\fReady...\n");

   while (TRUE) {
      k=kbd_getc();
      if(k!=0)
        if(k=='*')
          lcd_putc('\f');
        else
          lcd_putc(k);
   }
}


The compiler version is 4.093
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed May 05, 2010 6:16 pm     Reply with quote

Try adding the line in bold, so it's above the #include for lcd.c.
I didn't test this in hardware, but I think that's what it needs.
Quote:

#define LCD_ENABLE_PIN PIN_C0
#define LCD_RS_PIN PIN_C2
#define LCD_RW_PIN PIN_C1
#define LCD_TYPE 2
#define LCD_DATA4 PIN_B3
#define LCD_DATA5 PIN_B2
#define LCD_DATA6 PIN_B1
#define LCD_DATA7 PIN_B0

#define LCD_DATA_PORT getenv("SFR:PORTB")

#include <lcd.c>

This is a problem in your version. They fixed it in later versions.
oxxyfx



Joined: 24 May 2007
Posts: 97

View user's profile Send private message

PostPosted: Wed May 05, 2010 7:00 pm     Reply with quote

Thank you, that almost fixed it. Now I am getting an error in the kbd.c:

Line 106:
case 0 : set_tris_kbd(ALL_PINS&~COL0);

unidentified identfier: set_tris_d
oxxyfx



Joined: 24 May 2007
Posts: 97

View user's profile Send private message

PostPosted: Wed May 05, 2010 7:02 pm     Reply with quote

#define use_portb_kbd TRUE

inserted in the code fixed the above error as well. Thank you.
oxxyfx



Joined: 24 May 2007
Posts: 97

View user's profile Send private message

PostPosted: Wed May 05, 2010 7:20 pm     Reply with quote

Now I only have to figure out why am I not seeing anything displayed on the LCD...
oxxyfx



Joined: 24 May 2007
Posts: 97

View user's profile Send private message

PostPosted: Thu May 06, 2010 1:39 pm     Reply with quote

Got it working. The code was ok, the contrast pin required different values for the resistors. Thanks again.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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