![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
mlanglais
Joined: 13 Jun 2007 Posts: 1
|
Warning 216 |
Posted: Wed Jun 20, 2007 12:56 pm |
|
|
Hi
I have written an isr. All was fine, but suddently, it pops me warning 216 [@MUL1616].
This is the code
Code: |
int16 ga;
int16 gb;
SomeStruct gs[5][128] = {...}
...
#int_timer3
vois isr_timer3(void)
{
SomeStruct* p;
...
p = &gs[ga][gb];
...
}
|
The faulty line is
If I change it to something that do the same work Code: | p = gs + ga * 128 + gb; | the error is gone.
Why ? |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Jun 20, 2007 1:33 pm |
|
|
You need to post a compilable test program, showing all variable
declarations, #include, #fuses, etc., statements.
Also post your compiler version. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Thu Jun 21, 2007 3:14 am |
|
|
The warning, is a 'classic'. It ties up with the PIC, not allowing reentrancy to a function (you can't call a function inside itself), and so, if a function is called inside an interrupt, then interrupts are disabled around the same function used outside the interrupt, with this warning being given.
The function concerned here, is the 16*16bit multiplier routine.
Your 'alternative' line, though it appears the same, will code totally differently. The compiler is 'smart' with regards to *128 (and any binary multiplication), and knows this can be replaced, with a seven bit left shift, when dealing with a 'constant'. Hence it does so. However, when dealing with the 'array', a standardised array access routine is used, which uses the multiplication code.
In fact the replacement, will be faster/smaller, and avoid the re-entrancy problem!.
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
|