Part 2: Going to Sleep(); An Interrupt Using an Input Pin on a PIC16F690 CCS C

This is part two of the POV design. I added a sleep function to this program. It counts up to 14. Once it hits 15 it goes to sleep, only to be awakened by MCLR and starting from the beginning of the program. Please enjoy.

#include <16f690.h>
#fuses intrc_io,mclr,put,nobrownout,nowdt
#use delay(clock=31000) //clock set to oscillator frequency
int count=0;

#INT_RB //this is the interrupt
void interruptMe(void) { count++; delay_ms(250); }

void main(void)
setup_oscillator(osc_31khz); //This uses less current than 4MHz
enable_interrupts(INT_RB7); //a change on RB7 triggers interrupt

while (1)   {  output_c(count);
if (count==0x0f)
output_a(0×00); output_b(0×00); output_c(0×00); //set all outputs to ground
sleep(); //should only wake up after MCLR
}  }  }

Comments are closed.