fork download
  1. /* Main.c file generated by New Project wizard
  2.  *
  3.  * Created: ×ò Êâ³ 24 2025
  4.  * Processor: PIC16F876A
  5.  * Compiler: MPLAB XC8
  6.  */
  7.  
  8. #include <xc.h>
  9.  
  10. void interrupt ADC ()
  11. {
  12. L=ADRESL;
  13. H=ADRESH;
  14. PORTN=L;
  15. PORTC=H;
  16. ADIF=0;
  17. }
  18.  
  19. void main(void)
  20. {
  21. TRISA=0b11111111;
  22. TRISB=0b00000000;
  23. TRISC=0b00000000;
  24. PORTB=0b00000000;
  25. PORTC=0b00000000;
  26.  
  27. ADCON1bits.PCFG=0b0000;
  28. ADCON0bits.CHS=0b000;
  29. ADCON0bits.ADCS=0b01;
  30. ADFM=1;
  31. ADON=1;
  32. GO=0;
  33. ADIF=0;
  34. ADIE=1;
  35. PEIE=1;
  36. GIE=1;
  37.  
  38.  
  39. while (1)
  40. __delay_us(30);
  41. GO=1;
  42. while (ADIF==0)
  43. { }
  44. __delay_us(30);
  45.  
  46.  
  47.  
  48. }
Success #stdin #stdout 0.03s 25896KB
stdin
Standard input is empty
stdout
/* Main.c file generated by New Project wizard
 *
 * Created:   ×ò Êâ³ 24 2025
 * Processor: PIC16F876A
 * Compiler:  MPLAB XC8
 */

#include <xc.h>

void interrupt ADC ()
{
     L=ADRESL;
     H=ADRESH;
     PORTN=L;
     PORTC=H;
     ADIF=0;
}

void main(void)
 {
      TRISA=0b11111111;
      TRISB=0b00000000; 
      TRISC=0b00000000; 
      PORTB=0b00000000; 
      PORTC=0b00000000; 
    
      ADCON1bits.PCFG=0b0000; 
      ADCON0bits.CHS=0b000; 
      ADCON0bits.ADCS=0b01; 
      ADFM=1; 
      ADON=1; 
      GO=0; 
      ADIF=0; 
      ADIE=1; 
      PEIE=1; 
      GIE=1; 
    
    
   while (1)
      __delay_us(30);
      GO=1; 
      while (ADIF==0) 
      { } 
      __delay_us(30); 
   
   
   
 }