You are on page 1of 1

User File

The user file is used to define the ports of the microcontroller as inputs and outputs.
The PORT A is defined as analog input through ADC and the PORT E is defined digital
input through Hall sensor. The PORT C is defined as digital output from pic to drivers.
#if defined(__XC)
#include <xc.h>
/* XC8 General Include File */
#elif defined(HI_TECH_C)
#include <htc.h>
/* HiTech General Include File */
#endif
#include <stdint.h> /* For uint8_t definition */
#include <stdbool.h> /* For true/false definition */
#include "user.h"
void InitApp(void)
{
TRISB=0x00;
//Make port B as output
TRISC=0x00;
//Make port C as output
TRISE=0x07;
//Take last 3bits of port E as input
ANSEL=0x00;
//Make Port A0 to A7 digital input
ANSELH=0x00;
//Make Port A8 to A15 digital input
ANSEL=0x02;
PS0=1;
PS1=1;
PS2=1;
PSA=0;
T0SE=0;
T0CS=0;
TMR0=0;
TMR0IE=1;
PEIE=1;
GIE=1;
}
.

You might also like