Samples of AC sinewave PIC16F877a

Thread Starter

@m@

Joined Mar 9, 2009
15
Hi...!
here is code of mine for reading channel 0 of adc works fine with dc but when I am applying AC sine wave I am not getting enough sample at terminal to correctly reconstruct it...
Please tell me why I am not getting enough sample of sinewave to reconstruct it correctly ..
Rich (BB code):
unsigned short temp_res;
char buf[6];
int i;
void main() {
  UART1_Init(9600);  // Initalize USART (9600 baud rate, 1 stop bit, ...
   ADCON0.ADCS0=0;   // 32TOSC  :::Using External Crystal Oscillator of 20MHz:::
   ADCON0.ADCS1=1;
   CMCON = 0x07;      // Comparator OFF
   TRISA  = 0xFF;     // PORTA is input
   TRISC  = 0;        // PORTC is output
   TRISB  = 0;        // PORTB is output
do 
    {

    // Read ADC results of channel number 0 and send the upper byte via USART
    temp_res = ADC_Read(0) >> 2;
    PORTB = temp_res;         // Send lower 8 bits to PORTB
    WordToStr(temp_res,buf);
    for(i = 0; i < 6; i++)
   {
   // Write channel 1
      UART1_Write(buf);
  }
   UART1_Write(13); // New line
     Delay_ms(1);
    }
      while (1);       // endless loop
}

Thank you.............!:confused:
 
Top