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

problem with structs and interrupts

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



Joined: 04 Apr 2006
Posts: 117
Location: Brasil

View user's profile Send private message Send e-mail MSN Messenger

problem with structs and interrupts
PostPosted: Tue May 02, 2006 2:37 pm     Reply with quote

Hello people..

I was working on a software that needed to count the real time (RTC Software), so i was using structs and i have many problems with this.

the structs were like (for example):

Code:


struct TTime
{
      unsigned int Seg;
      unsigned int Min;
      unsigned int Hour;
};

struct TAlarm
{
       struct TTime Time;
       boolean AlarmFlag;
};

struct TClock
{
      struct TTime Time;
};


struct TAlarm Alarm;
struct TClock Clock;


i was counting the time using Timer0 interrupt on overflow, and everytime that i changed the value of Clock or Alarm's time (Clock.Time.Min or Alarm.Time.Hour) Timer0 stops to counting and my program becomes crazy.. whats the problem with that ? i wouldnt use the same Name of one type of struct on diferents structs ??

like struct TTime Time in both struct TAlarm and TClock ?

and i was having another problem with local variables. i wrote a menu function to work with lcd display and my function returns a value of a choice.

if i declares the variable that will take this value and return it from the function its value is lost. It just work if i use this variable like a global variable.

so, that is it...

hope to someone has answers for these questions..

regards.
_________________
Andre
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue May 02, 2006 3:09 pm     Reply with quote

Can you post a small test program that shows the problem ?
Post a complete program that can be copied and pasted into MPLAB
and compiled with no errors. It must have all the necessary
#include, #use, and #fuses statements. Make the program be
very short -- a maximum of 50 lines. Use a printf statement
to display the problem. Indicate the line of code that you think
is causing the problem with a comment.

Also post your compiler version. You can find the version number
at the top of the .LST file for your project. The .LST file is in your
project directory. The version will be a number like 3.191 or 3.249, etc.
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