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

RTC does not run when debugging?
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Eduardo__



Joined: 23 Nov 2011
Posts: 197
Location: Brazil

View user's profile Send private message

RTC does not run when debugging?
PostPosted: Mon Jun 25, 2012 11:41 am     Reply with quote

I'm using MPLAB with CCS C and ICD2 programmer/debugger.
My uC is the PIC18F26J11.

Despite of 32kHz clock is running (I checked with an oscilloscope), it seems that RTC does not run (does not count seconds, days...) when I stop the program.

Anyone knows whether is it possible to get RTC running even when debugging (even when it is stopped at a breakpoint)?


Thanks a lot for any idea =D
_________________
Eduardo Guilherme Brandt
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jun 25, 2012 11:48 am     Reply with quote

Use Google to search the Microchip forum. Use their forum as a KnowledgeBase. Search for this:
Quote:
site:microchip.com/forums RTC OR RTCC debug OR debugger OR debugging

Then you find threads like this:
http://www.microchip.com/forums/m442150-print.aspx
There might be other useful threads.
Eduardo__



Joined: 23 Nov 2011
Posts: 197
Location: Brazil

View user's profile Send private message

PostPosted: Mon Jun 25, 2012 8:16 pm     Reply with quote

Thank you very much.

Just one thing more:

With U40 Programmer/Debugger, RTC runs and counts date/time when uC stopped in a breakpoint?

thanks.
_________________
Eduardo Guilherme Brandt
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Tue Jun 26, 2012 9:36 am     Reply with quote

Quote:

it seems that RTC does not run (does not count seconds, days...) when I stop the program.


as i believe Richard Feynman once famously said:
"you can't do just ONE thing at a time"

the debugger has the potential to interfere with any aspect of your program, but ESPECIALLY in the time domain.

i have never used debug break points and probably never will.

there are other ( and IMHO BETTER) methods to figure out programming problems than carrying the overhead and operating interference that insertion of debug code creates. If you don't understand where your program is going wrong , adding more uncertainty to it's execution does not seem like a benefit, at least to me.

leds that flash , pins that can be read toggling at a given rate on on
an oscope, and serial conditional printf() scaffolding ALL come quickly to mind.

Smile
Eduardo__



Joined: 23 Nov 2011
Posts: 197
Location: Brazil

View user's profile Send private message

PostPosted: Tue Jun 26, 2012 10:23 am     Reply with quote

Thank you Mr. Asmboy.

I think that you´re right. In this case, debugger seems to stop something in uC that could work even in a Sleep.

But I´ve already programmed without debugger. After I begun using debugger, I would like never have to come back again.

very thanks again. I appreciate CCS forum help Smile
_________________
Eduardo Guilherme Brandt
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Tue Jun 26, 2012 10:56 pm     Reply with quote

There is a setting in MPLAB under the ICD menus to "freeze" or "halt" peripherals while the debugger is running that you can turn off.

So things like timers and clocks keep spinning -- although their code may not.

Check it out..
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
Eduardo__



Joined: 23 Nov 2011
Posts: 197
Location: Brazil

View user's profile Send private message

PostPosted: Wed Jun 27, 2012 7:07 am     Reply with quote

Very thanks Mr. bkamen. You solved the question.

Under MPLAB menu, I click in "Debugger", then click "Settings", tab "Freeze".
I´ve not tested it yet, but Thank you a lot!
_________________
Eduardo Guilherme Brandt
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Wed Jun 27, 2012 11:34 pm     Reply with quote

Eduardo__ wrote:
Very thanks Mr. bkamen. You solved the question.

Under MPLAB menu, I click in "Debugger", then click "Settings", tab "Freeze".
I´ve not tested it yet, but Thank you a lot!


That's why were here...

:D Don't forget to change the subject of your original post to include "[SOLVED]" so others can find it.

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
Eduardo__



Joined: 23 Nov 2011
Posts: 197
Location: Brazil

View user's profile Send private message

PostPosted: Thu Jun 28, 2012 6:42 am     Reply with quote

Mr bkamen.

