This repository has been archived by the owner on Apr 26, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
63 lines (56 loc) · 2.2 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// CONFIG1
#pragma config FOSC = INTRC_NOCLKOUT// Oscillator Selection bits (INTOSCIO oscillator: I/O function on RA6/OSC2/CLKOUT pin, I/O function on RA7/OSC1/CLKIN)
#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled and can be enabled by SWDTEN bit of the WDTCON register)
#pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled)
#pragma config MCLRE = OFF // RE3/MCLR pin function select bit (RE3/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 CPD = OFF // Data Code Protection bit (Data memory code protection is disabled)
#pragma config BOREN = ON // Brown Out Reset Selection bits (BOR disabled)
#pragma config IESO = OFF // Internal External Switchover bit (Internal/External Switchover mode is disabled)
#pragma config FCMEN = OFF // Fail-Safe Clock Monitor Enabled bit (Fail-Safe Clock Monitor is disabled)
#pragma config LVP = ON // Low Voltage Programming Enable bit (RB3 pin has digital I/O, HV on MCLR must be used for programming)
// CONFIG2
#pragma config BOR4V = BOR40V // Brown-out Reset Selection bit (Brown-out Reset set to 4.0V)
#pragma config WRT = OFF // Flash Program Memory Self Write Enable bits (Write protection off)
#include <xc.h>
#include <stdlib.h>
#include <stdio.h>
#include "house.h"
#include <string.h>
void main(){
//Configura entradas y salidas
ANSEL=0;
ANSELH=0;
OPTION_REG=0x04;
TRISB=0x3F;
TRISA=0xFF;
TRISC=0x00;
TRISC7=1;
//Configura UART a 9600 baudios
TXSTAbits.TXEN=1;
TXSTAbits.BRGH=1;
RCSTAbits.SPEN=1;
RCSTAbits.CREN=1;
BAUDCTLbits.BRG16=0;
SPBRG=25;
SPBRGH=0;
//Configura puerto AD
ANSELH=0;
ANSELHbits.ANS9=1;
ADCON1bits.ADFM=1;
ADCON1bits.VCFG0=0; ADCON1bits.VCFG1=0;
ADCON0bits.ADON=1;
ADCON0bits.CHS0=1; ADCON0bits.CHS1=0; ADCON0bits.CHS2=0; ADCON0bits.CHS3=1;
LED1 = 0;
LED2 = 0;
Relay = 0;
Buzzer = 0;
VentTrans1 = 0;
VentTrans2 = 0;
while(1){
//RECIBE UN COMANDO
if (RCIF == 1){
RX_Byte();
}
}
}