fork download
  1. // File: main.c
  2. #include <xc.h>
  3.  
  4. // CONFIG
  5. #pragma config FOSC = HS // Oscillator Selection bits
  6. #pragma config WDTE = OFF // Watchdog Timer Enable bit
  7. #pragma config PWRTE = OFF // Power-up Timer Enable bit
  8. #pragma config BOREN = OFF // Brown-out Reset Enable bit
  9. #pragma config LVP = OFF // Low-Voltage (Single-Supply) In-Circuit Serial Programming Enable bit
  10. #pragma config CPD = OFF // Data EEPROM Memory Code Protection bit
  11. #pragma config WRT = OFF // Flash Program Memory Write Enable bits
  12. #pragma config CP = OFF // Flash Program Memory Code Protection bit
  13.  
  14. #define _XTAL_FREQ 20000000 // 20 MHz crystal
  15.  
  16. void main(void) {
  17. TRISB = 0x00; // Set PORTB as output
  18. PORTB = 0x00; // Start with all pins low
  19.  
  20. while(1) {
  21. PORTBbits.RB0 = 1; // Turn on LED connected to RB0
  22. __delay_ms(500); // Wait 500 ms
  23. PORTBbits.RB0 = 0; // Turn off LED
  24. __delay_ms(500); // Wait again
  25. }
  26. }
  27.  
Success #stdin #stdout 0.03s 25976KB
stdin
1
2
10
42
11
stdout
// File: main.c
#include <xc.h>

// CONFIG
#pragma config FOSC = HS        // Oscillator Selection bits
#pragma config WDTE = OFF       // Watchdog Timer Enable bit
#pragma config PWRTE = OFF      // Power-up Timer Enable bit
#pragma config BOREN = OFF      // Brown-out Reset Enable bit
#pragma config LVP = OFF        // Low-Voltage (Single-Supply) In-Circuit Serial Programming Enable bit
#pragma config CPD = OFF        // Data EEPROM Memory Code Protection bit
#pragma config WRT = OFF        // Flash Program Memory Write Enable bits
#pragma config CP = OFF         // Flash Program Memory Code Protection bit

#define _XTAL_FREQ 20000000     // 20 MHz crystal

void main(void) {
    TRISB = 0x00;   // Set PORTB as output
    PORTB = 0x00;   // Start with all pins low

    while(1) {
        PORTBbits.RB0 = 1;  // Turn on LED connected to RB0
        __delay_ms(500);    // Wait 500 ms
        PORTBbits.RB0 = 0;  // Turn off LED
        __delay_ms(500);    // Wait again
    }
}