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

How to debug memory corruption?

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



Joined: 13 Apr 2011
Posts: 417

View user's profile Send private message

How to debug memory corruption?
PostPosted: Mon Jul 13, 2015 7:54 am     Reply with quote

I'm having a issue with inside an struct

Code:
struct GPRS{
    short Reset;
    short StartSIM900;
    char  IP_Attemps;
    short ComFromSMS;
    short IDxError;
    char  SMS_Phone[15];
    short ChkError;
    short Responder;
    short MassiveAnswer;
    char Step;
    short ShutGPRS;
    char VectorTypeArray[7];
    char VectorActual;
    short AllVectorsInit;
    char GPRS_Step;
    char Pendientes;
    short UnderBit;
}GPRS_Status;


The variable VectorTypeArray[7] is set to zero one by one every time that a CCP interrupt ends.

The compiler version is 5.025.

I'm using this variable only inside an interrupt routines

I think that can be a issue with the FSR register.

I wonder if there any way to make a breakpoint when a variable change to detect what line of code is messing with this variable.
_________________
Electric Blue
Ttelmah



Joined: 11 Mar 2010
Posts: 19338

View user's profile Send private message

PostPosted: Mon Jul 13, 2015 9:10 am     Reply with quote

What processor?.

Generally, there is no simple debugging method to find this.

The compiler/chip does not support bit aligned variables. So you will be wasting bytes as the compiler has to use 2 bits for the first two shorts, then byte/word align (depending on the chip) for the characters.
Better to organise your data so things are easier to align:
Code:

struct GPRS{
    char  SMS_Phone[15];
    char  IP_Attemps;
    char VectorTypeArray[7];
    char GPRS_Step;
    char Pendientes;
    char VectorActual;
    char Step;
    short Reset;
    short StartSIM900;
    short ComFromSMS;
    short IDxError;
    short ChkError;
    short Responder;
    short MassiveAnswer;
    short ShutGPRS;
    short AllVectorsInit;
    short UnderBit;
}GPRS_Status;
E_Blue



Joined: 13 Apr 2011
Posts: 417

View user's profile Send private message

PostPosted: Mon Jul 13, 2015 9:31 am     Reply with quote

The processor is PIC18F67j50.

Thanks for the tip; I tried and get this results.

Before the change

ROM used 37702 RAM used 2614

After the change(reorder shorts)

ROM used 37792 RAM used 2608.

I don't get why use more ROM, I did not change the code. Confused
_________________
Electric Blue
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