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

RTCC ???

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



Joined: 08 Sep 2003
Posts: 21

View user's profile Send private message

RTCC ???
PostPosted: Mon Jul 14, 2003 8:31 am     Reply with quote

To create a system clock to memorize the date/time I used a method as this used in computer bios system.
Into a setup variable I saved the second's number from a known date ... after I add the rtcc seconds.
I've compiled a software starting from CCS example :

#if defined(__PCM__)
#include <16F877.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7) // Jumpers: 8 to 11, 7 to 12

#elif defined(__PCH__)
#include <18F452.h>
#fuses HS,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7) // Jumpers: 8 to 11, 7 to 12
#endif

#define INTS_PER_SECOND (32000/(4*256*256))

byte seconds; // A running seconds counter
byte int_count; // Number of interrupts left before a second has elapsed


#int_rtcc // This function is called every time
void clock_isr() { // the RTCC (timer0) overflows (255->0).
// For this program this is apx 76 times
if(--int_count==0) { // per second.
++seconds;
int_count=INTS_PER_SECOND;
}
}

void main(void)
{
byte start;
long int i;
int_count=INTS_PER_SECOND;
set_rtcc(0);
setup_counters( RTCC_INTERNAL, RTCC_DIV_256 | RTCC_8_BIT);
enable_interrupts(INT_RTCC);
do {
start=seconds;
for(i=0;i!=500;i++)
i += 2;
start = seconds-start;
} while (TRUE);
}

There is a big problem ....
When I compile it and I run on ICD 2 the software is OK but the second's number don't change (seconds it's always 0).
Why the interrupt don't run correctly with this source ?

Thank you.....
___________________________
This message was ported from CCS's old forum
Original Post ID: 144515949
Douglas Kennedy



Joined: 07 Sep 2003
Posts: 755
Location: Florida

View user's profile Send private message AIM Address

Re: RTCC ???
PostPosted: Mon Jul 14, 2003 9:24 am     Reply with quote

:=To create a system clock to memorize the date/time I used a method as this used in computer bios system.
:=Into a setup variable I saved the second's number from a known date ... after I add the rtcc seconds.
:=I've compiled a software starting from CCS example :
:=
:=#if defined(__PCM__)
:=#include <16F877.h>
:=#fuses HS,NOWDT,NOPROTECT,NOLVP
:=#use delay(clock=20000000)
:=#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7) // Jumpers: 8 to 11, 7 to 12
:=
:=#elif defined(__PCH__)
:=#include <18F452.h>
:=#fuses HS,NOPROTECT,NOLVP
:=#use delay(clock=20000000)
:=#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7) // Jumpers: 8 to 11, 7 to 12
:=#endif
:=
:=#define INTS_PER_SECOND (32000/(4*256*256))
:=
:=byte seconds; // A running seconds counter
:=byte int_count; // Number of interrupts left before a second has elapsed
:=
:=
:=#int_rtcc // This function is called every time
:=void clock_isr() { // the RTCC (timer0) overflows (255->0).
:= // For this program this is apx 76 times
:= if(--int_count==0) { // per second.
:= ++seconds;
:= int_count=INTS_PER_SECOND;
:= }
:=}
:=
:=void main(void)
:={
:= byte start;
:= long int i;
:= int_count=INTS_PER_SECOND;
:= set_rtcc(0);
:= setup_counters( RTCC_INTERNAL, RTCC_DIV_256 | RTCC_8_BIT);
:= enable_interrupts(INT_RTCC);
:= do {
:= start=seconds;
:= for(i=0;i!=500;i++)
:= i += 2;
:= start = seconds-start;
:= } while (TRUE);
:=}
:=
:=There is a big problem ....
:=When I compile it and I run on ICD 2 the software is OK but the second's number don't change (seconds it's always 0).
:=Why the interrupt don't run correctly with this source ?
:=
:=Thank you.....
Read the manual under enable_interrupts (GLOBAL)
___________________________
This message was ported from CCS's old forum
Original Post ID: 144515950
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