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.

FSX control problem on McBSP as SPI master



Hello

I am using the McBSP in SPI master mode on my F28M35H52C1

In my SPI communication I have to control three independants slaves.

my CLKX and DX pins works perfectly

but I don't understand how I can use the FSX pin to control three chips select.

I tried to detect the end of each transmission by checking the XRDY register (in SPCR2) and "manually" change the state of my three output by controlling the GPIO, but it didn't work, the register apparently is not updated when the transmission is over.

Could you help me ?

Thanks in advance.

Regards.

Adrien

  • Adrien,

    Haven't tried this on the McBSP, but it should be somewhat similar to SPI.  I provided a few methods and an example here using the C28x SPI:

    http://e2e.ti.com/support/microcontrollers/tms320c2000_32-bit_real-time_mcus/f/171/t/171156.aspx#625809

    I think you will get the concept.. unfortunately, there is no seamless way to do it.  Could you tell us more about your application?  We have had numerous requests about this in the somewhat recent past, so we would like to understand the need.  Is this a field application, school project, etc?

    Thanks,

    Kris

  • Kris,

    My application is a control panel for my company, it's an industrial R&D project.

    My application is quiet similar to this representation wherein the Master is my c2000 and the three slaves are three DAC. The connections between the components are identical in my project but I use the McBSP peripheral in SPI mode.

     

    I thought that with the FSX I could control by in an interruption (MXINTA) the chip selects. I configure XINTM = 2 to send XINT request to the CPU when each transmit frame-synchronization pulse is detected ; and in the interruption I control my chip select with the GPIO but I have some problems with that method.

    My real problem is how to detect when the transmission to a slave is over to switch the chip select ?

    Your application give a good way to implement my solution I will make some tests.

    I hope that my explanations are not too confusing.

    Regards

    Adrien

  • Adrien,

    Thank you for the application information.  This helps us evaluate if we need to make peripheral enhancements such as this.

    If you don't mind wasting a few GPIOs, here is another solution I didn't think of in the post I linked you to.  Tie the output of the slave select line which is controlled by the McBSP hardware to a GPIO configured as a XINT.  Set the XINT to generate an interrupt on a rising edge.  Before your transmission, set your GPIO slave select line for whichever device you are communicating to low, indicating that device is selected.  The McBSP generated slave select line will return high when the transmission is completed, generating a XINT interrupt to the CPU.  In this interrupt, just set all of your GPIO slave selects high (you can use an if statement, but probably takes as many or more cycles to figure out which is low).

    If you have the pins to spare, this is probably the easiest and least CPU intensive way.

    I'm not sure I followed your explanation.  If you could send some diagrams or waveforms or what you expect to happen that might help.  I'm not sure the frame sync signal is functional in SPI mode, but not entirely sure right off hand.  Might be misunderstanding you though.

    Kris

  • Kris,

    Apparently you are right, frame synchronisation is not functional in SPI mode.

    I implemented a way to control my chip select without the frame synchronisation.

    After writing into the buffer I wait until the XRDY flag toggle, then I wait an additional time to be sure that the transmission is over before switching my chipselect.

    "write in the buffer"

    while(!McbspRegs->SPCR2.bit.XRDY)

    {

             "chipSelect1 clear;"

    }

    for(waitCounter = 0 ; waitCounter < 24 ; waitCounter++) {}

    "chipSelect1 set;"

    This is not the best way to control the chipselect I guess but it works

    Regards

    Adrien.