#include <18F45K22.h>
#Device PASS_STRINGS=IN_RAM //#ZERO_RAM
#define FASTER_BUT_MORE_ROM // Variables en memoria
#fuses HSM, NOWDT, BROWNOUT, PUT, NOPBADEN, NOHFOFST
#fuses NOPLLEN //HW PLL disabled, PLL enabled in software
#fuses MCLR //Master Clear pin enabled
#fuses PROTECT //Code protected from reads
#use delay(clock=12MHz,crystal=12MHz)
#use rs232(baud=9600,bits=8,parity=N,xmit=PIN_C0,rcv=PIN_C1,ERRORS,stream=debug) // Configuración debug (Software)
#use rs232(baud=9600,bits=8,parity=N,xmit=PIN_C6,rcv=PIN_C7,ERRORS,stream=uart1) // Configuración UART1 (Hardware)
#use rs232(baud=9600,bits=8,parity=N,xmit=PIN_D6,rcv=PIN_D7,ERRORS,stream=uart2) // Configuración UART2 (Hardware)
/***************************************************************/
//default RS232 for debugging
void main()
{
int1 old_input;
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_INTERNAL|T1_DIV_BY_8);
set_timer1 (0x6FA);
setup_timer_2(T2_DISABLED,0,1);
setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
setup_timer_4(T4_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_ccp1(CCP_OFF);
setup_ccp2(CCP_OFF);
setup_ccp3(CCP_OFF);
setup_ccp4(CCP_OFF);
setup_ccp5(CCP_OFF);
setup_dac(DAC_OFF);
setup_adc(ADC_OFF);
setup_adc_ports(NO_ANALOGS);
old_input=input(PIN_A0);
while(TRUE)
{
delay_ms(1000);
// output_toggle(PIN_A0);delay_ms(200);
output_toggle(PIN_c2);delay_ms(200);
output_low(PIN_A0);
if (input(PIN_A0))
}
else{fprintf(debug
,"Pin bajo\n\r");} } //loop sending to the RS232 when pin changes.
}