View previous topic :: View next topic |
Author |
Message |
Fusillade
Joined: 02 Aug 2007 Posts: 31
|
Compiler Calls to Built-In Functions |
Posted: Tue Sep 04, 2007 1:24 pm |
|
|
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**** |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
![](templates/subSilver/images/spacer.gif) |
Fusillade
Joined: 02 Aug 2007 Posts: 31
|
|
Posted: Tue Sep 04, 2007 3:00 pm |
|
|
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**** |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Sep 04, 2007 3:06 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
Fusillade
Joined: 02 Aug 2007 Posts: 31
|
|
Posted: Tue Sep 04, 2007 4:20 pm |
|
|
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**** |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
![](templates/subSilver/images/spacer.gif) |
Fusillade
Joined: 02 Aug 2007 Posts: 31
|
|
Posted: Tue Sep 04, 2007 4:46 pm |
|
|
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](images/smiles/icon_wink.gif) _________________ 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**** |
|
![](templates/subSilver/images/spacer.gif) |
|