This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

SPI: MASTER AND SLAVE SHOULD COMMUNICATE USING SAME CODE

HI ALL

I try to implement same code in master and slave for spi communication. Is it possible to do so? In detail, master will have code for both master_init and slave_init. The exact replica will be in slave controller. Which ever turns on first, it needs to configured as master and the other one as slave. This is my requirement. Innovative ideas, suggestions, h/w suggestions are requested on this concept

  • Hi Naga,

    Which controller are you using? Basically SPI peripheral has a register SPICTL in which you can configure the device as Master/Slave.

    Regards,

    Gautam

  • I am using F28021. configuration is fine. But i am looking for logic : i need same code for master and slave. whichever turns on first iit should configure as master and the later one as slave.

  • naga iec said:
    But i am looking for logic : i need same code for master and slave. whichever turns on first iit should configure as master and the later one as slave.

    There's no ready made code or provision as such but you can write an algorithm to do so. What you can do is, use SCI to determine the master/slave (using first power ON logic) and then configure SPI accordingly.

    Regards,

    Gautam

  • Thank U Gautham.

    The idea what u gave is good. I will try on this logic. But a small correction here. I havent asked readymade code on this. i requested some ideas on this.

    Thank you for your valuable inputs.

  • naga iec said:
    The idea what u gave is good.

    Thanks!

    naga iec said:
    I will try on this logic.

    Sure, do keep us informed.

    naga iec said:
    But a small correction here. I havent asked readymade code on this. i requested some ideas on this.

    No problem, I misunderstood when you asked for "i need same code for master and slave".

    Regards,

    Gautam