#include <16F628A.h>
#fuses INTRC_IO,NOPROTECT,NOBROWNOUT,NOMCLR,NOLVP,NOWDT,PUT // must include this line !!
#use fixed_io(A_OUTPUTS=40,41,42,43,44,46,47)
#use delay(clock=20000000)
#define D7 PIN_A3
#define D6 PIN_A2
#define D5 PIN_A1
#define D4 PIN_A0
#define RS PIN_A4
#define RW PIN_A6
#define E PIN_A7
#define INTS_PER_SECOND 76 // (20000000/(4*256*256))
#byte port_A=5
SET_TRIS_A( 0x20 );
BYTE sec; // A running seconds counter
BYTE min;
BYTE hour;
BYTE int_count; // Number of interrupts left before a second has elapsed
char x;
#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.
++sec;
if ( sec >= 60)
{
if(x == 0)
{
output_high(D4);
x = 1;
}
else
{
output_low(D4);
x = 0;
}
sec = 0;
min++;
if ( min >= 60)
{
min = 0;
hour++;
if ( hour >= 24)
{
hour = 0;
}
}
}
int_count=INTS_PER_SECOND;
}
}
main()
{
OUTPUT_A(0x00); //make sure all pins are at 0
x = 0;
int_count=INTS_PER_SECOND;
set_timer0(0);
setup_counters( RTCC_INTERNAL, RTCC_DIV_256 | RTCC_8_BIT);
enable_interrupts(INT_RTCC);
enable_interrupts(GLOBAL);
while(1)
{
clock_isr(); // i've added this in after it did not work without it.
//Of course it still does not work....
}
}