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.

CCS/TM4C1294NCPDT: AMC7820, SPI

Part Number: TM4C1294NCPDT
Other Parts Discussed in Thread: AMC7820

Tool/software: Code Composer Studio

Hi,

We are trying to to interface AMC 7820 with TM4C1294XL (EVK) through SSI (SPI). While reading the register values from AMC we are getting random values. Are there any example codes available for SPI on TM4C1294XL, espacially with AMC 7820 ?

Regards,

Shyam

  • Have you:

    • chosen then coded your MCU's SPI format to match that of your Slave SPI device?         (SPI dictates that the "Slave is the "boss" - MCU must comply w/Slave's format.     While "unexpected" such Slaves (almost always) are without the "formatting flexibility" enjoyed by the MCU.)
    • monitored the MCU's output SPI (clock & data) signals?
    • reviewed those signals - to insure that they comply w/your intent?

    The above is the standard method of SPI system, signal analysis/trouble-shooting.

    The separation between (the assumed) MCU board & board holding your SPI Slave must be limited - best always to "start" with a LOW Data Rate.

    Your Slave board's ground must "tie" to your EVK's ground  - and the Slave board must be adequately powered.

    "KISS" would direct you to "Start your SPI effort" with a small, low capacity EEProm!       (rather than the much more complex IC - so much easier to boost your confidence & understanding.)

  • I don't have an example of interfacing to the AMC7820, but looking at the datasheet I think you need to use Freescale SPI Frame Format with SPO=0 and SPH=1. Each read or write requires two 16-bit transfers with the slave select staying low between the transfers. This can be done by using the FIFO to do two transfers in continuous mode, or by configuring the slave select as a GPIO and using software to set the signal high at the end of the second 16-bit transfer. Remember that for every bit written a bit is also read. At the end of a write command the software should clear the receive FIFO of the two 16-bit values that were captured. In the case of a read operation, you must still do two 16-bit writes. The first is the command and the second is just dummy data (don't care). Then discard the first 16-bit value in the receive buffer. The value read will be the second 16-bit value in the receive buffer.
  • Hi, thanks for the reply. We have been following the same procedure you mentioned. But still am not able to get it to work. I am attaching the major portions of the code herewith. Could you please have a look??

    #define NUM_SSI_DATA 4
    uint32_t amctx[NUM_SSI_DATA];
    uint32_t amcrx[NUM_SSI_DATA];
    uint32_t index;
    uint32_t ui32SysClock;

    ui32SysClock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000);

    PinoutSet(false, false);

    SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI3);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOK);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);

    GPIOPinConfigure(GPIO_PD3_SSI3CLK); // SCLK
    GPIOPinTypeGPIOOutput(GPIO_PORTK_BASE, GPIO_PIN_3); // ~CS - configure it as GPIO output
    GPIOPinWrite(GPIO_PORTK_BASE, GPIO_PIN_3, GPIO_PIN_3); // ~CS - set it to logic HIGH
    GPIOPinConfigure(GPIO_PD1_SSI3XDAT0); // MOSI
    GPIOPinConfigure(GPIO_PD0_SSI3XDAT1); // MISO

    GPIOPinTypeSSI(GPIO_PORTD_BASE, GPIO_PIN_3 | GPIO_PIN_1 | GPIO_PIN_0);

    SSIConfigSetExpClk(SSI2_BASE,ui32SysClock, SSI_FRF_MOTO_MODE_1, SSI_MODE_MASTER, 35000000, 16);

    SSIEnable(SSI2_BASE);

    while(SSIDataGetNonBlocking(SSI2_BASE, &amcrx[0]))
    {
    }

    amcrx[0] = 0x02C0;
    amcrx[1] = 0x0002;
    amcrx[2] = 0x82C0;
    amcrx[3] = 0x0000;

    GPIOPinWrite(GPIO_PORTK_BASE, GPIO_PIN_3, 0); // ~CS - set it to logic LOW - start of transmission
    SysCtlDelay(10);

    SSIDataPut(SSI2_BASE, amctx[0]);
    SSIDataGet(SSI2_BASE, &amcrx[0]);
    SSIDataPut(SSI2_BASE, amctx[1]);
    SSIDataGet(SSI2_BASE, &amcrx[1);

    SSIDataPut(SSI2_BASE, amctx[2]);
    SSIDataGet(SSI2_BASE, &amcrx[2]);
    SSIDataPut(SSI2_BASE, amctx[3]);
    SSIDataGet(SSI2_BASE, &amcrx[3]); //WHEN I TRY TO READ AMCRX[3] it gives random values. When actually it should
    contain the read data

    while(SSIBusy(SSI2_BASE))
    {
    }

    SysCtlDelay(10);
    GPIOPinWrite(GPIO_PORTK_BASE, GPIO_PIN_3, GPIO_PIN_3); // ~CS - set it to logic HIGH - end of transmission



    Regards,
    Shyam
  • Have you compared the output waveforms you are generating to those expected from the data sheet?

    Robert
  • Such was suggested (along w/further detail) w/in 15 minutes of post's arrival - and yielded "silence."
  • In the code you provided above I see you initialized the amcrx array. Did you mean for that to be the amctx array instead?

     amcrx[0] = 0x02C0;
     amcrx[1] = 0x0002;
     amcrx[2] = 0x82C0;
     amcrx[3] = 0x0000;
    

  • Yes, it was meant to be amctx array. It was a mistake while posting.

  • Thank you for the reply. But,we have not been able to check the output waveforms yet.

    Regards,
    Shyam

  • Thank you - do note that without your active monitoring of key signals - the successful debug of SPI is rendered far more complex - will take longer - and "eat" time/effort. Your presentation of (well labeled) scope Screen Caps - will aid both you and helper crüe - in resolving your issue.

    Note: should this be your "initial attempt" @ SPI - use of so complex a chip - rather than a vastly simpler (small capacity, EEProm) - is a grave violation of "KISS" and is almost certain to, "over-challenge!"
  • Thank you all for the help. But apparently, the issue was with a level shifter that we were using. It was not working properly. Thanks again everyone for the responses.