|
|
View previous topic :: View next topic |
Author |
Message |
bittersweet
Joined: 23 Apr 2008 Posts: 22
|
RF modules |
Posted: Tue May 06, 2008 11:40 am |
|
|
Hi,
I want to use RF modules, I send data in interrupt function but it doesnt work i dont understand why, must I send data in while1() function?
here are the codes
Code: |
*****transmitter code****
#include <16F877A.H>
#fuses XT,NOWDT,NOPROTECT,BROWNOUT,PUT,NOLVP
#use delay (clock=4000000)
#use rs232 (baud=600, xmit=PIN_C6)
void main()
{
enable_interrupts(int_RB);
enable_interrupts(GLOBAL);
set_tris_b(0xFF);
while(1)
{
putc(0x55); //preamble bytes
putc(0x55);
putc(0x55);
putc(0x55);
putc(0x55);
putc(0x00); //sencron bytes
putc(0x00);
putc(0x00);
putc(0x00);
putc(0x00);
putc(0xff); //sencron bytes
putc(0xff);
putc(0xff);
putc(0xff);
putc(0xff);
putc(0xdd);
putc(0xcc);
}
}
#int_RB
void interrupt()
{
putc('y');
}
|
Code: |
***************receiver code*****
include <16F877A.H>
#fuses XT,NOWDT,NOPROTECT,BROWNOUT,PUT,NOLVP
#use delay (clock=4000000)
#include <lcd.c>
#use rs232 (baud=600, rcv=PIN_C7)
int say1=0;
int say2=0;
int i=0;
char x;
void read()
{
if(getc()==0xdd)
{if(getc()==0xcc)
{ x=getc();}
}
}
void fivebyte1() //if sencron bytes received test
{
while(1)
{
if(getc()==0xff)
{say2++;
if(say2>=5)
{say2=0;
read();
break;
}
}
}
}
void fivebyte0() // if sencron bytes received test
{
while(1)
{
if(getc()==0x00)
{say1++;
if(say1>=5)
{say1=0;
fivebyte1();
break;
}
}
}
}
void main()
{
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_CCP1(CCP_OFF);
while(1)
{
fivebyte0();
if(x=='y')
{output_high(pin_a2);
delay_ms(500);
output_low(pin_a2);
delay_ms(500);}
}
}
|
|
|
|
Matro Guest
|
|
Posted: Tue May 06, 2008 11:45 am |
|
|
Try a standard baudrate (for instance 9600) instead of 600.
Matro |
|
|
newguy
Joined: 24 Jun 2004 Posts: 1907
|
|
|
bittersweet
Joined: 23 Apr 2008 Posts: 22
|
|
Posted: Tue May 06, 2008 11:57 am |
|
|
@newguy
I dont want to use Int_RDA, I want to use Int_RB for transmitting data, but the codes u sent int_rda is used in receiver
@matro
but i use baud 600 and it works in simple codes, the modules i used support max 2400 baud |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|