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 support@ccsinfo.com

PCH and few problems?

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



Joined: 08 Sep 2003
Posts: 66
Location: Toronto, Canada

View user's profile Send private message

PCH and few problems?
PostPosted: Fri Jan 10, 2003 9:20 am     Reply with quote

I bit the bullet and got PCH so I could upgrade my current project to use a PIC18F452 instead of the PIC16F877 as I was running out of bith ROM and RAM. The code port was quite easy with only a couple of routines and a few defines needing changed. I did however run into a couple of odd issues that seem to be compiler related issues;

Using both PCW and PCH version 3.129;

#rom defines work differently between PCW and PCH;

Under PCW;
#rom 0x2110 { 0x01, 0x55 }
results in EEPROM location 10 having 0x01 and 11 having 0x55.

However in PCH;
#rom 0xF000010 { 0x01, 0x55 }
results in EEPROM location 10 having 0x01 and 12 having 0x55.

and unfortunately also in PCH;
#rom 0xF000010 ( 0x0155 }
results in EEPROM location 10 having 0x55 and 11 having 0x01.


The biggest problem I encountered was when I restructured some of my code and started using arrays of structures. Things seem to work well unless you perform any math functions on these.

The statement
Values[Channel].Cycle++;
does not seem to work properly.

However the statements
i = Values[Channel].Cycle;
i++;
Valies[Channel].Cycle = i;
does work properly.

The biggest problem is that the results are not always predictable. Some code arrangements work and then when you add, or rearrange the code, then the same lines no longer work properly. I have noticed some other problems that may also be related but had difficulty trying to reproduce the results.

I have only tried this with int, long, and int32 variables as I wanted to stay away from floats. I did see some previous posts that noted that there seems to be a few porblems with floating point math and page switching. I also have better accuracy with the 32bit integer math than with single precision floating point.

I don't have the time right now to properly debug exactly what is going on, but I do intend to spend some time to see what is happening once I get some spare time.

For now I changed all my arrays of structures to different arrays, but the code is not as easily and I lose my binary mapping I use for data transfer to a PC, so I have to change that end as well.

Except for the above mentioned items the code conversion was quite simple and the PIC18 was a definite upgrade.

Has anyone else encountered these, or other, issues that may bite me unexpectedly?

-Troy
___________________________
This message was ported from CCS's old forum
Original Post ID: 10594
TSchultz



Joined: 08 Sep 2003
Posts: 66
Location: Toronto, Canada

View user's profile Send private message

PCH and few problems, update?
PostPosted: Sat Jan 11, 2003 6:16 am     Reply with quote

After looking into things a bit I found that the compiler is not always correctly assigning the variables correct data memory locations. I have almost all of my vars defined as global to try and force the compiler to not re-use memory locations if it is not needed. I also have any vars used in interrupt routines defined as static.

However in reviewing the SYM file I found the following;

I found that the compiler has actually placed the gloabal arrays and independant vars at the same memory locations. This seems to happen mostly with arrays of structures, but I have also found it with just plain single dimention arrays of longs.

I also found that compilter sometimes places the array accross data memory banks. I have not gone throught the actual listing output to see if it smart enough to place the page switching code to handle the page boundry cross.

The code for the math seems to work, but the contents get trashed becuase other vars use the same locations.

If I use #locate to manually force all the arrays to a higher bank and also ensure that none of them cross page boundaries then the odd math errors seem to go as well. If I remove the #locates then my problems come back.

I also tried defining all vars as static without the #locates and the problem persisted.

I am currently using 76\% of ROM and 684/728 bytes of RAM.

-Troy
___________________________
This message was ported from CCS's old forum
Original Post ID: 10611
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