Shop OBEX P1 Docs P2 Docs Learn Events
Propeller and AVR's — Parallax Forums

Propeller and AVR's

Eric PetersonEric Peterson Posts: 2
edited 2006-12-13 02:36 in Propeller 1
Hello,
·
I am new with the Propeller and here is my situation:
·
I need the Propeller to communicate with several Atmel AVRs on a shared bus. I am very limited as far as pins on the bus so I was hoping to use UART's·at TTL levels and incorporate·tri-state ability for the AVR transmitters. Another option would be to use the SPI (MOSI,MISO,SCK) on the AVR's. So my questions are:
·
1. Is there·a source code object that would allow the Propeller to talk to the AVR's using their·SPI?
·
2. Is I2c an option?
·
3. Is there a simpler method than tri-stating the transmitters on the AVR's?
·
Any info is greatly appreciated.
·
Eric···

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2006-12-12 15:54
    1) SPI varies so much from device to device that there are several device specific routines already in the Propeller Object Exchange Library. Use the routines in the BS2 compatibility library for examples (SHIFTIN and SHIFTOUT), but you will have to tailor them for your specific circumstances.

    2) There is an I2C master package also in the Object Exchange Library written in SPIN. I have an assembly I2C routine that's part of the Propeller OS that is usable on its own as well.

    3) On a shared bus, you'll have to have some kind of party line. You can tri-state the transmitters. You can use the transmitters to feed a transistor (bipolar or MOSFET) that provides an open-collector (open-drain) bus with a pullup resistor. If you have a limited number of AVRs, you could use a 1:8 or 1:16 multiplexor to select which AVR you're going to listen to. If you have enough spare Propeller pins, you could just wire a separate pin to each AVR's transmit line, but use a single Propeller pin to transmit to all the AVRs. You could effectively do a "wired-or" in software in the serial input routines to simplify some of the coding (change the references from a single pin (INA[noparse][[/noparse]x]) being a one to a range of pins (INA[noparse][[/noparse]x..y]) being non-zero.
  • BTXBTX Posts: 674
    edited 2006-12-12 15:55
    Eric.
    How many AVR's ?
    How long one from another ?
    Did you think in a RS485 line ? It's not difficult.....
    RS485 line using FullDuplexSrial propeller object could be fine.

    Regards.
    Alberto.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2006-12-12 17:36
    BTX really identifies the problem.
    How far? Inches or meters?

    If it is mere inches I2C is likely the best as it has acknowledge and can indicate the need to resend, upto 400K bits per second in some case.
    SPI is much simpler and much faster, up to Mhz of bits per second - good for being on the same board, but not much else.

    Technically RS485 is never full duplex. Full duplex is RS-422. But that can go for kilometers using the RS-232 software with the TTL going into RS-422 Transmiters and Recievers.

    So if the AVR uses full duplex serial, it is likely the simplest for both distance and speed.
    I2C and SPI don't over the full duplex and usually require timing a Master/Slave link. More complex software control.

    I am not sure what 'tristating the transmiters on the AVRs' means. And this is an awkward place to ask for tech support on the AVR side of it all. I just don't have time to learn them too, the PDFs are huge

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "If you want more fiber, eat the package.· Not enough?· Eat the manual."········
    ···················· Tropical regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
  • Eric PetersonEric Peterson Posts: 2
    edited 2006-12-13 02:36
    Thanks guys,

    I decided to use the UARTs and add a 74hc125 to tristate the unused transmit lines. Works great.

    BTX: The distance is inches accross the same board.

    Kramer: Tristating is putting the unused transmitters into a high impedance state so that the other transmitters can use the same line.

    Thanks again,
    Eric
Sign In or Register to comment.