View previous topic :: View next topic |
Author |
Message |
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
#INLINE fixes the warning , but why ??? |
Posted: Wed Jan 28, 2015 2:45 pm |
|
|
Program build with xtal oscillator of 10mhz 18f2525
timer 0,1,2 have simple flag based #int handlers
there is NO #INT handler for timer3...
there are NO delay_xx calls of any kind ( _MS _US _CYCLES - nothing !!)
.LST hdr
CCS PCH C Compiler, Version 5.036, 15300 28-Jan-15 15:12
Filename: D:\A_FW2\Q8.lst
ROM used: 20222 bytes (41%)
Largest free fragment is 28926
RAM used: 487 (12%) at main() level
518 (13%) worst case
Stack used: 6 locations (4 in main + 2 for interrupts)
Stack size: 31
Code: |
void Wait25MS(unsigned int8 howmany){
#bit TMR3IF=0xFA1.1
set_timer3(0);
tmr3if=0;
while(howmany){
if (TMR3IF){
tmr3if=0;
--howmany;
}
}
}
// even this junk substitute causes the same warning.....
void Wait25MS(unsigned int8 howmany){
while(howmany) --howmany;
}
|
then this .ERR file
>>> Warning 203 "Q8.c" Line 1900(1,1): Condition always TRUE ( while(1) )
>>> Warning 216 "Q8.c" Line 2461(1,2): Interrupts disabled during call to prevent re-entrancy: (Wait25MS)
Memory usage: ROM=41% RAM=12% - 13%
0 Errors, 2 Warnings.
Build Successful.
BTW: line 2461 is the very last line of MAIN() and the program file itself...
what is there about calling a non interrupting delay function that causes this ??
BTW: i get the exact same warning in Ver 4.141 too
Makes no sense to me........
BUT making the function
#INLINE
fixes the re-entrant warning
and.
then it compiles with just the one silly warn about while(1);
huh ?? |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Jan 28, 2015 3:21 pm |
|
|
I didn't get any warnings. Tested with vs. 5.036.
Quote: | Executing: "C:\Program files\Picc\CCSC.exe" +FH "PCH_Test.c" +DF +LY -T -A +M -Z +Y=9 +EA -EW #__18F2525=TRUE
Memory usage: ROM=0% RAM=0% - 0%
0 Errors, 0 Warnings.
Build Successful.
Loaded C:\Program Files\PICC\Projects\PCH_Test\PCH_Test.cof.
BUILD SUCCEEDED: Wed Jan 28 13:18:58 2015
|
Note while(TRUE) removes the other warning.
Test program:
Code: |
#include <18F2525.h>
#fuses HS,NOWDT
#use delay (clock=10M)
void Wait25MS(unsigned int8 howmany){
#bit TMR3IF=0xFA1.1
set_timer3(0);
tmr3if=0;
while(howmany){
if (TMR3IF){
tmr3if=0;
--howmany;
}
}
}
//==========================
void main()
{
while(TRUE);
} |
|
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19375
|
|
Posted: Wed Jan 28, 2015 4:06 pm |
|
|
It would suggest wait25ms, is being called inside an interrupt somewhere. If you call the routine in the main code, and also inside an interrupt routine, you will get the interrupt_disabled warning. This is because code cannot be called from inside 'itself'. Search here.
Since it does not use any variables, declaring it as #inline, will allow it to be used in both places, since it then becomes two separate routines. |
|
![](templates/subSilver/images/spacer.gif) |
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Wed Jan 28, 2015 4:38 pm |
|
|
Just Got it: Thanks PCM_P
this is an inherited code mess being altered for a brand new client
- AND i had done a blind quick S&R job on to get rid of delay_MS () salted throughout the program , using timer3 for 25 msec increments of delay
and did not catch a function calling a function calling the function in question in the nest-- ;-((
AND MR. T was correct - i overlooked the stack situation inside the #int
the upside is i can now restructure the #int handler to do the deed
in question in MAIN() with just a bit flag set.
T H A N K S to you both for the kind analysis |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19375
|
|
Posted: Thu Jan 29, 2015 1:50 am |
|
|
Inherited code.....
Trying to work out an epithet for this without being rude.
Anyway, you 'step forwards'. ![Smile](images/smiles/icon_smile.gif) |
|
![](templates/subSilver/images/spacer.gif) |
drh
Joined: 12 Jul 2004 Posts: 192 Location: Hemet, California USA
|
|
Posted: Thu Jan 29, 2015 9:09 am |
|
|
It's always fun trying to figure out what another person intended their undocumented code to do, then figure out why is doesn't do that. Then correct or re-write to make the customer happy. Even more fun getting paid to do that. _________________ David |
|
![](templates/subSilver/images/spacer.gif) |
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Thu Jan 29, 2015 9:24 am |
|
|
Code: |
Inherited code.....
|
has anybody else run into 'comments' in alien code only to find that they say more about the authors degree ( or lack ) of skill than-
about the code it purports to describe ??
It is especially difficult when the circuitry allegedly under control
is deficient too. Good code can't fix a bad circuit, and making 'hacks' to an existing circuit board at the same time as reworking the code itself is extra fun to be had , with "inheritance" ........... |
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9176 Location: Greensville,Ontario
|
|
Posted: Thu Jan 29, 2015 10:07 am |
|
|
some times it's easier,faster, cheaper.... to just 'start from scratch' especially these days with hi speed PCs, CCS C compiler and 'instant' programming unlike the good old dayze of diode based boot 'proms', papertape readers, real 'core'.....
sigh
I miss them!
jay |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19375
|
|
Posted: Thu Jan 29, 2015 10:13 am |
|
|
The really fun one, is where you have what may be quite competent documentation, but it is in another language. Unfortunately a lot of technical terms are not translated by either programs or translators, unless you have one who 'knows' the specific stuff about a technical process. Trying to find a polyglot who is a specialist in a mix of fields like chemistry, electronics, industrial measurement, & optics, can be very hard indeed. Some of the automated translations are positively 'hysterical', on technical phrases.... |
|
![](templates/subSilver/images/spacer.gif) |
|