![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
EdWaugh
Joined: 07 Dec 2004 Posts: 127 Location: Southampton, UK
|
Problem creating copy of integer math routines using #org |
Posted: Thu Jan 19, 2012 12:14 pm |
|
|
Hi all,
I'd like to create a second copy of the MUL1616 and DIV1616 math routines for use in an interrupt, I reviewed the post by PCM Programmer and Ttelmah and thought I got it right, but I still get the warning message.
The posts I'm referring to are:
http://www.ccsinfo.com/forum/viewtopic.php?t=25464&highlight=math+library
http://www.ccsinfo.com/forum/viewtopic.php?t=30539
I may be pushing my luck by expecting the compiler to automatically pull in all the functions my interrupt routine calls.
Anyway perhaps someone can shine some light on it for me:
Code: |
#pragma org 0x1000, 0x2000 default
#pragma int_ccp8
void ctrl_loop_40Hz()
{
output_high(GPIO0);
// Valve Actuator
va_ctrl();
va_he_poll();
// Pumps
bp_ctrl();
psp_ctrl();
output_low(GPIO0);
return;
}
#pragma org default
|
Also, is there a way to have the #org size itself so I don't need to provide an end address?
Thanks
Ed |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Jan 19, 2012 1:33 pm |
|
|
Comment out lines of code in your isr, one-by-one, and re-compile until
you find the offending line. Then post a small complete program that
shows the problem. |
|
![](templates/subSilver/images/spacer.gif) |
EdWaugh
Joined: 07 Dec 2004 Posts: 127 Location: Southampton, UK
|
|
Posted: Fri Jan 20, 2012 2:51 am |
|
|
I guess that means what I've done must look ok. I think the problem is that I have not explictly included the called functions in the #org section, I thought they would get pulled in.
So this does not give a warning:
Code: |
#pragma org 0x1000, 0x2000 default
#pragma int_ccp8
void ctrl_loop_40Hz()
{
psp_state.speed_error_p = (psp_speed_error * ws_params.psp_ctrl_p) / PSP_GAIN_POST_SCALAR;
}
#pragma org default
|
But this does:
Code: |
void mul_test()
{
psp_state.speed_error_p = (psp_speed_error * ws_params.psp_ctrl_p) / PSP_GAIN_POST_SCALAR;
}
#pragma org 0x1000, 0x2000 default
#pragma int_ccp8
void ctrl_loop_40Hz()
{
mul_test();
}
#pragma org default
|
Should the function get dragged into the #org automatically because I call it there? That would certainly be nice... Otherwise I guess I have to figure out how to tag several functions across different modules to be in the same #org.
Also, any syntax for not having to set the size of the #org? Surely the compiler could do this for me?
Cheers
Ed |
|
![](templates/subSilver/images/spacer.gif) |
EdWaugh
Joined: 07 Dec 2004 Posts: 127 Location: Southampton, UK
|
|
Posted: Fri Jan 20, 2012 8:02 am |
|
|
Hi all,
So I managed to make this work but putting each individual function explicitly within the same #org. This seems to work as the warnings go away and I can see interrupt calls going to an address within the area and non interrupt calls going to one outside the area. Can anyone recommend another way I can check this?
Also, any thoughts on the auto sizing of the ROM area? It would be much more convenient.
Also, also, how about the best location for the area? My boot loader is at the top of the space, I just selected 0x1000 randomly as away from 0x0000, but I guess I might get some defragmentation around the block.
All suggestions welcome.
Thanks
Ed |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19369
|
|
Posted: Fri Jan 20, 2012 8:20 am |
|
|
OK.
The 'point' about the #ORG, is that the code 'generated' by the functions in this section are stored in the defined memory area.
Problem is that if you define a subroutine, the code in the area 'calls' this subroutine, but the routine itself is 'generated' by the code that defines it, so is not inherently in the area defined.
You can make a function be included in the defined area, by declaring it as '#inline', which will force the code to actually be placed where it is called.
As a comment, stop using #pragma. _it has no effect at all on the CCS compiler_. It is only allowed so the compiler won't 'complain' when compiling code written for other compilers, and does nothing at all. Just makes the code look messy, and implies the author hasn't read the manual....
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|