jaya krishna
Member level 1
- Joined
- May 10, 2012
- Messages
- 41
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,286
- Location
- India,coimbatore
- Activity points
- 1,770
hi every one ,how to calculate the timer value 76 it show in below program its 1second and also how the clock _isr() loop will excute.there is [if(--int_count==0)]how it decremented the value of 76. i need clear explain of this program.
thanks advance
by
jai
PHP:
#if defined(__PCH__)
#include <18F452.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=40000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#endif
#define INTS_PER_SECOND 76 //Processor and clock specific
#define LED0 PIN_B0
int8 int_count=0;
int8 data = 0;
//////////////////////////////////////////////////
#int_rtcc
clock_isr()
{
set_tris_b(0x00);
//this block maintains timer variables with a resolution of a ~ 1 s
if(--int_count==0)
{
int_count=INTS_PER_SECOND; //reset
if(data == 0)
{
output_low(LED0);
data = 1;
// delay_ms(50);
}
else
{
output_high(LED0);
data = 0;
// delay_ms(50);
}
}
}
void main(void)
{
int_count=INTS_PER_SECOND;
setup_counters( RTCC_INTERNAL, RTCC_DIV_256);
setup_timer_0(RTCC_INTERNAL | RTCC_DIV_256 | RTCC_8_BIT);
enable_interrupts(INT_RTCC);
enable_interrupts(GLOBAL);
while(1)
{ }
}
thanks advance
by
jai