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

int32 and printf problem

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







int32 and printf problem
PostPosted: Wed Mar 12, 2003 12:20 pm     Reply with quote

am using the PCH compiler v 3.074 to program the PIC18F258.
The parts of the program I am working on are working perfectly when they are used separately. When put all together they still work well apart from one thing: I use 2 printf commands for debugging in main() which should output a signed int32. the exact commands are

printf("mpos=\%lX\n\r",mposition);
printf("mpos=\%ld\n\r",mposition); //mposition is signed int32

When the program was still small in size both functions worked. At some point, after reaching about 20\% of ROM and 5-9\% of RAM (program is about 5kb in size) and without touching this portion of code, only the first printf would produce some output in hex while the second would always output 0. I tried several things and it seems that printf can only handle int16 with the \%ld option. The behaviour of printf reverts to normal only after reducing the size of the program, which is not an option. What can be done? Can I instruct the compiler to use a large memory model?
___________________________
This message was ported from CCS's old forum
Original Post ID: 12576
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

Re: int32 and printf problem
PostPosted: Wed Mar 12, 2003 12:56 pm     Reply with quote

:=am using the PCH compiler v 3.074 to program the PIC18F258.
:=The parts of the program I am working on are working perfectly when they are used separately. When put all together they still work well apart from one thing: I use 2 printf commands for debugging in main() which should output a signed int32. the exact commands are
:=
:=printf("mpos=\%lX\n\r",mposition);
:=printf("mpos=\%ld\n\r",mposition); //mposition is signed int32
:=
:=When the program was still small in size both functions worked. At some point, after reaching about 20\% of ROM and 5-9\% of RAM (program is about 5kb in size) and without touching this portion of code, only the first printf would produce some output in hex while the second would always output 0.
--------------------------------------------------------------

Here's a portion of the versions list. I don't see any
bug fixes for printf. I notice they don't even list
your version, 3.074. They had recently added sprintf().
Maybe they broke printf when they did that. I would guess
that your only choice is to write your own ascii hex output
routine, or to upgrade.

You could write your own ltoax() routine relatively quickly.

<PRE>
3.072 Some problems with types being mis-interpreted is fixed
3.072 SPRINTF has been added
3.073 PCH arrays may now be any size (as long as there is RAM)
3.073 Support added for newest PIC18 parts
3.075 Added memory management functions such as malloc()
3.075 PIC18 arrays over 128 bytes is now supported
3.076 PIC18 outputs now use the LATch registers
3.076 Some array access problems (since 3.075) are fixed
3.076 getenv() has been added
3.077 Some array access problems created in the last couple of versions are fixed
3.078 PIC18 input_x() broke in 3.077 is now fixed
3.078 IDE color syntax improvments and auto-indentation added
3.079 Various bugs dealing with the correct typing for more complex arrays is fixed
3.080 A bug concerning assigning the result of a & to a bit field of a struct is fixed
3.081 PIC18 fuse settings in the .HEX file now support newer configuration words
3.082 PCW IDE Improvments
3.084 Pointer arithmetic on pointers to multi-byte elements is fixed
3.085 Some structure assignment problems (with pointers to structures) are fixed
</PRE>
___________________________
This message was ported from CCS's old forum
Original Post ID: 12577
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