viknes1985
Newbie level 5
manchester code
Hi, I tried to get help from many people on machester decoding. No one could help. So i started to read the manchester code. The idea is, if the width of the pulse is 90us, pic start to sample after 45us. So it would always stay in the middle of the pulse. This is so far i got to, but no idea why this never works. anyone, please help Please help. I'll work on myself on decoding, for now, i just want to read the code from EM4001. If you've any other method, let me know (viknes1985@hotmail.com)
Hi, I tried to get help from many people on machester decoding. No one could help. So i started to read the manchester code. The idea is, if the width of the pulse is 90us, pic start to sample after 45us. So it would always stay in the middle of the pulse. This is so far i got to, but no idea why this never works. anyone, please help Please help. I'll work on myself on decoding, for now, i just want to read the code from EM4001. If you've any other method, let me know (viknes1985@hotmail.com)
Code:
#include <16F877A.h>
//#FUSES XT,NOWDT,NOPROTECT,NOPUT, HS, NOLVP
#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
#use delay(clock=20000000)
#use rs232(baud=9600,xmit=PIN_B6,rcv=PIN_B7,stream=TOPC)
//#use rs232(baud=9600,xmit=PIN_D7,rcv=PIN_D6,stream=SIGNAL)
//#byte a_port = 5 //Port you want to use
#byte b_port = 6
//#byte d_port = 8
#int_ccp1
void main ()
{
//SET_TRIS_A(0x0A);
SET_TRIS_B(0x81);
setup_ccp1(CCP_CAPTURE_RE); // to know the starting point
if (CCP_1) //if there's any rising edge
{
delay_us(45); //shift to half of the pulse
while (TRUE)
{
int x=0;
while (x<=64) //for 64 bits
{
if (input(PIN_B0)) //from u2270 output (manchester code)
fputc('1'); //show 1 when high
else
fputc('0'); // show 0 when low
delay_us(90); //shift to next pulse
x++;
}
delay_ms(1000);
fputs(" Next 64 bits ");
}
}
else
{
fputs(" Not Yet find the rising edge ");
}
}