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

conditional compile

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



Joined: 08 Sep 2003
Posts: 92
Location: Glasgow, UK

View user's profile Send private message

conditional compile
PostPosted: Sun Jan 11, 2004 9:05 am     Reply with quote

I have a question about conditional compile.

I am trying to use a conditional compile to enable printf for use as debug statements whilst I am developing my product. No ICD's involved here! The conditional compile will be removed for production programming as there will be no RS232 interface on the production system.

I enable debug via #define DEBUG_LEVEL_1 and disable by commenting out the line. This #define is declared in the project.h file.
Debug printing is thereby controlled via....
#ifdef DEBUG_LEVEL_1
printf("mains = %lu\n\r",clock_ticks);
#endif

However, I find that this arrangement only works in 'main'. If I try and use it within a function called from 'main', I get the following error message....
Error[132] STDOUT not defined (may be missing #USE RS232).

I am using PCM v3.148 and MPLab 5.70.40.

Any suggestions anybody?
Ttelmah
Guest







Re: conditional compile
PostPosted: Sun Jan 11, 2004 10:14 am     Reply with quote

adrian wrote:
I have a question about conditional compile.

I am trying to use a conditional compile to enable printf for use as debug statements whilst I am developing my product. No ICD's involved here! The conditional compile will be removed for production programming as there will be no RS232 interface on the production system.

I enable debug via #define DEBUG_LEVEL_1 and disable by commenting out the line. This #define is declared in the project.h file.
Debug printing is thereby controlled via....
#ifdef DEBUG_LEVEL_1
printf("mains = %lu\n\r",clock_ticks);
#endif

However, I find that this arrangement only works in 'main'. If I try and use it within a function called from 'main', I get the following error message....
Error[132] STDOUT not defined (may be missing #USE RS232).

I am using PCM v3.148 and MPLab 5.70.40.

Any suggestions anybody?


Where is the function defined?.
What you describe should work, but would give problems if the code is like this:

#include <define file for chip>
#include "include file containing function"

#use RS232 defintions

main() {

}

If the code is laid out like this, then a function included in 'include file containing function', will give this error, since the #use RS232, has not yet been 'met' in the code.
If the layout is changed to:

#include <define file for chip>
#use RS232 definitions

#include "include file containing function"

main() {

}

The problem should disappear.

Best Wishes
adrian



Joined: 08 Sep 2003
Posts: 92
Location: Glasgow, UK

View user's profile Send private message

PostPosted: Sun Jan 11, 2004 11:40 am     Reply with quote

Yep that solved it.

I just logged back on, after I figured out the answer, to give an update.

I had the following in my hardware initialisation subroutine...
//conditional compile
//if DEBUG is enabled, use GPIO_4 on pin 3 for RS232 duty using software USART
#ifdef DEBUG_LEVEL_1
#use rs232(baud=9600,xmit=PIN_A4) //-> debug RS232 on pin 3
#endif

//if DEBUG is not enabled, use GPIO_4 on pin 3 as relay driver
#ifndef DEBUG_LEVEL_1
#define RELAY PIN_A4 // use PIN 3 as an output
#endif

Shifting the #use rs232(baud=9600,xmit=PIN_A4) into my project.h solved the printing problem.

This now leads onto a further question. If I put the #use RS232 statement in the project.h file, can I leave the conditional compile statement for GPIO_4 (to be configured as a Relay output) in my hardware initialisation routine? Or do I have to comment out both the #define DEBUG_LEVEL_1 and #use RS232? If I comment out the #define DEBUG_LEVEL_1, but leave in the #use RS232, what will happen to GPIO_4? Which takes control of the port pin, the #define RELAY PIN_A4 or the use RS232?
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