#include <16F88.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP,PUT
#use delay(clock=10000000)
int timeCount; //int = int8
long TempA, TempB; //long = int16
int32 step, step2, position, position2;
CONST unsigned int SineTab[64] = {
7,8,8,9,10,10,11,11
12,12,13,13,13,14,14,14
14,14,14,14,13,13,13,12
12,11,11,10,10,9,8,8
7,6,6,5,4,4,3,3
2,2,1,1,1,0,0,0
0,0,0,0,1,1,1,2
2,3,3,4,4,5,6,6};
#INT_TIMER2
void interrupt(){
position+=step;
TempB=SineTab[(position>>16)&63];
output_b(TempB);
position2+=step2;
TempA=SineTab[(position2>>16)&63];
output_a(TempA);
}
void main(void) {
setup_comparator(NC_NC_NC_NC);
set_timer2(0);
setup_timer_2(T2_DIV_BY_4, 124, 1); // 200us = (1/10000000 * 4 * 4 * 124+1)
// N = F * 200*10-6*64*65536
// N = F * 838.86
// For 200Hz N = 167772
step = 167772; // changing frequency
// For 211.4 N = 177335
step2 = 177335; // base frequency
enable_interrupts(INT_TIMER2);
enable_interrupts(GLOBAL);
while(TRUE)
{
delay_us(1);
}
disable_interrupts(INT_TIMER2);
}