#include <stdio.h>
#include <stdlib.h>
#include <xc.h>
#include <pic.h>
#define _XTAL_FREQ 16000000
//#pragma config MCLRE = OFF, CP = OFF, WDTE = OFF, FORC = INTRC
// CONFIG
#pragma config FOSC = INTOSC // Oscillator Selection bits (INTOSC oscillator: CLKIN function disabled)
#pragma config BOREN = OFF // Brown-out Reset Enable (Brown-out Reset disabled)
#pragma config WDTE = OFF // Watchdog Timer Enable (WDT disabled)
#pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled)
#pragma config MCLRE = OFF // MCLR Pin Function Select bit (MCLR pin function is digital input, MCLR internally tied to VDD)
#pragma config CP = OFF // Code Protection bit (Program memory code protection is disabled)
#pragma config LVP = ON // Low-Voltage Programming Enable (Low-voltage programming enabled)
#pragma config LPBOR = OFF // Brown-out Reset Selection bits (BOR disabled)
#pragma config BORV = LO // Brown-out Reset Voltage Selection (Brown-out Reset Voltage (Vbor), low trip point selected.)
#pragma config WRT = OFF // Flash Memory Self-Write Protection (Write protection off)
/* Pic10F322
* _______
* nothing | | RA 3
* 2 - 5.5V | | ground
* RA 2 | | nothing
* RA 1 |_______| RA 0
*/
int main(int argc, char** argv)
{
TRISA = 0b1000;
PORTA = 0b0000;
PORTA = 0b0000;// Blink 3 Times so you know its working
__delay_ms(500);
PORTA = 0b1111;
__delay_ms(500);
PORTA = 0b0000;
__delay_ms(500);
PORTA = 0b1111;
__delay_ms(500);
PORTA = 0b0000;
__delay_ms(500);
PORTA = 0b1111;
__delay_ms(500);
while ( 1)
{
// When RA3 gets high, the light will turn off or on
// Although it says that there are errors, it will work fine
// That is a bug in mplab X
while(!PORTAbits.RA3)
{
;
}
PORTA = 0b0111;
__delay_ms(500);
while(!PORTAbits.RA3)
{
;
}
PORTA = 0b0000;
__delay_ms(500);
}
}