#include <18f4550.h>
#fuses hspll,mclr,nowdt,noprotect,nolvp,nodebug,usbdiv,pll3,cpudiv1,novregen,nopbaden
#use delay (clock=48000000)
#use standard_io(B)
#use standard_io(C)
#use standard_io(D)
int16 frecuencia=0;
int8 desbordes=0;
int seno[100]={77,82,86,91,96,101,105,109,114,118,122,126,129,133,136,
139,142,144,146,148,150,151,152,153,153,154,153,153,152,151,150,148,146,144,142,
139,136,133,129,126,122,118,114,109,105,101,96,91,86,82,77,72,67,62,58,53,49,44,
40,36,32,28,24,21,18,15,12,9,7,5,4,2,1,1,0,0,1,1,2,4,5,7,9,12,15,18,21,24,28,32,36,
40,44,49,53,58,62,67,72,77};
#int_rtcc
void rtcc_isr(){
frecuencia=read_adc();
output_B(seno[desbordes]);
output_d(seno[desbordes]);
set_rtcc(frecuencia);
desbordes++;
if(desbordes>=100)
{
desbordes = 0;
}
}
void main()
{
setup_adc_ports(all_analog);
setup_adc(adc_clock_internal);
set_adc_channel(0);
set_tris_b(0x00);
set_tris_d(0x00);
setup_counters(rtcc_internal, rtcc_div_4 | rtcc_8_bit);
enable_interrupts(int_rtcc);
enable_interrupts(global);
set_rtcc(231);
desbordes = 0;
while(true)
{
}
}