Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

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
 

Nigel Goodwin

Super Moderator
Most Helpful Member
jijita said:
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!.
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top