|
|
View previous topic :: View next topic |
Author |
Message |
ghamblin
Joined: 02 Aug 2015 Posts: 38 Location: Tucson
|
Am I missing something? |
Posted: Sat Nov 21, 2015 12:34 pm |
|
|
I'm getting the error "Expecting function name ::" at each line that contains a printf() statement. Here is a code snippet:
Code: |
if(!input(PIN_A0))
{
x=9;
while(!input(PIN_A0) && x)
{
printf(lcd_putc,"Pending\nReset");
lcd_gotoxy(8,2);
printf(lcd_putc,"%d",x--);
delay_ms(1000);
}
if(!x)
{
WRITE_LONG_EEPROM(0, (int32)0);
lcd_putc('\f');
printf(lcd_putc,"Reset\n PWR OFF");
while(1);
}
}
|
If I comment out the printf() lines it compiles without error. I figure I must be missing something here, and perhaps another set of eyes will see it?
Thanks,
Glenn _________________ -Glenn |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1933 Location: Norman, OK
|
|
Posted: Sat Nov 21, 2015 1:00 pm |
|
|
With no more than you have given us I randomly picked a short section of
test code I had and dropped yours into it. It compiled it under 5.051 with no
problems. It may be something further upstream.
What chip?
What compiler version? _________________ Google and Forum Search are some of your best tools!!!! |
|
|
ghamblin
Joined: 02 Aug 2015 Posts: 38 Location: Tucson
|
|
Posted: Sat Nov 21, 2015 1:13 pm |
|
|
PCM Compiler Version 5.051 (Linux command line version)
Here's the .err file content:
*** Error 53 "CashMeterMX.c" Line 57(29,30): Expecting function name ::
*** Error 53 "CashMeterMX.c" Line 77(121,125): Expecting function name ::
2 Errors, 0 Warnings.
Build Failed.
Here's the whole program:
Code: |
/*
* File: CashMeterMX.c
* Author: Glenn Hamblin
* Mexico Version of CashMeter
* Created on February 15, 2014, 7:18 PM
*/
#include <16F1823.h>
#device WRITE_EEPROM = NOINT
#fuses PUT,NOWDT,INTRC_IO,NOMCLR,NOCLKOUT,NOIESO,NOLVP,NOPROTECT,NODEBUG
#USE STANDARD_IO(a)
#USE STANDARD_IO(c)
#use delay(clock=8M)
#include <stdio.h>
#include <stdlib.h>
#include <CashMeterMX.h>
#include <gh_lcd.c>
int main(void)
{
int8 nickels=0,x;
CASH=0;
TICKS=TICKS_PER_SECOND;
set_rtcc(0);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_256|RTCC_8_BIT);/*increments every 128us
//and overflows every 32.7ms*/
setup_oscillator(OSC_8MHZ | OSC_NORMAL | OSC_PLL_OFF);
setup_timer_1(T1_EXTERNAL|T1_DIV_BY_1);
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_comparator(NC_NC_NC_NC);
setup_ccp1(CCP_OFF);
set_timer1(0);
enable_interrupts(INT_TIMER0);
enable_interrupts(GLOBAL);
port_a_pullups(3);
delay_ms(50);
lcd_init();
delay_ms(50);
lcd_putc('\f');
if(!input(PIN_A0))
{
x=9;
while(!input(PIN_A0) && x)
{
printf(lcd_putc,"Pending\nReset");
lcd_gotoxy(8,2);
printf(lcd_putc,"%d",x--);
delay_ms(1000);
}
if(!x)
{
WRITE_LONG_EEPROM(0, (int32)0);
lcd_putc('\f');
printf(lcd_putc,"Reset\n PWR OFF");
while(1);
}
}
lcd_putc('\f');
delay_ms(10);
CASH=READ_LONG_EEPROM(0);
LASTCASH=CASH;
printf(lcd_putc,"CASH MX \n%8.1w",CASH);
set_timer1(0);
while(1)
{
update_time();
if(!input(PIN_A5))
{
delay_ms(2);
while(!input(PIN_A5));
delay_ms(2);
nickels=get_timer1();
set_timer1(0);
}
if(nickels >0)
{
CASH=CASH+(nickels*5);
nickels=0;
}
if(LASTCASH != CASH)
{
LASTCASH=CASH;
if(CASH > (int32)9999999)
{
lcd_gotoxy(8,1);
lcd_putc('#');
CASH=0;
}
lcd_gotoxy(1,2);
printf(lcd_putc,"%8.1w",CASH);
MINUTES=0;
SECONDS=0;
}
if(MINUTES > 4)
{
MINUTES=0;
SECONDS=0;
if(READ_LONG_EEPROM(0) != CASH)
{
WRITE_LONG_EEPROM(0,CASH);
lcd_gotoxy(5,1);
lcd_putc(' ');
}
}
if(READ_LONG_EEPROM(0) != CASH)
{
lcd_gotoxy(5,1);
lcd_putc('*');
}
}
return (0);
}
|
_________________ -Glenn |
|
|
drolleman
Joined: 03 Feb 2011 Posts: 116
|
|
Posted: Sat Nov 21, 2015 1:19 pm |
|
|
lcd_putc needs to go somewhere
lcd_putc(char buffer)
{
// put charter somewhere
}
if you have something like this, you may be missing the prototype for this funtion |
|
|
ghamblin
Joined: 02 Aug 2015 Posts: 38 Location: Tucson
|
|
Posted: Sat Nov 21, 2015 1:48 pm |
|
|
I have lcd_putc() defined in gh_lcd.c. It's just a modification of the original CCS file lcd.c that I've been using for years.
As a test, I built this little program:
Code: |
/*
* File: newmain.c
* Author: glenn
*
* Created on November 21, 2015, 12:21 PM
*/
#include <16F1823.h>
#device WRITE_EEPROM = NOINT
#fuses PUT,NOWDT,INTRC_IO,NOMCLR,NOCLKOUT,NOIESO,NOLVP,NOPROTECT,NODEBUG
#USE STANDARD_IO(a)
#USE STANDARD_IO(c)
#use delay(clock=8M)
#include <stdio.h>
#include <stdlib.h>
#include <lcd.c>
int main(void)
{
printf(lcd_putc,"Hello") ;
while(1);
}
|
And it generated these errors:
*** Error 28 "/opt/picc/drivers/lcd.c" Line 163(4,5): Expecting an identifier Bad SFR name
*** Error 12 "/opt/picc/drivers/lcd.c" Line 163(5,9): Undefined identifier
*** Error 48 "/opt/picc/drivers/lcd.c" Line 163(10,16): Expecting a (
*** Error 28 "/opt/picc/drivers/lcd.c" Line 164(4,5): Expecting an identifier Bad SFR name
*** Error 48 "/opt/picc/drivers/lcd.c" Line 164(5,9): Expecting a (
*** Error 48 "/opt/picc/drivers/lcd.c" Line 164(10,17): Expecting a (
*** Error 28 "/opt/picc/drivers/lcd.c" Line 164(33,34): Expecting an identifier Bad SFR name
*** Error 48 "/opt/picc/drivers/lcd.c" Line 164(33,34): Expecting a (
*** Error 43 "/opt/picc/drivers/lcd.c" Line 164(34,38): Expecting a declaration
9 Errors, 0 Warnings.
Build Failed.
So something is amiss. Can you compile this little program? _________________ -Glenn |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1933 Location: Norman, OK
|
|
Posted: Sat Nov 21, 2015 1:51 pm |
|
|
You are missing some defines that must be before lcd.c
Look at the comments in the lcd.c file for info.
Quote: | //// To use port access, #define LCD_DATA_PORT to the SFR location of ////
//// of the GPIO port that holds the interface, -AND- edit LCD_PIN_MAP ////
//// of this file to configure the pin order. If you are using a ////
//// baseline PIC (PCB), then LCD_OUTPUT_MAP and LCD_INPUT_MAP also must ////
//// be defined. |
_________________ Google and Forum Search are some of your best tools!!!! |
|
|
ghamblin
Joined: 02 Aug 2015 Posts: 38 Location: Tucson
|
|
Posted: Sat Nov 21, 2015 2:02 pm |
|
|
Ah, yes. That info is in my header file. I forgot to put it in my simple program.
I added this, and it still fails, same errors. I don't understand why it used to compile OK, but now gives this weird error.
Code: |
/*
* File: newmain.c
* Author: glenn
*
* Created on November 21, 2015, 12:21 PM
*/
#include <16F1823.h>
#device WRITE_EEPROM = NOINT
#fuses PUT,NOWDT,INTRC_IO,NOMCLR,NOCLKOUT,NOIESO,NOLVP,NOPROTECT,NODEBUG
#USE STANDARD_IO(a)
#USE STANDARD_IO(c)
#use delay(clock=8M)
#include <stdio.h>
#include <stdlib.h>
#include <lcd.c>
#define LCD_DATA_PORT getenv("SFR:PORTC")
#define LCD_ENABLE_PIN PIN_A2
#define LCD_RS_PIN PIN_C4
#define LCD_RW_PIN PIN_C5
#define LCD_DATA4 PIN_C0
#define LCD_DATA5 PIN_C1
#define LCD_DATA6 PIN_C2
#define LCD_DATA7 PIN_C3
#define LCD_LINE_LENGTH 8
int main(void)
{
printf(lcd_putc,"Hello") ;
while(1);
}
[quote]
[/quote] |
_________________ -Glenn |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1933 Location: Norman, OK
|
|
Posted: Sat Nov 21, 2015 2:03 pm |
|
|
The defines must be BEFORE LCD.C... _________________ Google and Forum Search are some of your best tools!!!! |
|
|
ghamblin
Joined: 02 Aug 2015 Posts: 38 Location: Tucson
|
|
Posted: Sat Nov 21, 2015 2:11 pm |
|
|
Duh! Thanks.
OK, That compiles fine. So I'm back to my original problem. _________________ -Glenn |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1933 Location: Norman, OK
|
|
Posted: Sat Nov 21, 2015 2:13 pm |
|
|
I would first go back and add the defines prior to your gh_lcd.c include... _________________ Google and Forum Search are some of your best tools!!!! |
|
|
ghamblin
Joined: 02 Aug 2015 Posts: 38 Location: Tucson
|
|
Posted: Sat Nov 21, 2015 2:14 pm |
|
|
Strike that. I just reopened my original file, and it compiled error free.
So that was a time sink I guess.
Thank you for looking, I appreciate it.
Glenn _________________ -Glenn |
|
|
|
|
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
|