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

fputc() NOT DEFINED

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



Joined: 05 Mar 2009
Posts: 15

View user's profile Send private message Send e-mail

fputc() NOT DEFINED
PostPosted: Thu Mar 05, 2009 12:42 pm     Reply with quote

Hello
I am trying to set up two serial streams with a 16F876 standard UART
and a second software defined serial port defined as a second stream
therefore I am using putc and printf for char and string output on the
standard UART stream and I want to use for the first time in my program
the c function fputc and fprintf defining the second software stream to
send the data I am using the standard 16F876.h and I get the message
with an error at the first occurrence of fputc unknown identifier fputc

any ideas please

thanks
dara hayes
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Mar 05, 2009 12:44 pm     Reply with quote

1. Post your compiler version.

2. Post a short little test program that shows the problem.
Post the #include, #fuses, #use delay(), and #use rs232() statements,
and the main(). It should compile without errors.
darahayes



Joined: 05 Mar 2009
Posts: 15

View user's profile Send private message Send e-mail

fputc not defined
PostPosted: Thu Mar 05, 2009 1:32 pm     Reply with quote

My compiler version is 3.181

see test.c below if i change the fputc statement to a putc or a printf statement it compiles without error if i try and use either fputc or fprintf it comes up with fputc not defined or fprintf not defined what file do i go to find the reason for this error ?

Code:
// test program test.c

#include <16f876.h>

#include <stdlib.h>        // for c string manipulation ATOL ATOI etc
#include <math.h>          // need maths
#include <string.h>


#undef BYTE
#undef WORD

#define BYTE unsigned int
#define WORD unsigned long
// moid for 16mhz xtal fitted to all boards SMART TATOR
// piculator box moded back to 20mhz for development 1 box 4 boards 6th Jan 2008
#define GPS 1
#define RAD 0


#use delay(clock=20000000)
#use rs232(baud=1200,xmit=PIN_A5,rcv=PIN_C4,parity=N,BITS=8,ERRORS,STREAM=RAD)   // TX RX TO FROM RADIO
#use rs232(baud=4800,xmit=PIN_C6,rcv=PIN_C7,parity=N,BITS=8,ERRORS,STREAM=GPS)   // TX RX TO FROM GPS RECEIVER


#use fast_io(A)
#use fast_io(B)
#use fast_io(C)



#define P0 PIN_C0
#define P1 PIN_C1
#define P2 PIN_C2
#define P3 PIN_C3
#define P4 PIN_A0
#define P5 PIN_A1
#define P6 PIN_A2
#define P7 PIN_A3
#define P8 PIN_B0
#define P9 PIN_B1
#define P10 PIN_B2
#define P11 PIN_B3
#define P12 PIN_B4
#define P13 PIN_B5
#define P14 PIN_B6
#define P15 PIN_B7

// SERIAL ERRORS ARE HERE
#BYTE RCREG=0x1A
#BYTE PIR1=0x0C
#BYTE RCSTA=0x18
#BIT OERR=RCSTA.1
#BIT CREN=RCSTA.4
#BIT FRAM=RCSTA.2
#BIT RCIF=PIR1.5




void main(void)

 {
char x;

     x = 1;

   while (x=1)
    {

  fputc("test\n\l",RAD);

    }
}
darahayes



Joined: 05 Mar 2009
Posts: 15

View user's profile Send private message Send e-mail

fputc not defined
PostPosted: Thu Mar 05, 2009 1:36 pm     Reply with quote

THat fputc should read fputc("S",RAD); single character send using fputc
darahayes



Joined: 05 Mar 2009
Posts: 15

View user's profile Send private message Send e-mail

fputc third time lucky
PostPosted: Thu Mar 05, 2009 1:38 pm     Reply with quote

that fputc statement should read

fputc('$',RAD);
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Mar 05, 2009 1:42 pm     Reply with quote

Quote:
#define GPS 1
#define RAD 0

Get rid of these two lines. CCS doesn't allow you to do this with streams.

In your version of the compiler, it compiles without error. In 4.087,
the compiler gives these error messages if you try to #define a stream
name as a numeric value. In other words, it fails to work in both
versions, if you use the #define statements, but in the current version
it at least gives an error, so you know to fix it.
Quote:

*** Error 100 "pcm_test.c" Line 22(5,105): USE parameter value is out of range "STREAM"
*** Error 100 "pcm_test.c" Line 23(5,112): USE parameter value is out of range "STREAM"
darahayes



Joined: 05 Mar 2009
Posts: 15

View user's profile Send private message Send e-mail

fputc not recognized by compiler
PostPosted: Thu Mar 05, 2009 2:27 pm     Reply with quote

I remove those two defines and leave them as two different streams defined in the two #use rs232 statements however that is not the issue...

