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

Program execution and how to trace?

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



Joined: 08 Sep 2003
Posts: 105
Location: New Castle, DE

View user's profile Send private message

Program execution and how to trace?
PostPosted: Wed Sep 13, 2017 7:11 pm     Reply with quote

I'm working with the dsPIC33EP512GP506 using compiler 5.072.

I'm having issues with my code either getting lost or it is stuck in some loop that I'm not see and the WDT is resetting.
So I would like a way to trace the execution and retrieve it after reset.
I know that trace execution will be difficult and in some case not feasible at all.

But I was searching the forum and found 2 post that Ttelmah tells how to preserve a RAM locations after reset.
In this post he talks about how to accomplish this.

http://www.ccsinfo.com/forum/viewtopic.php?t=55813&highlight=trace

So my question is Ttelmah do you or anyone have a small example of code with this type of trace setup?

Thanks
Ttelmah



Joined: 11 Mar 2010
Posts: 19255

View user's profile Send private message

PostPosted: Thu Sep 14, 2017 12:50 am     Reply with quote

It's very simple....
Code:

//processor define
//fuses & clock

int16 fred;

void main(void)
{
    //At this point 'fred' will contain a unknown value on first boot
    //but will still contain what it had in it on a subsequent boot
    int8 why;
    why=restart_cause();
    if (why==RESTART_POWER_UP)
    {
        fred=0; //Initialise fred on power on
    }
    //Now 'fred' will contain '0' on the first power up and whatever
    //the code leaves in it on other restarts
    printf ("Fred is %d\n"); //either display it or put a break here

    while (TRUE)
    {
        fred=1;
        //now do what you want and set fred to different values
        //when the code restarts, fred will contain what it last had   

   }
}


The key point is that a global variable always sits iin the same RAM location. Provided you do not tell the compiler to initialise it, nothing is done at boot (one exception - you must not use #ZERO_RAM), so it retains what it last contained.
Tom-H-PIC



Joined: 08 Sep 2003
Posts: 105
Location: New Castle, DE

View user's profile Send private message

PostPosted: Mon Sep 18, 2017 6:50 am     Reply with quote

Thank you Ttelmah
I will give it a go!
Tom-H-PIC



Joined: 08 Sep 2003
Posts: 105
Location: New Castle, DE

View user's profile Send private message

PostPosted: Tue Sep 19, 2017 9:16 am     Reply with quote

So the problem that I having now is if I'm not using “#ZERO_RAM” the program will not start and it gets hung-up.
So I'm using the CCS ICD-U64 and I only use it for programing and that is all.
After reprogramming the chip the code will get stuck in a loop and not enter the run loop also the reset button will not get it out of this. But if I do a power reset it start and runs fine. Also at that point I can do a reset using the reset button and it still starts and runs.
But all the variables in that location pointed to by the trace have been initialized to zero.
So are there things left in the registers or something I don’t know about?

Tom
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