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

Warning 216

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



Joined: 13 Jun 2007
Posts: 1

View user's profile Send private message

Warning 216
PostPosted: Wed Jun 20, 2007 12:56 pm     Reply with quote

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
Code:
p = &gs[ga][gb];


If I change it to something that do the same work
Code:
p = gs + ga * 128 + gb;
the error is gone.

Why ?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jun 20, 2007 1:33 pm     Reply with quote

You need to post a compilable test program, showing all variable
declarations, #include, #fuses, etc., statements.

Also post your compiler version.
Ttelmah
Guest







PostPosted: Thu Jun 21, 2007 3:14 am     Reply with quote

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
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