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 CCS Technical Support

Compiler Calls to Built-In Functions

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



Joined: 02 Aug 2007
Posts: 31

View user's profile Send private message

Compiler Calls to Built-In Functions
PostPosted: Tue Sep 04, 2007 1:24 pm     Reply with quote

How does the compiler process calls to the built in functions? For instance, if I call clear_interrupt() or input_state() in my main program AND in my interrupt routine, should I:

- receive a warning from the compiler telling me that I've made a call to a function that could be in use?

- not receive an error because the compiler creates a secondary instance of the function for interrupt purposes?

- not receive an error because the command is not really a function but a macro and code substitution is used?

- or is everything designed such that the function can be interrupted and called again during the interrupt without causing corruption issues?

I just want to make sure that there is no chance of unexpected data corruption during my interrupt routines.
_________________
New:

Compiler Version: 5.078
IDE Version: MPLAB X V4.15
Devices: PIC18LF****

Old:

Compiler Version: 4.121
IDE Version: MPLAB IDE V8.63
Devices: PIC18LF****
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Sep 04, 2007 1:44 pm     Reply with quote

See this FAQ article:
http://www.ccsinfo.com/faq.php?page=interrupts_disabled
Fusillade



Joined: 02 Aug 2007
Posts: 31

View user's profile Send private message

PostPosted: Tue Sep 04, 2007 3:00 pm     Reply with quote

So if I call the CCS supplied clear_interrupt() function outside of the interrupt and inside of the interrupt and I do not get a warning message from the compiler, then I should have no problems even if the clear_interrupt function is the process which is interrupted?
_________________
New:

Compiler Version: 5.078
IDE Version: MPLAB X V4.15
Devices: PIC18LF****

Old:

Compiler Version: 4.121
IDE Version: MPLAB IDE V8.63
Devices: PIC18LF****
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Sep 04, 2007 3:06 pm     Reply with quote

The clear_interrupt() function will generate one line of ASM code.
It's never going created as a separate routine by the compiler.
The compiler will always insert the ASM code as an inline statement
every time it sees that function.
Fusillade



Joined: 02 Aug 2007
Posts: 31

View user's profile Send private message

PostPosted: Tue Sep 04, 2007 4:20 pm     Reply with quote

Taking what you have told me and running with it, I've come to the following conclusion.

All CCS functions that do not require a library will use code substitution (inserting a single or multiple lines of assembly code in place of the function) and all other functions which require a library will generate a call. Any of the functions which require a call and are used in both the main program and the interrupts are likely to generate the warning message. So as long as I avoid functions which require a library, then I should be safe.
_________________
New:

Compiler Version: 5.078
IDE Version: MPLAB X V4.15
Devices: PIC18LF****

Old:

Compiler Version: 4.121
IDE Version: MPLAB IDE V8.63
Devices: PIC18LF****
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Sep 04, 2007 4:24 pm     Reply with quote

Or invoke the library a 2nd time, to generate another instance of it.
See this FAQ article:
http://www.ccsinfo.com/faq.php?page=delay_in_interrupt
Fusillade



Joined: 02 Aug 2007
Posts: 31

View user's profile Send private message

PostPosted: Tue Sep 04, 2007 4:46 pm     Reply with quote

Thanks for all your help.

I've been burned in the past because of the way some C compilers process certain commands and so I tend to be a bit cautious. What can I say, I like it best when there are no surprises. Wink
_________________
New:

Compiler Version: 5.078
IDE Version: MPLAB X V4.15
Devices: PIC18LF****

Old:

Compiler Version: 4.121
IDE Version: MPLAB IDE V8.63
Devices: PIC18LF****
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