sacalu
Joined: 10 May 2007 Posts: 4
|
need help pls for manhester encoding |
Posted: Thu May 10, 2007 5:35 am |
|
|
hey,this might be a stupid request but since i'm a newbie at this i'll do i anyway .i want to encode manchester a character send via rs232....so here's my code
Code: |
#include "E:\PICC\Devices\16f88.h"
#use DELAY(clock=8000000,internal)
#use rs232(baud=9600, xmit=pin_b5,rcv=PIN_B2)
#use fixed_io(a_outputs=pin_a0)
#fuses intrc,mclr,noprotect,nowdt,nowrt,nolvp,noput,nocpd
void main()
{
int i,b=0;
char a,c,e1,e2;
int16 f,e=0x0000;
c=getch();
a=c;
for (i=0;i<7>>=2;
if (c&&0x01)
{e=e^0x8000;}
else
{e=e^0x4000;}
c>>=1;
}
putchar(a);
f=e;
e1=f;
f>>=8;
e2=f;
/*while (b==0){
for (i=1;i<=7;i++)
{
if (e2&&0x01)
output_bit(pin_a0,1);
else output_bit(pin_a0,0);}
delay_ms(30);
}*/
for (i=1;i<=7;i++)
{
if (e2&&0x01)
output_bit(pin_a0,1);
else output_bit(pin_a0,0);
}
delay_ms(100);
for (i=1;i<=7;i++)
{
if (e1&&0x01)
output_bit(pin_a0,1);
else output_bit(pin_a0,0);}
}
|
the questin is this code send's the 16 bit variable wright...if not can u suggest some way to do this
Last edited by sacalu on Thu May 10, 2007 6:57 am; edited 5 times in total |
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Thu May 10, 2007 6:13 am |
|
|
We can't read your code as the forum interpreted some of the source code as HTML text. When posting code please tick the 'Disable HTML in this post' checkbox, also use the 'code' buttons in order to preserve the formatting.
Registering to this forum is free and gives the advantage that you can edit an earlier post. Also you can then set the 'Disable HTML in this post' as a default setting in your profile.
From the part of your code that is readableHere you should use the 'bit wise' AND operator, now you are using the 'logical' AND (use & i.s.o. &&).
Use the search function of this forum, Manchester encoding has been discussed several times in the past. |
|