hi friends im trying to make a communication between 2 pics (tx-16F627A n rx-16f877A) via RF (TLP434 n RLP434) but i cant obtain any result.
1º i was trying with a simple program through a simple PIN, but it was a lot of problems, then i tried with uart port but im still havin problems, here are the code of the tx and rx…
tx:
#include <16F627.h>
#fuses INTRC_IO,NOWDT,NOPROTECT,PUT,NOLVP,BROWNOUT,NOCPD,NOMCLR
#use delay(clock=4000000,RESTART_WDT)
#use RS232(BAUD=600, BITS=8, PARITY=N, XMIT=PIN_B2, RCV=PIN_B1, RESTART_WDT, FORCE_SW)
#byte TRISA=0x85
#byte CMCON=0x1F
//--------------------------------------------------------
void enviar_trama()
{
putc(0x55);
putc(0x55);
putc(0x29); //data
putc(0x55);
}
//--------------------------------------------------------
#INT_EXT
Ext_Int_Handler()
{
delay_ms(30);
enviar_trama();
}
//--------------------------------------------------------
void main()
{
CMCON=0x07;
TRISA=0xFE;
ext_int_edge(H_TO_L);
enable_interrupts(INT_EXT);
enable_interrupts(GLOBAL);
sleep();
}
rx:
#include <16F877A.h>
#fuses XT,NOWDT,NOPROTECT,PUT,NOLVP,BROWNOUT,NOCPD,NOWRT //HS
#use delay(clock=4000000,RESTART_WDT)
#use RS232(BAUD=600, BITS=8, PARITY=N, XMIT=PIN_C6, RCV=PIN_C7,RESTART_WDT,ERRORS) // c7
int8 cont=0;
int8 j;
int8 aux;
int8 trama[4];
#define BUFFER_SIZE 4
//--------------------------------------------------------------------
#int_RDA
void RDA_isr(void)
{
output_low(PIN_B6);
trama[cont] = getc();
aux = trama[cont];
if(aux==0x55) // just for save data
{cont–;}
cont++;
if (cont > BUFFER_SIZE)
{ cont = 0; }
output_high(PIN_B6);
}
//--------------------------------------------------------------------
#INT_EXT
Ext_Int_Handler()
{
delay_ms(30);
for(j=0;j<=7;j++)
{
if(bit_test(trama[0],j))
{output_high(PIN_B5);}
else
{output_low(PIN_B5);}
delay_ms(1000);
}
output_low(PIN_B5);
trama[0]=0;
trama[1]=0;
trama[2]=0;
trama[3]=0;
output_high(PIN_B7);
delay_ms(1000);
output_low(PIN_B7);
}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
void main()
{
ext_int_edge(H_TO_L);
enable_interrupts(INT_EXT); // Habilita interrup. EXT
enable_interrupts(INT_RDA); // Habilita interrup. dato recibido en USART
enable_interrupts(GLOBAL); // Habilita interrup. GLOBAL
output_high(PIN_B6);
while(1);
}
HELP ME PLEASE IM SO DESPERATE!!!