Follow along with the video below to see how to install our site as a web app on your home screen.
Nota: This feature currently requires accessing the site using the built-in Safari browser.
#include "pic12f629.h"
#include <stdio.h>
#include <stdlib.h>
#include "CONFIG.h"
#include "ADC.h"
#define _XTAL_FREQ 4000000
uint8_t tiempo;
uint8_t datos[10];
void __interrupt() Interrupcion(void){
if(INTCONbits.TMR0IF == 1){
PORTAbits.a1 = 1; //alto
__delay_us(100);
PORTAbits.a1 = 0; //bajo
INTCONbits.TMR0IF = 0;
INTCONbits.TMR0IE = 0;
}else if(PIR1bits.RCIF == 1){
char dataRX = RCREG;
PIR1bits.RCIF = 0;
}
else if(INTCONbits.INTF == 1)
{
PORTAbits.RA1 = 0; //triac apagdo
TMR0 = tiempo;
INTCONbits.TMR0IF = 0; //Limpia bandera de tmr0
INTCONbits.TMR0IE = 1;
INTCONbits.INTF = 0;
}
}
void TIMER0_init(void)
{
OPTION_REGbits.T0CS = 0; //0 TEMP, 1 CONT
OPTION_REGbits.PSA = 0; //0= PRE-TMR0, 1=PRE-WDT
OPTION_REGbits.PS = 0B100; //256
TMR0 = 255;
}
void RB0_init(void)
{
OPTION_REGbits.INTEDG = 1; //1 subida, 0= bajda
INTCONbits.INTF = 0;
}
void main(void) {
TRISAbits.TRISA1 = 0; //triac
TRISAbits.TRISA0 = 1; //in
ADC_init();
//UART_init();
TIMER0_init();
RB0_init();
INTCONbits.GIE = 1; //Habilita interrupcion global
INTCONbits.INTE = 1; //Habilita interrupcion por RB0
__delay_ms(500);
while(1)
{
tiempo = ADC_read(0);
if(tiempo >= 210){
PORTAbits.RA1 = 1;
INTCONbits.INTE = 0;
}else if(tiempo <= 10){
PORTAbits.RA1 = 0;
INTCONbits.INTE = 0;
}else{
INTCONbits.INTE = 1;
}
sprintf(datos, "%d\n\r", tiempo);
//UART_write_text(datos);
__delay_ms(10);
}
return;
}
Podría ser XC-8 o Hi-Tech C con MPLAB-X¿qué compilador estás usando?
Eso le hará ver el error.¿Sabes que el 12F629 no tiene ADC? El que lo implementa es el 12F675
X8Tengo 2 preguntas, ¿qué compilador estas usando? y ¿sabes que el 12F629 no tiene ADC? el que lo implementa es el 12F675
¿Por qué no ponen atención a los mensajes?
¿Por qué no ponen atención a los mensajes?![]()
¿Por qué no ponen atención a los mensajes?![]()