Continue to Site

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.

Software UART Problem.

Status
Not open for further replies.

Suraj143

Active Member
I'm sending 8 bit data from a slave PIC to the master PIC.Slave PIC has internal UART & master PIC has software UART.

My problem is when master PIC is doing some other work & come back to read RX byte it can be in the middle of the byte of the receiving data.So the value will be incorrect.

Any method to overcome this & read the whole byte nicely??

Thanks
 
Last edited:
I'm sending 8 bit data from a slave PIC to the master PIC.Slave PIC has internal UART & master PIC has software UART.

My problem is when master PIC is doing some other work & come back to read RX byte it can be in the middle of the byte.So the value will be incorrect.

Any method to overcome this & read the whole byte nicely??

Thanks

hi Suraj,
Use the UART's RXD interrupt to read the RX data as it is detected.
Save the RX data in a string buffer until you are ready to process it.

EDIT: which pins are you using for the RXD input on the software uart.?
 
Last edited:
Hi eric gibbs thanks for your input.

The problem is I have to connect 8 slave PICs & read the incoming data from one master PIC.

I'm using eight 485 IC's in slave PIC's & eight 485 IC's in Mater PIC side.

I have a timing case here when to detect the start bit.
 
Last edited:
Hi eric gibbs thanks for your input.

The problem is I have to connect 8 slave PICs & read the incoming data from one master PIC.

OK.
Why not use PORTB.0 pin as the software UARTs RXD, then interrupt on PORTB.0 change.?
 
Last edited:
Hi Suraj,

When I think of a master/slave serial '485 buss I think of one '485 on the master and the other eight slave '485s on the same buss with the "master" managing traffic from only one "slave" at a time.
 
That’s a very good suggestion mike. I’m going to use it.

I don’t know 485 protocol so I’m going to use UART method for this. See my drawing.

In standby mode the bus will be in high impedance. Disabling all the drivers using CTRL lines & they are ready to receive data.

I address each slave PIC as 1, 2, and 3.

Now I enable driver in master PIC & send “1” using UART TXREG. That is slave PIC 1 address. All slave PIC’s will get this value but only slave PIC 1 will match this value. After matching it will enable its driver by CTRL line & send its data to the master PIC.

I must make sure at each time after sending data I must disable drivers by each PIC’s CTRL lines.

Is this going to work nicely?
 

Attachments

  • 485 Bus..PNG
    485 Bus..PNG
    13.7 KB · Views: 494
Last edited:
I think this is a version of Mikes advice, use an external interrupt for detecting which Slave is to send the data, have the same bus for data transmission.

Alternately if you are using a MAX485 IC then connect the bit to each of the DE and RE inputs turning the required bit on for each specific IC( you will require an inverter here if you can not spare 2 bits for each IC.Or you can even use a decoder for that purpose, use 3 bits and connect them to the Decoder, using a not gate do it.
 

Attachments

  • masterslave..JPG
    masterslave..JPG
    23 KB · Views: 196
  • 485..JPG
    485..JPG
    59.9 KB · Views: 210
Last edited:
Wond3rboy Your design needs additional chip select lines that is too much work & wasting master PIC pins.

In my method ( Mikes Method) the chip selecting signal goes from the same 2 wire data bus.Not with an additional wire.

Mike where are you whats your idea?
 
Last edited:
Hi Suraj,

You've got the idea. As far as a protocol, there are lots of ways to do that too.

I have used a short distance one pin Icom CI-V serial buss (5 volt signal levels) and protocol in the past with very good results. The protocol defines data records with a "header" or "preamble" byte, "address" bytes, a "command" byte, optional "data" bytes, and an "end-of-record" byte.

You can find lots of info' on the Icom CI-V protocol here; Ekki's CI-V Pages

Regards, Mike
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top