Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Thanks BigDogGuru for your help...
Whatsoever you told me i had implemented that before, but my result are not at all satisfactory,
Here is the Snapshot of What i Got
View attachment 66909
/******************************************************************************/
/* BLINKY.C: LED Flasher */
/******************************************************************************/
/* This file is part of the uVision/ARM development tools. */
/* Copyright (c) 2005-2006 Keil Software. All rights reserved. */
/* This software may only be used under the terms of a valid, current, */
/* end user licence from KEIL for a compatible version of KEIL software */
/* development tools. Nothing else gives you the right to use this software. */
/******************************************************************************/
#include <stdio.h> /* standard I/O .h-file */
#include <LPC213x.H> /* LPC213x definitions */
#include <math.h>
extern void init_serial (void); /* Initialize Serial Interface */
int volatile timeval;
/*
* ----- Parameters and Variables for Sine Wave Generator -----
*/
unsigned long OutFreq = 480l; /* Output Frequency (Range 1Hz - 4000Hz) */
#define OutAmpl 600 /* Output Amplitute (Range 0 - 0.99) */
#define PI 3.1415926
#define T0_RlFreq 8000 /* Timer 0 Reload Frequency */
struct tone { /* struct for Sine Wave Generator Signal */
int cos; /* cosine factor */
long y1; /* y[-1] value */
int y2; /* y[-2] value */
};
int NewFreq; /* New Frequency Setup indication */
short tval;
signed char cval;
struct tone Tone;
/*
* Generate Sine Wave Tone
*/
static void Generate_Sine (struct tone *t) {
int y;
y = (t->cos * (t->y1 >> 14)) - t->y2;
t->y2 = t->y1;
t->y1 = y;
tval = t->y1 >> 16;
cval = tval;
}
/*
* Initialize the Sine Wave Tone Generator
*/
__inline void Init_Sine (int OutFreq) {
Tone.cos = (cos (2*PI*((float)OutFreq/T0_RlFreq))) * 32768;
Tone.y1 = 0;
Tone.y2 = (sin (2*PI*((float)OutFreq/T0_RlFreq)) * OutAmpl) * 32768;
}
/* Timer Counter 0 Interrupt executes each 10ms @ 60 MHz CPU Clock */
__irq void tc0 (void) {
++timeval;
if (NewFreq) { /* The frequency changes when a new ADC value is measured */
Init_Sine (NewFreq);
NewFreq = 0;
}
Generate_Sine (&Tone);
DACR = ((Tone.y1 >> 10) & 0xFFC0) + 0x8000;
T0IR = 1; /* Clear interrupt flag */
VICVectAddr = 0; /* Acknowledge Interrupt */
}
/* Setup the Timer Counter 0 Interrupt */
void init_timer (void) {
T0MR0 = 1874; /* 0.125uSec = 1875-1 counts */
T0MCR = 3; /* Interrupt and Reset on MR0 */
T0TCR = 1; /* Timer0 Enable */
VICVectAddr0 = (unsigned long)tc0; /* set interrupt vector in 0 */
VICVectCntl0 = 0x20 | 4; /* use it for Timer0 Interrupt */
VICIntEnable = 0x00000010; /* Enable Timer0 Interrupt */
}
void delay (void) { /* Delay function */
unsigned int cnt;
unsigned int val;
static unsigned int oldval;
int diff;
AD0CR |= 0x01200000; /* Start A/D Conversion */
do {
val = AD0DR; /* Read A/D Data Register */
} while ((val & 0x80000000) == 0); /* Wait for end of A/D Conversion */
AD0CR &= ~0x01000000; /* Stop A/D Conversion */
val = (val >> 6) & 0x03FF; /* Extract AIN0 Value */
diff = val - oldval;
if (diff > 10 || diff < -10) {
oldval = val;
NewFreq = 1200 - val;
}
printf ("\nAIN1 Result = 0x%03X", val); /* Output A/D Conversion Result */
val = (val >> 2) << 12; /* Adjust Delay Value */
for (cnt = 0; cnt < val; cnt++); /* Delay */
}
int main (void) {
unsigned int n;
IODIR1 = 0x00FF0000; /* P1.16..23 defined as Outputs */
AD0CR = 0x00200402; /* Setup A/D: 10-bit AIN0 @ 3MHz */
PINSEL1 = 0x01080000; /* enable DAC */
init_serial(); /* Initialize Serial Interface */
init_timer ();
while (1) { /* Loop forever */
for (n = 0x00010000; n <= 0x00800000; n <<= 1) {
/* Blink LED 0, 1, 2, 3, 4, 5, 6, 7 */
IOSET1 = n; /* Turn on LED */
delay(); /* Delay */
IOCLR1 = 0x00FF0000; /* Turn off LEDs */
}
}
}
/***This is With Interrupt***/
#include<htc.h>
#include<string.h>
#include<stdio.h>
#define _XTAL_FREQ 20000000
void T1_ISR(void); //ISR
void interrupt Check_Interrupt(void)
{
if(PIR1bits.TMR1IF == 1)
T1_ISR(); //Timer-1 Interrupt Occurs
}
const unsigned char wave[181] = {128,132,137,141,146,150,155,159,163,168,172,176,180,184,188,192,196,200,203,207,210,214,217,220,223,226,229,232,234,237,239,241,243,245,247,248,250,251,252,253,254,254,255,255,255,255,255,255,255,255,254,253,252,251,250,248,247,245,243,241,239,237,234,232,229,226,223,220,217,214,210,207,203,200,196,192,188,184,180,176,172,168,163,159,155,150,146,141,137,132,128,124,119,115,110,106,101,97,93,88,84,80,76,72,68,64,60,56,53,49,46,42,39,36,33,30,27,24,22,19,17,15,13,11,9,8,6,5,4,3,2,1,1,0,0,0,0,0,1,1,2,3,4,5,6,8,9,11,13,15,17,19,22,24,27,30,33,36,39,42,46,49,53,56,60,64,68,72,76,80,84,88,93,97,101,106,110,115,119,124,128};
/*FDD5*/
unsigned int i=0;
void main()
{
TRISD = 0x00;
T1CON = 0x01;
TMR1H = 0xFE; //To Generate 111usec Pulse
TMR1L = 0x50;
//Enable all Interrupts
INTCONbits.TMR0IE = 1;
PIE1bits.TMR1IE = 1;
INTCONbits.PEIE = 1;
INTCONbits.GIE = 1;
while(1)
{
if(i == 181)
{ i=0;
}
}
}
void T1_ISR(void)
{
PORTD = wave[i];
i++;
TMR1H = 0xFE;
TMR1L = 0x50;
PIR1bits.TMR1IF = 0; //Clear the Timer-1 Flag Bit
}
Now pls tell me how can i adjust the values of delay i.e TMR1H and TMR1L Register to get a Variable sine Wave...
I am not fully professional with the use of ADC.. but i can use PIC16F877A adc...
But what are the parameters by which i can control the TMR1L and TMR1H values..
Suppose i using ADC with Vref of 5V which means that 1024 steps do i require such large step size..
can you pls provide me some more details
As generation of the sine wave is much more important then the ADC Conversion thats why
I want to place my T1_ISR in high Priority Interrupt
But ADC_Conversion Routine Must be in Low_Priority Interrupt
/***This is With Interrupt***/
#include<htc.h>
#include<string.h>
#include<stdio.h>
#define _XTAL_FREQ 20000000
void T1_ISR(void); //ISR for Generating Delay
void AD_ISR(void); //ISR for A/D Conversion
void interrupt Check_Interrupt(void)
{
if(PIR1bits.TMR1IF == 1)
T1_ISR(); //Timer-1 Interrupt Occurs
if(PIR1bits.ADIF == 1) //A/D Interrupt Occurs
AD_ISR();
}
const unsigned char wave[181] = {128,132,137,141,146,150,155,159,163,168,172,176,180,184,188,192,196,200,203,207,210,214,217,220,223,226,229,232,234,237,239,241,243,245,247,248,250,251,252,253,254,254,255,255,255,255,255,255,255,255,254,253,252,251,250,248,247,245,243,241,239,237,234,232,229,226,223,220,217,214,210,207,203,200,196,192,188,184,180,176,172,168,163,159,155,150,146,141,137,132,128,124,119,115,110,106,101,97,93,88,84,80,76,72,68,64,60,56,53,49,46,42,39,36,33,30,27,24,22,19,17,15,13,11,9,8,6,5,4,3,2,1,1,0,0,0,0,0,1,1,2,3,4,5,6,8,9,11,13,15,17,19,22,24,27,30,33,36,39,42,46,49,53,56,60,64,68,72,76,80,84,88,93,97,101,106,110,115,119,124,128};
unsigned int i=0;
unsigned char adc_data_l,adc_data_h;
void main()
{
TRISAbits.TRISA0 = 1; //Channel A0 as Input Port
TRISD = 0x00;
//Running ADC For the First Time Before Starting the Interrupt
//So That we Can Acquire the Delay Value
ADCON0 = 0x81;
//Fosc/64 is Selected
//Channel-0 is Selected
//Analog-to-Digital Converter Module is Powered Up
ADCON1 = 0xCE;
//A/D Result Format Select Bit Right Justified
//and AN0 Channel as Analog Channel
__delay_ms(100);
ADCON0bits.GO = 1; //Start Conversion
while(ADCON0bits.GO == 1); //Wait Here Until Conversion Gets Over
adc_data_l = ADRESL;
adc_data_h = ADRESH;
T1CON = 0x01;
TMR1H = adc_data_h;
TMR1L = adc_data_l;
//Enable all Interrupts
PIE1bits.TMR1IE = 1;
PIR1bits.ADIF = 0; //Clear A/D Flag Bit
PIE1bits.ADIE = 1; //Enable A/D Interrupt Bit
INTCONbits.PEIE = 1;
INTCONbits;GIE = 1;
while(1)
{
if(i == 181)
{ i=0;
}
}
}
void T1_ISR(void)
{
PORTD = wave[i];
i++;
TMR1H = adc_data_h;
TMR1L = adc_data_l;
PIR1bits.TMR1IF = 0; //Clear the Timer-1 Flag Bit
}
//This is Interrupt Service Routine for ADC
void AD_ISR(void)
{
adc_data_l = ADRESL;
adc_data_h = ADRESH;
//adc_data = adc_data | ADRESL;
PIR1bits.ADIF = 0; //Clears the Interrupt
}
Please enclose your posted code in code tags CODE /CODE either manually or use the # button under "Advanced"
void main()
{
TRISAbits.TRISA0 = 1; //Channel A0 as Input Port
TRISD = 0x00;
//Running ADC For the First Time Before Starting the Interrupt
//So That we Can Acquire the Delay Value
ADCON0 = 0x81;
//Fosc/64 is Selected
//Channel-0 is Selected
//Analog-to-Digital Converter Module is Powered Up
ADCON1 = 0xCE;
//A/D Result Format Select Bit Right Justified
//and AN0 Channel as Analog Channel
__delay_ms(100);
[COLOR="#FF0000"] ADCON0bits.GO = 1; //Start Conversion
while(ADCON0bits.GO == 1); //Wait Here Until Conversion Gets Over[/COLOR]
adc_data_l = ADRESL;
adc_data_h = ADRESH;
T1CON = 0x01;
TMR1H = adc_data_h;
TMR1L = adc_data_l;
//Enable all Interrupts
PIE1bits.TMR1IE = 1;
PIR1bits.ADIF = 0; //Clear A/D Flag Bit
PIE1bits.ADIE = 1; //Enable A/D Interrupt Bit
INTCONbits.PEIE = 1;
INTCONbits;GIE = 1;
while(1)
{
if(i == 181)
{ i=0;
}
}
}
//This is Interrupt Service Routine for ADC
void AD_ISR(void)
{
adc_data_l = ADRESL;
adc_data_h = ADRESH;
//adc_data = adc_data | ADRESL;
PIR1bits.ADIF = 0; //Clears the Interrupt
}
#include<htc.h>
#define _XTAL_FREQ 20000000
void T1_ISR(void); //ISR for Generating Delay
void interrupt Check_Interrupt(void)
{
if(PIR1bits.TMR1IF == 1)
T1_ISR(); //Timer-1 Interrupt Occurs
}
const unsigned char wave[181] =
{128,132,137,141,146,150,155,159,163,168,172,176,180,184,188,192,196,200,203,207,210,214,217,220,
223,226,229,232,234,237,239,241,243,245,247,248,250,251,252,253,254,254,255,255,255,255,255,255,2
55,255,254,253,252,251,250,248,247,245,243,241,239,237,234,232,229,226,223,220,217,214,210,207,20
3,200,196,192,188,184,180,176,172,168,163,159,155,150,146,141,137,132,128,124,119,115,110,106,101
,97,93,88,84,80,76,72,68,64,60,56,53,49,46,42,39,36,33,30,27,24,22,19,17,15,13,11,9,8,6,5,4,3,2,1
,1,0,0,0,0,0,1,1,2,3,4,5,6,8,9,11,13,15,17,19,22,24,27,30,33,36,39,42,46,49,53,56,60,64,68,72,76,
80,84,88,93,97,101,106,110,115,119,124,128};
unsigned int i=0;
unsigned char adc_data;
void main()
{
TRISAbits.TRISA0 = 1; //Channel A0 as Input Port
TRISB = 0x00;
TRISC = 0x00;
TRISD = 0x00;
//Running ADC For the First Time Before Starting the Interrupt
//So That we Can Acquire the Delay Value
ADCON0 = 0x81;
//Fosc/64 is Selected
//Channel-0 is Selected
//Analog-to-Digital Converter Module is Powered Up
ADCON1 = 0xCE;
//A/D Result Format Select Bit Right Justified
//and AN0 Channel as Analog Channel
adc_data = 0x00;
T1CON = 0x01;
TMR1H = 0xFD; //To Generate 111usec Pulse
TMR1L = 0xCE; //These Values are Random
//Enable all Interrupts
PIE1bits.TMR1IE = 1;
//PIR1bits.ADIF = 0; //Clear A/D Flag Bit
//PIE1bits.ADIE = 1; //Enable A/D Interrupt Bit
INTCONbits.PEIE = 1;
INTCONbits;GIE = 1;
while(1)
{
__delay_us(100);
ADCON0bits.GO = 1; //Start Conversion
while(ADCON0bits.GO == 1); //Wait Here Until Conversion Gets Over
adc_data = ADRESL;
}
}
void T1_ISR(void)
{
PORTD = wave[i];
i++;
switch(adc_data)
{
case 0x00:
TMR1H = 0xFD; //40Hz Frequency
TMR1L = 0x00;
break;
case 0x01:
TMR1H = 0xFD; //42Hz Frequency
TMR1L = 0xA0;
break;
case 0x02:
TMR1H = 0xFD; //46Hz Frequency
TMR1L = 0xFC;
break;
}
if(i == 181)
i=0;
PIR1bits.TMR1IF = 0; //Clear the Timer-1 Flag Bit
}
Its very difficult to measure the frequency of the sine wave on the proteus oscilloscope for every value i loaded in the timer register..
can you tell me how to measure the frequency of the sine wave exactly in proteus by any other means...
or some particular format to generate accurate timer delays..
/***This is With Interrupt***/
#include<htc.h>
#include<string.h>
#include<stdio.h>
#define _XTAL_FREQ 20000000
#define LCD_DATA PORTB
#define RS PORTCbits.RC0
#define RW PORTCbits.RC1
#define EN PORTCbits.RC2
#define Second_Bit PORTCbits.RC4
void lcdcmd(unsigned char value);
void lcddata(unsigned char value);
void lcdstr(unsigned char msg[]);
void T1_ISR(void); //ISR for Generating Delay
void interrupt Check_Interrupt(void)
{
if(PIR1bits.TMR1IF == 1)
T1_ISR(); //Timer-1 Interrupt Occurs
/*if(PIR1bits.ADIF == 1) //A/D Interrupt Occurs
AD_ISR();*/
}
const unsigned char msg1[] = "PIC16F877A";
const unsigned char msg2[] = "MATLAB ACADEMY";
const unsigned char wave[180] = {128,132,137,141,146,150,155,159,163,168,172,176,180,184,188,192,196,200,203,207,210,214,217,220,223,226,229,232,234,237,239,241,243,245,247,248,250,251,252,253,254,254,255,255,255,255,255,255,255,255,254,253,252,251,250,248,247,245,243,241,239,237,234,232,229,226,223,220,217,214,210,207,203,200,196,192,188,184,180,176,172,168,163,159,155,150,146,141,137,132,128,124,119,115,110,106,101,97,93,88,84,80,76,72,68,64,60,56,53,49,46,42,39,36,33,30,27,24,22,19,17,15,13,11,9,8,6,5,4,3,2,1,1,0,0,0,0,0,1,1,2,3,4,5,6,8,9,11,13,15,17,19,22,24,27,30,33,36,39,42,46,49,53,56,60,64,68,72,76,80,84,88,93,97,101,106,110,115,119,124};
/*FDD5*/
unsigned int i=0;
unsigned char adc_data;
void main()
{
TRISAbits.TRISA0 = 1; //Channel A0 as Input Port
TRISB = 0x00;
TRISC = 0x00;
TRISD = 0x00;
EN = 0;
lcdcmd(0x38);
lcdcmd(0x0E);
lcdcmd(0x01);
lcdcmd(0x06);
lcdcmd(0x83);
lcdstr(msg1);
lcdcmd(0xC1);
lcdstr(msg2);
lcdcmd(0x01);
// __delay_ms(500);
lcdcmd(0x80);
lcdstr("Initializing....");
lcdcmd(0xC6);
lcdstr("DAC.......");
lcdcmd(0x01);
lcdcmd(0x80);
lcdstr("See Oscilloscope");
//Running ADC For the First Time Before Starting the Interrupt
//So That we Can Acquire the Delay Value
ADCON0 = 0x81;
//Fosc/64 is Selected
//Channel-0 is Selected
//Analog-to-Digital Converter Module is Powered Up
ADCON1 = 0xCE;
//A/D Result Format Select Bit Right Justified
//and AN0 Channel as Analog Channel
/* __delay_ms(100);
ADCON0bits.GO = 1; //Start Conversion
while(ADCON0bits.GO == 1); //Wait Here Until Conversion Gets Over
adc_data = ADRESL; // & 0x00FF;
//adc_data_h = ADRESH; //& 0x00FF;
/*adc_data = adc_data<<8;
adc_data = adc_data | ADRESL;*/
adc_data = 0x00;
T1CON = 0x01;
TMR1H = 0xFD;
TMR1L = 0x9C;
//Enable all Interrupts
//INTCONbits.TMR0IE = 1;
PIE1bits.TMR1IE = 1;
//PIR1bits.ADIF = 0; //Clear A/D Flag Bit
//PIE1bits.ADIE = 1; //Enable A/D Interrupt Bit
INTCONbits.PEIE = 1;
INTCONbits;GIE = 1;
while(1)
{
__delay_us(100);
ADCON0bits.GO = 1; //Start Conversion
while(ADCON0bits.GO == 1); //Wait Here Until Conversion Gets Over
adc_data = ADRESL;
}
}
void lcdcmd(unsigned char value)
{
LCD_DATA = value;
RS = 0;
RW = 0;
EN = 1;
__delay_ms(1);
EN = 0;
}
void lcddata(unsigned char value)
{
LCD_DATA = value;
RS = 1;
RW = 0;
EN = 1;
__delay_ms(1);
EN = 0;
}
void lcdstr(unsigned char msg[])
{
unsigned int i,len;
len = strlen(msg);
for(i=0;i<len;i++)
{
lcddata(msg[i]);
}
}
void T1_ISR(void)
{
PORTD = wave[i];
i++;
switch(adc_data)
{
[I]case 0:
TMR1H = 0xFD; //40Hz Frequency
TMR1L = 0x9C;
break; [/I]
case 1:
TMR1H = 0xFD; //42Hz Frequency
TMR1L = 0x9F;
break;
case 2:
TMR1H = 0xFD; //46Hz Frequency
TMR1L = 0xA3;
break;
case 3:
TMR1H = 0xFD;
TMR1L = 0xA5;
break;
case 4:
TMR1H = 0xFD;
TMR1L = 0xA7;
break;
case 5:
TMR1H = 0xFD;
TMR1L = 0xA9;
break;
case 6:
TMR1H = 0xFD;
TMR1L = 0xAB;
break;
case 7:
TMR1H = 0xFD;
TMR1L = 0xAE;
break;
case 8:
TMR1H = 0xFD; //42Hz Frequency
TMR1L = 0xB0;
break;
case 9:
TMR1H = 0xFD; //46Hz Frequency
TMR1L = 0xFC;
break;
case 10:
TMR1H = 0xFE;
TMR1L = 0xFC;
break;
case 11:
TMR1H = 0xFE;
TMR1L = 0xFC;
break;
case 12:
TMR1H = 0xFE;
TMR1L = 0xFC;
break;
case 13:
TMR1H = 0xFF; //40Hz Frequency
TMR1L = 0xFC;
break;
case 14:
TMR1H = 0xFD; //42Hz Frequency
TMR1L = 0x9C;
break;
case 15:
TMR1H = 0xFD; //46Hz Frequency
TMR1L = 0xFC;
break;
case 16:
TMR1H = 0xFE;
TMR1L = 0xFC;
break;
case 17:
TMR1H = 0xFE;
TMR1L = 0xFC;
break;
case 18:
TMR1H = 0xFE;
TMR1L = 0xFC;
break;
case 19:
TMR1H = 0xFF; //40Hz Frequency
TMR1L = 0xFC;
break;
case 20:
TMR1H = 0xFD; //42Hz Frequency
TMR1L = 0x9C;
break;
case 21:
TMR1H = 0xFD; //46Hz Frequency
TMR1L = 0xFC;
break;
case 22:
TMR1H = 0xFE;
TMR1L = 0xFC;
break;
case 23:
TMR1H = 0xFE;
TMR1L = 0xFC;
break;
case 24:
TMR1H = 0xFE;
TMR1L = 0xFC;
break;
case 25:
TMR1H = 0xFF; //40Hz Frequency
TMR1L = 0xFC;
break;
case 26:
TMR1H = 0xFD; //42Hz Frequency
TMR1L = 0x9C;
break;
case 27:
TMR1H = 0xFD; //46Hz Frequency
TMR1L = 0xFC;
break;
case 28:
TMR1H = 0xFE;
TMR1L = 0xFC;
break;
case 29:
TMR1H = 0xFE;
TMR1L = 0xFC;
break;
case 30:
TMR1H = 0xFE;
TMR1L = 0xFC;
break;
case 31:
TMR1H = 0xFD; //42Hz Frequency
TMR1L = 0x9C;
break;
case 32:
TMR1H = 0xFD; //46Hz Frequency
TMR1L = 0xFC;
break;
case 33:
TMR1H = 0xFE;
TMR1L = 0xFC;
break;
case 34:
TMR1H = 0xFE;
TMR1L = 0xFC;
break;
case 29:
TMR1H = 0xFE;
TMR1L = 0xFC;
break;
case 30:
TMR1H = 0xFE;
TMR1L = 0xFC;
break;
case 31:
TMR1H = 0xFD; //42Hz Frequency
TMR1L = 0x9C;
break;
case 32:
TMR1H = 0xFD; //46Hz Frequency
TMR1L = 0xFC;
break;
case 33:
TMR1H = 0xFE;
TMR1L = 0xFC;
break;
case 34:
TMR1H = 0xFE;
TMR1L = 0xFC;
break;
case 29:
TMR1H = 0xFE;
TMR1L = 0xFC;
break;
case 30:
TMR1H = 0xFE;
TMR1L = 0xFC;
break;
case 31:
TMR1H = 0xFD; //42Hz Frequency
TMR1L = 0x9C;
break;
case 32:
TMR1H = 0xFD; //46Hz Frequency
TMR1L = 0xFC;
break;
case 33:
TMR1H = 0xFE;
TMR1L = 0xFC;
break;
case 34:
TMR1H = 0xFE;
TMR1L = 0xFC;
break;
case 35:
TMR1H = 0xFE;
TMR1L = 0xFC;
break;
case 36:
TMR1H = 0xFE;
TMR1L = 0xFC;
break;
case 37:
TMR1H = 0xFD; //42Hz Frequency
TMR1L = 0x9C;
break;
case 38:
TMR1H = 0xFD; //46Hz Frequency
TMR1L = 0xFC;
break;
case 39:
TMR1H = 0xFE;
TMR1L = 0xFC;
break;
case 40:
TMR1H = 0xFE;
TMR1L = 0xFC;
break;
case 41:
TMR1H = 0xFE;
TMR1L = 0xFC;
break;
case 42:
TMR1H = 0xFE;
TMR1L = 0xFC;
break;
case 43:
TMR1H = 0xFD; //42Hz Frequency
TMR1L = 0x9C;
break;
case 44:
TMR1H = 0xFD; //46Hz Frequency
TMR1L = 0xFC;
break;
case 45:
TMR1H = 0xFE;
TMR1L = 0xFC;
break;
case 46:
TMR1H = 0xFE;
TMR1L = 0x16;
break;
case 47:
TMR1H = 0xFE;
TMR1L = 0xFC;
break;
case 48:
TMR1H = 0xFE;
TMR1L = 0xFC;
break;
case 49:
TMR1H = 0xFD; //42Hz Frequency
TMR1L = 0x9C;
break;
case 50:
TMR1H = 0xFD; //46Hz Frequency
TMR1L = 0xFC;
break;
case 51:
TMR1H = 0xFE;
TMR1L = 0xFC;
break;
case 52:
TMR1H = 0xFE;
TMR1L = 0xFC;
break;
case 53:
TMR1H = 0xFE;
TMR1L = 0xFC;
break;
case 54:
TMR1H = 0xFE;
TMR1L = 0xFC;
break;
case 55:
TMR1H = 0xFD; //42Hz Frequency
TMR1L = 0x9C;
break;
[I]case 56:
TMR1H = 0xFE;
TMR1L = 0x60;
break;[/I]
case 57:
TMR1H = 0xFE;
TMR1L = 0x61;
break;
case 58:
TMR1H = 0xFE;
TMR1L = 0x62;
break;
case 59:
TMR1H = 0xFE;
TMR1L = 0x63;
break;
case 60:
TMR1H = 0xFE;
TMR1L = 0x64;
break;
case 61:
TMR1H = 0xFE;
TMR1L = 0x65;
break;
case 62:
TMR1H = 0xFE;
TMR1L = 0x66;
break;
case 63:
TMR1H = 0xFE;
TMR1L = 0x67;
break;
case 64:
TMR1H = 0xFE;
TMR1L = 0x68;
break;
case 65:
TMR1H = 0xFE;
TMR1L = 0x69;
break;
case 66:
TMR1H = 0xFE;
TMR1L = 0x6A;
break;
case 67:
TMR1H = 0xFE;
TMR1L = 0x6B;
break;
case 68:
TMR1H = 0xFE;
TMR1L = 0x6C;
break;
case 69:
TMR1H = 0xFE;
TMR1L = 0x6D;
break;
case 70:
TMR1H = 0xFE;
TMR1L = 0x6F;
break;
case 71:
TMR1H = 0xFE;
TMR1L = 0x70;
break;
case 72:
TMR1H = 0xFE;
TMR1L = 0x71;
break;
case 73:
TMR1H = 0xFE;
TMR1L = 0x72;
break;
case 74:
TMR1H = 0xFE;
TMR1L = 0x73;
break;
case 75:
TMR1H = 0xFE;
TMR1L = 0x74;
break;
case 76:
TMR1H = 0xFE;
TMR1L = 0x75;
break;
case 77:
TMR1H = 0xFE;
TMR1L = 0x77;
break;
case 78:
TMR1H = 0xFE;
TMR1L = 0x78;
break;
case 79:
TMR1H = 0xFE;
TMR1L = 0x79;
break;
case 80:
TMR1H = 0xFE;
TMR1L = 0x7A;
break;
case 81:
TMR1H = 0xFE;
TMR1L = 0x7B;
break;
case 82:
TMR1H = 0xFE;
TMR1L = 0x7C;
break;
case 83:
TMR1H = 0xFE;
TMR1L = 0x7D;
break;
case 84:
TMR1H = 0xFE;
TMR1L = 0x80;
break;
case 85:
TMR1H = 0xFE;
TMR1L = 0x81;
break;
case 86:
TMR1H = 0xFE;
TMR1L = 0x82;
break;
case 87:
TMR1H = 0xFE;
TMR1L = 0x83;
break;
case 88:
TMR1H = 0xFD; //42Hz Frequency
TMR1L = 0x84;
break;
case 89:
TMR1H = 0xFD; //46Hz Frequency
TMR1L = 0x85;
break;
case 90:
TMR1H = 0xFE;
TMR1L = 0x86;
break;
case 91:
TMR1H = 0xFE;
TMR1L = 0x87;
break;
case 92:
TMR1H = 0xFE;
TMR1L = 0x89;
break;
[I]case 93:
TMR1H = 0xFE;
TMR1L = 0x90; //90.06Hz Frequency
break;[/I]
}
/*TMR1H = 0xFD; //To Generate 111usec Pulse
TMR1L = 0xCE;*/
if(i == 180)
i=0;
PIR1bits.TMR1IF = 0; //Clear the Timer-1 Flag Bit
}
//This is Interrupt Service Routine for ADC
/*void AD_ISR(void)
{
adc_data_l = ADRESL;
adc_data_h = ADRESH;
//adc_data = adc_data | ADRESL;
PIR1bits.ADIF = 0; //Clears the Interrupt
}*/