View previous topic :: View next topic |
Author |
Message |
reptile404
Joined: 01 Apr 2011 Posts: 17
|
lcd problem |
Posted: Fri Apr 01, 2011 7:09 am |
|
|
hello guys , what's up ?
i have a problem when i want to use lcd
for example this is the simplest code ever :
pic16f876a
Code: |
#include "lcd4447.h"
#define LCD_ENABLE_PIN PIN_B0
#define LCD_RS_PIN PIN_B1
#define LCD_RW_PIN PIN_B3
#define LCD_TYPE 1
#include <lcd.c>
void main()
{
lcd_init();
lcd_putc("\fReady...\n");
while (TRUE) {
k=kbd_getc();
if(k!=0)
if(k=='*')
lcd_putc('\f');
else
lcd_putc(k);
}
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_spi(SPI_SS_DISABLED);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1););
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
// TODO: USER CODE!!
} |
But when I compile it many errors will appear like this one:
an Expression must be a constant or simple variable
Code: |
BYTE const LCD_INIT_STRING[4] = {0x20 | (lcd_type << 2), 0xc, 1, 6};
// These bytes need to be sent to the LCD
// to start it up.
// The following are used for setting
// the I/O port direction register.
|
Maybe compiler did not know these functions :
lcd_init(),lcd_putc()....etc or #include <lcd.c>
So, what I have to do ?
Thanks _________________ REPTILE404
55AA55AA55 |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19515
|
|
Posted: Fri Apr 01, 2011 8:21 am |
|
|
Are you compiling directly in CCS, or under MPLAB?.
If the latter, you _must_ only include your main program code file in the list of files to compile. If you add the 'lcd.c' file, MPLAB tries to compile this on it's own, and then lacks the processor definitions etc., and gives the errors you are describing.
Best Wishes |
|
|
reptile404
Joined: 01 Apr 2011 Posts: 17
|
hello |
Posted: Fri Apr 01, 2011 11:22 am |
|
|
thanks for respond.
I've compiled it using both ccs directly and under mplab
and had same problem. _________________ REPTILE404
55AA55AA55 |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9226 Location: Greensville,Ontario
|
|
Posted: Fri Apr 01, 2011 11:32 am |
|
|
if that's your entire program, then it's missing the
#include ..processortype line
which should be the first line of code.... |
|
|
|