the issue for me is the compiler doesnt recogniZe the c function "fputc" or "fprintf" for that matter , it claims they are unidentifed fputc..... so in my version 3.181 it wont compile but does when I replace the fputc line with a simple putc statement my problem is where do i go to fix this problem ?? as i want to use the second stream that doesnt use the stdio hardware uart ?
thanks for your help
Dara
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Mar 05, 2009 2:36 pm     Reply with quote

It does compile with vs. 3.181, after making the changes shown in bold,
in the code below.
Quote:
Executing: "C:\Program Files\PICC\Ccsc.exe" +FM "pcm_test.c" +DF +LY -T -A +M -Z +Y=9 +EA -EW
Memory usage: ROM=1% RAM=7% - 8%
Loaded C:\Program Files\PICC\Projects\PCM_Test\pcm_test.cof.
BUILD SUCCEEDED: Thu Mar 05 12:21:00 2009


Code:
CCS PCM C Compiler, Version 3.181, xxxxx

               Filename: pcm_test.LST

               ROM used: 88 (1%)
                         Largest free fragment is 2048
               RAM used: 13 (7%) at main() level
                         14 (8%) worst case
               Stack:    1 locations


Quote:

// test program test.c

#include <16f876.h>

#include <stdlib.h> // for c string manipulation ATOL ATOI etc
#include <math.h> // need maths
#include <string.h>


#undef BYTE
#undef WORD

#define BYTE unsigned int
#define WORD unsigned long
// moid for 16mhz xtal fitted to all boards SMART TATOR
// piculator box moded back to 20mhz for development 1 box 4 boards 6th Jan 2008
//#define GPS 1 // *** Comment this out ***
//#define RAD 0 // *** Comment this out ***


#use delay(clock=20000000)
#use rs232(baud=1200,xmit=PIN_A5,rcv=PIN_C4,parity=N,BITS=8,ERRORS,STREAM=RAD) // TX RX TO FROM RADIO
#use rs232(baud=4800,xmit=PIN_C6,rcv=PIN_C7,parity=N,BITS=8,ERRORS,STREAM=GPS) // TX RX TO FROM GPS RECEIVER

#use fast_io(A)
#use fast_io(B)
#use fast_io(C)

#define P0 PIN_C0
#define P1 PIN_C1
#define P2 PIN_C2
#define P3 PIN_C3
#define P4 PIN_A0
#define P5 PIN_A1
#define P6 PIN_A2
#define P7 PIN_A3
#define P8 PIN_B0
#define P9 PIN_B1
#define P10 PIN_B2
#define P11 PIN_B3
#define P12 PIN_B4
#define P13 PIN_B5
#define P14 PIN_B6
#define P15 PIN_B7

// SERIAL ERRORS ARE HERE
#BYTE RCREG=0x1A
#BYTE PIR1=0x0C
#BYTE RCSTA=0x18
#BIT OERR=RCSTA.1
#BIT CREN=RCSTA.4
#BIT FRAM=RCSTA.2
#BIT RCIF=PIR1.5

void main(void)

{
char x;

x = 1;

while (x=1)
{

fputc('$',RAD); // *** Add per Dara ***

}
}
darahayes



Joined: 05 Mar 2009
Posts: 15

View user's profile Send private message Send e-mail

fputc not recognized by compiler 3.181
PostPosted: Thu Mar 05, 2009 3:08 pm     Reply with quote

thanks for that
I am sorry but I have done all you have suggested commented out removed the two defines and adjusted the fputc line to the correct format as fputc('$',RAD);
and i still get an error 12
unidentified "fputc" when i try to compile , i must have a problem
with an include file maybe ......
I note several defines in the h file relating to "put" and "printf" nothing about fputc or fprintf

i THINK I am going to have to download another version of the compiler as mine must have a corrupted file some where ??

from my pic16876.h file ............
Code:
/////////////////////////////// Useful defines
#define FALSE 0
#define TRUE 1

#define BYTE int
#define BOOLEAN short int

#define getc getch
#define getchar getch
#define puts(s) {printf(s); putchar(13); putchar(10);}
#define putc putchar



/////////////////////////////// Constants used for RESTART_CAUSE()
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Mar 05, 2009 3:19 pm     Reply with quote

Re-install your version. See if that fixes the problem.
darahayes



Joined: 05 Mar 2009
Posts: 15

View user's profile Send private message Send e-mail

RESINSTALL WORKS
PostPosted: Thu Mar 05, 2009 6:19 pm     Reply with quote

Many thanks the re install did the trick I was missing some defines in the 16f876.h file see below
THank you for all your help I am sorted now best wishes Dara

Code:
/////////////////// Useful defines
#define FALSE 0
#define TRUE 1

#define BYTE int
#define BOOLEAN short int

#define getc getch
#define fgetc getch
#define getchar getch
#define putc putchar
#define fputc putchar
#define fgets gets
#define fputs puts
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