#include <16F877A.h>
#device adc=8
#FUSES NOWDT //No Watch Dog Timer
#FUSES HS //High speed Osc (> 4mhz)
#FUSES NOPUT //No Power Up Timer
#FUSES NOPROTECT //Code not protected from reading
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD //No EE protection
#FUSES WRT_50% //Lower half of Program Memory is Write Protected
#use delay(clock=4194304)
#use delay(crystal = 4.194304MHz)
#use rs232(baud=9600,parity=N,xmit=PIN_E0,rcv=PIN_B0, stream=COM2,bits=8)
//#use rs232(baud=9600, xmit=PIN_E0, rcv=PIN_B0, stream=COM2) // WT5001 Software
-----------------------------------------------------------
#include "E:\WT5001.h"
#include <string.h>
#define Luz_p Pin_C4
#Byte Puerto_A = 0x85
#Byte ProtA = 0X05
#Byte Puerto_D = 0x88
#Byte ProtD = 0X08
char cmd0[]={0x7E,0x04,0xA0,0x00,0x01,0x7E}; // Comando CMDO datos a enviar ;
Int i=0;
#int_TIMER1
void TIMER1_isr(void)
{
// setup_timer_1(T1_DISABLED);
set_timer1(0);
// setup_timer_1(T1_INTERNAL|T1_DIV_BY_8);
}
#int_rda
void rda_isr(Void) // harware Sim900
{
//aquí llega la interruptor de Sim900
// VGN_Resive = getc( );
}
/********************************************************************/
#int_EXT
void EXT_isr(void) // Software Wt5001
{
//aquí llega la interruptor de Wt5001
}
//----------------------------
void main()
{
setup_adc_ports(NO_ANALOGS);// decimos al compilador que todos los puertos pasan hacer digitales y no analogos
setup_adc(ADC_OFF);//se encarga básicamente de setear que puertos van a trabajar como analógicos y que puertos van a trabajar como digitales.
setup_psp(PSP_DISABLED);
setup_spi(SPI_SS_DISABLED);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_INTERNAL|T1_DIV_BY_8);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
// -----------------------------------------------------
enable_interrupts(GLOBAL);
enable_interrupts(INT_EXT);
enable_interrupts(int_rda);
set_timer1(0);
//--------------------------------------------------------
Puerto_A = 0x00;
PROTA = 0x00;
Puerto_D = 0x00;
PROTD = 0x00;
//-------------------------------------------------
for(i=0;i<=5;i++)
{
fprintf (COM2,"%c",cmd0[i]);
}
//fprintf (COM2,"%C","0x7E,0x04,0xA0,0x00,0x01,0x7E");
while(true)
{
output_high(PIN_A0);
delay_ms(1000);
output_low(PIN_A0);
delay_ms(1000);
}// while(true)
}//void main()