Just one more question: Do you´ve MPLAB?
I do not know why my MPLAB ICD2 does not leave me to change Peripheral Freezing (it not allows uncheck it). Do you know why?
_________________
Eduardo Guilherme Brandt
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Thu Jun 28, 2012 8:26 pm     Reply with quote

Eduardo__ wrote:
Mr bkamen.

Just one more question: Do you´ve MPLAB?
I do not know why my MPLAB ICD2 does not leave me to change Peripheral Freezing (it not allows uncheck it). Do you know why?


yes, I use MPLAB exclusively.

As for your question, I would have to go check. It may not work with some devices or some other MPLAB feature...

I can't get to it right now -- another project is clogging up my bench.

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
Eduardo__



Joined: 23 Nov 2011
Posts: 197
Location: Brazil

View user's profile Send private message

PostPosted: Fri Jun 29, 2012 7:30 am     Reply with quote

thanks Mr Bkamen for helping.
You can answer when you could, no problem.
I actually use PIC18F24J11.
_________________
Eduardo Guilherme Brandt
hemasc_



Joined: 01 Aug 2012
Posts: 15
Location: Brazil

View user's profile Send private message Visit poster's website

PostPosted: Wed Aug 01, 2012 8:28 am     Reply with quote

Edward (rs), I want to use 18F87k90 RTC.

I would like to configure hour and date.

Can you send me some example?


Last edited by hemasc_ on Wed Aug 01, 2012 9:35 am; edited 1 time in total
Eduardo__



Joined: 23 Nov 2011
Posts: 197
Location: Brazil

View user's profile Send private message

PostPosted: Wed Aug 01, 2012 9:01 am     Reply with quote

Dear hemasc_, you need to write in same forum language(english). Sorry, but these´re rules.

Yes, it´s very very simple with CCS.

There is a default time/date structure(see. 18F87k90 header file(18F87k90.h)).

Code:
typedef struct {
   int8 tm_year;
   int8 tm_yday;  // Not used by built in functions
   int8 tm_mday;
   int8 tm_mon;
   int8 tm_hour;
   int8 tm_wday;
   int8 tm_sec;
   int8 tm_min;
   int8 tm_isdst; // Not used by built in functions
} rtc_time_t;


But there are commands for reading from and writing into PIC´s rtc peripherals, like
Code:
rtc_write(), rtc_alarm_read(), rtc_alarm_write()


Do not forget to put a 32kHz external Crystal and enable PIC´s rtc.
You can enable RTC interrupt if you want to. It can be useful for alarm events:
Code:

#fuses HS,RTCOSC_T1,HSPLL             

/***********************************/
void init() {
   setup_rtc(RTC_ENABLE,0);                  //enables internal RTCC
   //enable_interrupts(INT_RTC);             //enable RTC interrupts
   enable_interrupts(GLOBAL);                //enable interrupts
}
/***********************************/
//inside main programm

void main() {
rtc_time_t  Clock;      //date/time structured variable

init();

Clock.tm_Hour=10;
Clock.tm_min=30;
Clock.tm_sec=0;

rtc_write(&Clock),

while(true) {

  rtc_read(&Clock);
  fprintf(" %02u:%02u:%02u      \r\n",
         Clock.tm_hour, Clock.tm_min, Clock.tm_sec );
  //Connect to windows hyperterminal´s
  //Donp´t forget to enable and set PIC RS232 serial configuration before


}
}



There is an Example file that comes with CCS documentation.
Good luck
_________________
Eduardo Guilherme Brandt
hemasc_



Joined: 01 Aug 2012
Posts: 15
Location: Brazil

View user's profile Send private message Visit poster's website

PostPosted: Wed Aug 01, 2012 9:52 am     Reply with quote

I used the CCS example and I can write and read, but after some seconds, I read again and value of second doesn't modify.

I used RTCOSC_T1 fuse

I have a crystal of 32kHz in hardware.

I think the clock is not enabled.
Eduardo__



Joined: 23 Nov 2011
Posts: 197
Location: Brazil

View user's profile Send private message

PostPosted: Wed Aug 01, 2012 10:20 am     Reply with quote

Check whether clock is running(with an oscilloscope).

Check whether RTC fuse is in(check before writing it to uC, in programmer view fuses).
_________________
Eduardo Guilherme Brandt
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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