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.

TMS570LS1224: How to code SPI polling method safely?

Part Number: TMS570LS1224
Other Parts Discussed in Thread: HALCOGEN

Hi, there. Since my master SPI control 2 slaves, what is the proper, good, safety way to control that? I think I cannot always write such things,

    while ((spiREG4->FLG & 0x0200) == 0);
    spiREG4->DAT1 = 0x0080 | 0x10FE0000;        // Send first 8 bit

    while ((spiREG4->FLG & 0x0200) == 0);
    spiREG4->DAT1 = (val & 0xFF) | 0x00FE0000;  // Send 2nd 8 bit

Since I do not want such dead loop. Is there have any safe way for polling method? If no, then we must use interrupt method?

  • Hello Joe,

    To communicate with 2 slave devices, two chip selects (CS) should be used.

    The HALCoGen generated code has functions for transmitting data and receiving data in polling mode:

    uint32 spiTransmitData(spiBASE_t *spi, spiDAT1_t *dataconfig_t, uint32 blocksize, uint16 * srcbuff)

    and

    uint32 spiReceiveData(spiBASE_t *spi, spiDAT1_t *dataconfig_t, uint32 blocksize, uint16 * destbuff)