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

serial communication channels of 16F84A

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



Joined: 10 Feb 2004
Posts: 1
Location: TURKEY

View user's profile Send private message

serial communication channels of 16F84A
PostPosted: Sat Mar 06, 2004 3:47 am     Reply with quote

I have a problem with 16F84A. I am using one pin of 16F84A as receiving pin and I am satisfied with good results, that is no problem about the serial communication.
However I want to use three pins of the 16F84A as receiving pin.Because I have three infrared receivers.
How can I do this?
Can you suggest a software solution?
If impossible with software what should I do?

Thank you for your help.......
Ttelmah
Guest







Re: serial communication channels of 16F84A
PostPosted: Sat Mar 06, 2004 4:27 am     Reply with quote

ukaza wrote:
I have a problem with 16F84A. I am using one pin of 16F84A as receiving pin and I am satisfied with good results, that is no problem about the serial communication.
However I want to use three pins of the 16F84A as receiving pin.Because I have three infrared receivers.
How can I do this?
Can you suggest a software solution?
If impossible with software what should I do?

Thank you for your help.......

So long as you can guarantee that only one receiver will send data at a time, what you want can be done.
Put the three inputs onto the high PORTB pins (RB4:7 - use just three of these). In the main code, read PORTB, and enable the 'interrupt on change' feature on these pins. Then when the interrupt takes place, read PORTB, and check which of the pins has dropped. The code will be something like:

Code:

int1 RX_DATA=false;

#INT_RB
void port_has_changed(void) {
    int8 ipval;
    ipval=INPUT_B();
    disable_interrupts(INT_RB);
    RX_DATA=true;
    if ((ipval & 0x10)==0) {
       #USE_RS232(baud=1200,parity=N,rcv=PIN_B4);
       return;
    }
    if ((ipval & 0x20)==0) {
       #USE_RS232(baud=1200,parity=N,rcv=PIN_B5);
       return;
    }
    #USE_RS232(baud=1200,parity=N,rcv=PIN_B6);
}

//Note that the code will only pick up the 'first' bit that has dropped
//and that you must ensure B7, does not change.

In the 'main', you will need to read port B, and then enable the RB interrupt. Then sit waiting for 'RX_DATA' to go true. When it does, use:
Code:

    char=getc();  //This will read the character from the selected input bit
    RX_DATA=false;
    enable_interrupts(INT_RB);


Obviously, you could also use the 'stream' ability, and set the stream in the interrupt. You may also want to just set a number so you know which pin has received the data.
Where you will get problems, is if more than one receiver sends data at the same time...

Best Wishes
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