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 support@ccsinfo.com

tx433 & rx433

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



Joined: 05 Apr 2013
Posts: 11

View user's profile Send private message

tx433 & rx433
PostPosted: Tue Apr 09, 2013 10:43 am     Reply with quote

I have tried many code, and that doesn't work.
Confused

I really need a real help here (correcting the code).

Transmission
Code:

#include <16F876.h>
#fuses XT,NOWDT,PROTECT,NOBROWNOUT,PUT

#use delay(clock=10M)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)

void main()
{

int start;
int addr;
int data ;
int chksum;

set_tris_b(0x00);
set_tris_a(0xff);
start = 0x55 ;
addr = 0x8E;     
data = 0x27; 
chksum = (addr + data);

while(true)
{
if (input(pin_b1))
{
output_high(pin_a1);
putc(start);
delay_ms(20);
putc(addr);
delay_ms(20);
putc(data);
delay_ms(20);
putc(chksum);
delay_ms(20);
}
else
{
putc(0x66);
delay_ms(20);
putc(0x66);
delay_ms(20);
putc(0x66);
delay_ms(20);
putc(0x66);
delay_ms(20);
}
}
}


receiver code
Code:

#include <16F876.h>
#fuses XT,NOWDT,PROTECT,NOBROWNOUT,PUT
#use delay(clock=10M)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
void main()
{
char c;
int start;   
int addr;     
int data;     
int chksum;
set_tris_b(0x03);
while(true)
{
if(kbhit())
{
start=getc();
delay_ms(20);
addr=getc();
data=getc();
delay_ms(20);
chksum=getc();
delay_ms(20);


if (start ==0x55)
         {
         output_high(pin_b1);
               }
               else
               {
               output_low(pin_b1);
               }
  if (data ==0x27) 
  {
  output_high(pin_b2);
  }
  else
  {
  output_low(pin_b2);
  }
 
   if (addr ==0x8E) 
  {
  output_high(pin_b3);
  }
  else
  {
  output_low(pin_b3);
  }
  if (chksum ==(addr + data)) 
  {
  output_high(pin_b4);
  }
  else
  {
  output_low(pin_b4);
  }
 
         }
}
}


in isis this work perfectly


Last edited by midoroi on Tue Apr 09, 2013 11:37 am; edited 1 time in total
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Tue Apr 09, 2013 11:05 am     Reply with quote

On the receiver get rid of the 2ms delays. Once the PIC reaches getc() it will wait until a character comes in. Beware it will wait forever if a character never comes in.

If your receiver 2ms is a little longer than the transmitter 2ms then the receiver will wait too long and getc() will miss the start of the next byte.
_________________
The search for better is endless. Instead simply find very good and get the job done.
midoroi



Joined: 05 Apr 2013
Posts: 11

View user's profile Send private message

PostPosted: Tue Apr 09, 2013 11:38 am     Reply with quote

i thinked to make if(kbhit()) to read all the bytes.on the place of delay_ms(20)
i means make 5 ==> if (kbhit())
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Tue Apr 09, 2013 12:16 pm     Reply with quote

Hi,

Why have you started a new thread on exactly the same topic? This is confusing, because people won't realize it, and a lot of information will need to be repeated. This is a sure way to annoy the forum members and get your thread locked!

Use your original thread here: http://www.ccsinfo.com/forum/viewtopic.php?t=50212


John
midoroi



Joined: 05 Apr 2013
Posts: 11

View user's profile Send private message

PostPosted: Tue Apr 09, 2013 3:32 pm     Reply with quote

ezflyr wrote:
Hi,

Why have you started a new thread on exactly the same topic? This is confusing, because people won't realize it, and a lot of information will need to be repeated. This is a sure way to annoy the forum members and get your thread locked!

Use your original thread here: http://www.ccsinfo.com/forum/viewtopic.php?t=50212


John

i opened new topic because it is new idea
midoroi



Joined: 05 Apr 2013
Posts: 11

View user's profile Send private message

PostPosted: Tue Apr 16, 2013 12:47 pm     Reply with quote

help friends,
I need simple program for these components.
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Wed Apr 17, 2013 5:11 am     Reply with quote

You have not explained:-

1) What you are trying to do.
2) What result(s) you expect.
3) What result(s) you get.
4) What does/doesn't work.
5) What the problem is.

Start by posting the SHORTEST possible, complete, compilable code which shows the issue you've got.

Mike
Ttelmah



Joined: 11 Mar 2010
Posts: 19454

View user's profile Send private message

PostPosted: Wed Apr 17, 2013 8:06 am     Reply with quote

Classic thing.
What is the maximum clock frequency supported by the XT fuse setting?.
Isis doesn't check such things at all, and the things it does check it often gets wrong. It is like repeatedly shooting yourself in the foot, to look at Isis as being 'helpful' with the PIC.....
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