Part 1- Understanding I/O Ports and Pins – Blink A LED

In this Tutorial We will use the 10F322 to blink a LED every 1 second

You will learn the basics of:
-ANSELA (Analog Select Register)
-TRISA (Data Direction Register)
-LATA (Output Latch Register)

Code for Blink LED Project – For 10F322 and XC

/** File:main.c - Blink LED 10F322 XC* Author: Jamie Starling -** Created on March 17, 2019, 2:16 PM*/#include <xc.h>//Device Config#pragma config FOSC = INTOSC// Oscillator Selection bits->INTOSC oscillator: CLKIN function disabled
#pragma config BOREN = ON// Brown-out Reset Enable->Brown-out Reset enabled
#pragma config WDTE = OFF// Watchdog Timer Enable->WDT disabled
#pragma config PWRTE = ON// Power-up Timer Enable bit->PWRT enabled
#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 = OFF// Low-Voltage Programming Enable->High-voltage on MCLR/VPP must be used for programming
#pragma config LPBOR = ON// Brown-out Reset Selection bits->BOR enabled
#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//Used to calculate the delay time#define _XTAL_FREQ 8000000//8 MHz (default after Reset)//Function Prototypesvoid deviceSetup (void);void main(void)
{//Calls the device setupdeviceSetup ();//Main Loop - we should never exit from herewhile (1){//Top of Forever While Loop//Set PortA.0 High (turn on LED)LATAbits.LATA0 = 1;//Wait 1 second__delay_ms(1000);//Set PortA.0 Low(turn off LED)LATAbits.LATA0 = 0;//Wait 1 second__delay_ms(1000);//End of Loop}}void deviceSetup (void)
{//Turn off AnalogANSELA=0x00;//Setup Ports for OutputTRISAbits.TRISA0 = 0;TRISAbits.TRISA1 = 0;TRISAbits.TRISA2 = 0;//Bring Device into Known Configuration State//Clears Port A - Set LowLATA=0x00;PORTA=0x00;return;