Beruflich Dokumente
Kultur Dokumente
* File: newmainc2.c
* Author: leon serna
*
* Created on 15 de octubre de 2015, 11:17 AM
*/
// PIC16F1824 Configuration Bit Settings
// 'C' source line config statements
#include <xc.h>
#include <pic16f1824.h>
// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.
// CONFIG1
#pragma config FOSC = INTOSC
// Oscillator Selection (XT Oscillator, Crystal
/resonator connected between OSC1 and OSC2 pins)
#pragma config WDTE = OFF
// Watchdog Timer Enable (WDT disabled)
#pragma config PWRTE = ON
// Power-up Timer Enable (PWRT enabled)
#pragma config MCLRE = ON
// MCLR Pin Function Select (MCLR/VPP pin functi
on is MCLR)
#pragma config CP = OFF
// Flash Program Memory Code Protection (Program
memory code protection is disabled)
#pragma config CPD = OFF
// Data Memory Code Protection (Data memory code
protection is disabled)
#pragma config BOREN = ON
// Brown-out Reset Enable (Brown-out Reset enabl
ed)
#pragma config CLKOUTEN = OFF // Clock Out Enable (CLKOUT function is disabled
. I/O or oscillator function on the CLKOUT pin)
#pragma config IESO = ON
// Internal/External Switchover (Internal/Extern
al Switchover mode is enabled)
#pragma config FCMEN = ON
// Fail-Safe Clock Monitor Enable (Fail-Safe Clo
ck Monitor is enabled)
// CONFIG2
#pragma config WRT = OFF
// Flash Memory Self-Write Protection (Write pro
tection off)
#pragma config PLLEN = ON
// PLL Enable (4x PLL enabled)
#pragma config STVREN = ON
// Stack Overflow/Underflow Reset Enable (Stack
Overflow or Underflow will cause a Reset)
#pragma config BORV = LO
// Brown-out Reset Voltage Selection (Brown-out
Reset Voltage (Vbor), low trip point selected.)
#pragma config LVP = ON
// Low-Voltage Programming Enable (Low-voltage p
rogramming enabled)
#define _XTAL_FREQ 4000000
//Frecuencia de Oscilador
__delay_ms(500);
RA4=0;
}
}
//Funcin Inicializacin de puertos, ac Inicializamos todo lo que tenga que ver con p
uertos.
void port_init()
{
OSCCON=0b001101010;
ANSELA=0;
TRISA=0b000111;
xterna INT
TRISC=0b000000;
PORTC=0;
// PORTA=0;
//
//
//
//
IOCAP=0b000110; //pag137
//
IOCAN=0b000000;
//
IOCAF=0b000110;
}
//Funcin Principal
void main(void)
{
port_init();
//se inicializan los puertos.
while(1)
{
//Ciclo Infinito
__delay_ms(500);
PORTC=0b100001;
__delay_ms(500);
}
else if(RA0==0 && RA1==1
ue da el and es cero
RA4=0;
RA5=0;
PORTC=0b111111;
__delay_ms(500);
PORTC=0b000000;
__delay_ms(500);
){
}
else if(RA0==1 && RA1==0){
ro que da el and es cero
RA4=0;
RA5=1;
PORTC=0b100001;
__delay_ms(500);
PORTC=0b011110;
__delay_ms(500);
}
else if(RA0==1 && RA1==1){
a el and es cero
PORTC=0b000000;
RA4=1;
RA5=0;
}
else
//Si el numero entero que da el and es dif
erente de 0, 1 y 2 siempre saldr un cero en RA0
RC0=0;
}
}