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

Even more obscure PCM compiler behaviour!

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







Even more obscure PCM compiler behaviour!
PostPosted: Fri Jan 30, 2009 7:49 am     Reply with quote

Hi all (again)

I am now tearing out what little hair I have left on this strange problem with the PCM compiler (Version 4.013), compiling code for a PIC16F876A. The section in question is below; the line marked 'This runs once' only runs once during execution, but the line marked 'This runs twice', quite obviously, is executed twice! I cannot see how the PIC can possibly run the end of a function twice, but the start only once (which is correct; this function is only called a single time), unless something funky is happening with the program counter. Can anyone shed some light on this? Please?

Code:

   tone(down);            // This code runs once!
   DS1337_set_datetime(&dt);
   putc(0xCC);
   get_bst_data(&dt);
   current_state = asleep;
   uart_power(off);
   tone(up);               // This runs twice!



Any suggestions incredibly gratefully received!

Angus
Angus
Guest







Re: Even more obscure PCM compiler behaviour!
PostPosted: Fri Jan 30, 2009 7:58 am     Reply with quote

OK, quick update!

I have tried commenting out each of the 3 function calls in between these 2 points in the code in turn. When any single function is commented out the code still does not run correctly (with the repeated call to tone(up)) but with all 3 commented out, it does run correctly. Go figure.

The code is pretty big (it uses almost 75% ROM) which is why I haven't posted a full listing. Am happy to if that helps with diagnosis!

Hairline is still receding nicely.


Angus
Ttelmah
Guest







PostPosted: Fri Jan 30, 2009 8:15 am     Reply with quote

Look at the sticky thread at the top of this forum about V4.
I'm afraid, that 4.013, is _not_ a working compiler.

Best Wishes
Angus
Guest







PostPosted: Fri Jan 30, 2009 8:33 am     Reply with quote

My apologies; I had not read this thread. Thanks for pointing it out!


Ttelmah wrote:
Look at the sticky thread at the top of this forum about V4.
I'm afraid, that 4.013, is _not_ a working compiler.

Best Wishes
Angus
Guest







PostPosted: Fri Jan 30, 2009 10:20 am     Reply with quote

OK, further update! I am now using version 4.085 of the compiler. Unfortunately I still have the same problem. I am now incredibly desperate to find a solution to this as it is a work project that is going to be demo'ed on Monday!

A prize in the post to the person who can find a solution! (Honestly, I'm not joking!)
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jan 30, 2009 11:10 am     Reply with quote

Post a short test program. Here's an example. Post as little code as
possible, while still putting in enough code to demonstrate the problem.
From your code, it looks like you're probably doing something with the
PIC's "sleep" mode. Maybe you've got a problem with waking it up.
Post a short program (don't post 100 lines). It must be compilable
without errors.
Code:

#include <16F876A.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

//======================================
void main()
{

printf("Hello World\n\r");

while(1);
}

Post something similar to this, except that it incorporates your code.
John P



Joined: 17 Sep 2003
Posts: 331

View user's profile Send private message

PostPosted: Fri Jan 30, 2009 12:54 pm     Reply with quote

Examine the LST file. You don't need to be fluent in assembly language to get an idea of what's happening, and it probably isn't going to be very much code anyway. Does any function leave the processor in a wacky state which will affect subsequent operation?

Try substituting one function for another. If executing the same code more than once won't cause failure, try the effect of running the same function five times instead of five different ones. Is the problem the result of just executing any function, or does it have to be a particular one?
Angus
Guest







PostPosted: Sat Jan 31, 2009 8:01 am     Reply with quote

Well firstly, thanks for the replies so far. I am in the middle of examining the LST file now, though the code is 1320 lines long so it's taking a while!

However, I have temporarily solved the problem by removing a fairly large block of code from the main() function (thankfully a non-essential bit), that was only run once at startup. The code consisted of several printf statements so presumably would have taked up quite a bit of ROM. The code is not related to the faulty area but removing it has fixed the problem.

It seems to my (unscientific) mind that as soon as CCS' code goes over a certrain point in size, strange things start to happen. Has anyone else had similar faults when compiling programs over approx. 6000 bytes of ROM?

Again, thanks for the replies so far; I am in the process of trying all your suggestions!


Angus 'almost bald' Thomson
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Sat Jan 31, 2009 9:20 am     Reply with quote

To add another suggestion, I would always use a debugger to trace program execution and itentify the cause of unexpected behaviour.
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