CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

RF modules

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
bittersweet



Joined: 23 Apr 2008
Posts: 22

View user's profile Send private message

RF modules
PostPosted: Tue May 06, 2008 11:40 am     Reply with quote

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







PostPosted: Tue May 06, 2008 11:45 am     Reply with quote

Try a standard baudrate (for instance 9600) instead of 600.

Matro
newguy



Joined: 24 Jun 2004
Posts: 1909

View user's profile Send private message

PostPosted: Tue May 06, 2008 11:51 am     Reply with quote

Working interrupt driven code: http://www.ccsinfo.com/forum/viewtopic.php?t=23953
bittersweet



Joined: 23 Apr 2008
Posts: 22

View user's profile Send private message

PostPosted: Tue May 06, 2008 11:57 am     Reply with quote

@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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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