serial communication pc pic

Status
Not open for further replies.

jijita

New Member
i'm sending binary data from pc matlab to pic using asynchronous communication
i was told that i have to do a software handshaking but i don't know how
plus there is a problem in matlab i don't know how to calculate the time each bit will take.
about the software handshaking there are xon Xoff used to resume and pause transmission i don't know how can i use them in my software


so in my code i'll check for the start bit first then the 8 data then the stop bit
where does the software handshaking fit in this
please help me
 

It doesn't, it's not part of the actual data transfer itself.

Software handshaking uses data sent back from the receive side, telling the transmitter to stop sending any more data, then telling it to resume again later.

So, as an example, assume you PIC has an 8 byte buffer for received data - once 8 bytes are received the buffer is full, so the PIC sends an Xoff byte back to the PC which then pauses sending data. Once the buffer is empty, or has some space (it's your choice), the PIC will send an Xon code, and the PC resumes sending the data.

If you are writing both sides of the connection, you have full control over what goes on - for the example above you could arrange for the PC to transmit in 8 byte 'packets', then pause and wait for an 'ACK' (acknowledge) before sending the next 8 bytes. This produces the same result, but doesn't require you to sent an Xoff command to stop the flow of data.

The time per bit is dependent on the baudrate used, simply divide 1 by the baudrate to get the bit time in seconds - so 1/9600=104uS per bit, for 9600 baud. Many people prefer to use BPS rather than baud, but for this purpose they are the same thing.

Have a look at my RS232 PIC tutorials, they may help you - although I don't deal with handshaking, it's rarely required - and not at all if you carefully design not to require it!.
 
I used simple pascal to communicate via COM, and I don't have to use handshake communication. Everything is good. The tutorial of Nigel is very good, and you will pleasure with it.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…