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

How can I send and receive 16 bits of data between two PICs

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



Joined: 21 Aug 2009
Posts: 15
Location: Texas

View user's profile Send private message

How can I send and receive 16 bits of data between two PICs
PostPosted: Mon Oct 05, 2009 10:01 am     Reply with quote

I would like to send and receive 16 bits of data from one PIC to another but I'm not sure how to go about doing this. I was thinking of using fputc from rs232 but I only see in the options the ability to send and receive 9 bits using long_data and setting the bits=9. Any suggestions? Thanks.
kdoney34711



Joined: 05 Oct 2009
Posts: 6

View user's profile Send private message

PostPosted: Mon Oct 05, 2009 10:16 am     Reply with quote

Do you have to use any specific pics and does it have to be in one transfer?
Code:

// PSPMASTER.C

#include "16F877A.h"

void main()
{
    int sendbyte;

    port_b_pullups(1);

    while(1)
    {   sendbyte = input_B();
        output_D(sendbyte);

        output_low(PIN_E2);
        output_low(PIN_E1);
        output_high(PIN_E1);
    }
}

// PSPSLAVE.C

#include "16F877A.h"

void main()
{
    int recbyte;

    setup_psp(PSP_ENABLED);
   
    while(1)
    {   if(psp_input_full())
        {   recbyte = input_D();
            output_C(recbyte);
        }
    }
}



Of course if it must be in one transfer you will need more ports.
_________________
KDONEY
SherpaDoug



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

View user's profile Send private message

PostPosted: Mon Oct 05, 2009 4:47 pm     Reply with quote

Serial data is usually sent in bytes. That is how hardware UARTs are constructed. The 9th bit, parity bit, etc. are special and not generally expandable to 16 bits.

To send 16 bits just use two byte transfers.
_________________
The search for better is endless. Instead simply find very good and get the job done.
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