Skip to content

Instantly share code, notes, and snippets.

@chukitow
Created March 20, 2014 03:10
Show Gist options
  • Select an option

  • Save chukitow/9656446 to your computer and use it in GitHub Desktop.

Select an option

Save chukitow/9656446 to your computer and use it in GitHub Desktop.
#include <18f4520.h>
#fuses XT, NOWDT, PUT, NODEBUG, NOBROWNOUT, NOPROTECT, NOLVP, NOWRT
#use delay(clock=4000000)
boolean timerDetected = false;
int general = 0;
#INT_TIMER0
void timer()
{
timerDetected = true;
general++;
}
void main(void)
{
int i=1,j=1,k=1;
enable_interrupts(global);
enable_interrupts(INT_TIMER0);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_16);
set_timer0(12);
set_tris_b(0x00);
set_tris_c(0x00);
set_tris_d(0x00);
output_b(0);
output_c(0);
output_d(0);
while(true)
{
if(timerDetected)
{
if (general % 1 == 0)
{
if(i==256) i=0;
output_b(i++);
}
if (general % 2 == 0)
{
if(j==256) j=0;
output_c(j++);
}
if (general % 3 == 0)
{
if(k==256) k=0;
output_d(k++);
}
timerDetected = false;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment