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

Fault in CCS compiler version 3.136, HELP ME!!!!

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



Joined: 02 Oct 2003
Posts: 1

View user's profile Send private message Send e-mail

Fault in CCS compiler version 3.136, HELP ME!!!!
PostPosted: Wed Jan 14, 2004 6:35 am     Reply with quote

Crying or Very sad
Dear programmers,

Iam using a PIC16F877A processor in combination with CCS compiler version 3.316.

One of the code i use is the code below:

while ((Fl24HourRst) && (!FlWrtLastErrEep) && (!FlRunHigh1h) && (!FlRunLow1h) && (!FlBurnStrt));

Description:
Fl24HourRst = bit 7 of a byte (placed in bank 1 by the compiler)
FlWrtLastErrEep = bit 5 of a byte (placed in bank 0 by the compiler)
FlRunHigh1h = bit 0 of a byte (placed in bank 2 by the compiler)
FlRunLow1h = bit 1 of a byte (placed in bank 2 by the compiler)
FlBurnStrt = byte ((placed in bank 2 by the compiler)

Normally when Fl24HourRst = 1, FlWrtLastErrEep = 0, FlRunHigh1h = 0, FlRunLow1h = 0 and FlBurnStrt = 0 the programm has to stay inside the loop, but my programm doesn't.

I have checked the assemblycode and now i discovered that the compiler is not seting the right bank when jumping from the end of the while loop to the beginning of the while loop.

What is happening?
Isn't my code right?
Are there to many conditions in the while function?
Does the compiler contain errors?
Etc...

Iam using #device *=16

Please help me as soon as possible, because my EEPROM is overwritten sometimes.

Thanks!

Ivar
neil



Joined: 08 Sep 2003
Posts: 128

View user's profile Send private message

An idea
PostPosted: Wed Jan 14, 2004 10:17 am     Reply with quote

Hi Ivar, there are rather a lot of conditions in that one expression, might be a case of function overloading but I think it will handle them. Clearly if the compiler is putting the flags in different banks, it makes for more instruction cycles because of all the bank switching.

Try putting your flags into a struct of bit variables, I think this will make the compiler assign the bits sequentially to one byte so no bank switching is necessary between parts in the expression. However, if you are doing this, it might be easier to apply a mask for the condition you are looking for, instead of bit testing each flag individually. apply to the whole byte and exor it. You may need to mask out the 'don't cares' with an AND mask.

eg.

    struct flags{
    boolean Fl24HourRst, FlWrtLastErrEep, FlRunHigh1h, FlRunLow1h, FlBurnStrt;
    int unused:3;
    } flag_byte;

    Now, for the logic states in your expression apply a mask of: xxx10000. So to test the state:
    do "flag_byte &= 0b00011111;
    if((flag_byte ^ 0b00010000)==0){ do stuff }"

    This will be true when the structure of flags matches your test mask. I think this will be more efficient code, but not as easily readable.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jan 14, 2004 12:51 pm     Reply with quote

If he uses the structure, he can also write the test like this,
and keep his existing readability.

Code:
while ((flag_byte.Fl24HourRst)  &&
       (!flag_byte.FlWrtLastErrEep) &&
       (!flag_byte.FlRunHigh1h) &&
       (!flag_byte.FlRunLow1h) &&
       (!flag_byte.FlBurnStrt));


This will produce ASM code like this:
Code:
0014 1C21       BTFSS  21.0
0015 281E       GOTO   01E
0016 18A1       BTFSC  21.1
0017 281E       GOTO   01E
0018 1921       BTFSC  21.2
0019 281E       GOTO   01E
001A 19A1       BTFSC  21.3
001B 281E       GOTO   01E
001C 1E21       BTFSS  21.4
001D 2814       GOTO   014
Ivar Boer
Guest







Fault in CCS compiler version
PostPosted: Thu Jan 15, 2004 3:01 am     Reply with quote

Crying or Very sad
Thanks for your information, but this information does not help me to determine the reason of my problem. Maybe the complier has made more wrong code which i don't know.

Could it be a compiler error????

Thanks.

Ivar
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Thu Jan 15, 2004 8:45 am     Reply with quote

A compiler error is certainly a possibility. They are common in any uC compiler. But my first step would be to break that long line into smaller more digestable pieces. Then look at the assembler and see just what the compiler is doing. Then you will be able to find a way to get the behavior you want. The procedure is the same whether it is a compiler error or more likely a programmer error.
_________________
The search for better is endless. Instead simply find very good and get the job done.
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