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: I am having problems writing over SPI

Part Number: TM4C1294NCPDT

Tool/software: Code Composer Studio

hi,

I need help with my write functions for SSI.

I was able to read but then I couldn't write over my spi.

and i don't know what im doing wrong.

below is my read and write function.

void ft_Wr8(unsigned long ftAddress, unsigned char ftData8)

{

    unsigned char cTempAddr[3];                              // FT800 Memory Address

    cTempAddr[2] = (char) (ftAddress >> 16) | MEM_WRITE; // Compose the command and address to send

    cTempAddr[1] = (char) (ftAddress >> 8);                           // middle byte

    cTempAddr[0] = (char) (ftAddress);                                   // low byte

    GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_CS, 0);            // Set chip select low

    while (SSIDataGetNonBlocking(SSI0_BASE, &pui32DataRx) != 0)

        ;

    SSIDataPut(SSI0_BASE, &cTempAddr[2]); // Send Memory Write plus high address byte

    SSIDataPut(SSI0_BASE, &cTempAddr[1]);

    SSIDataPut(SSI0_BASE, &cTempAddr[0]);

    SSIDataPut(SSI0_BASE, &ftData8);                                // Send data byte

    while (SSIBusy(SSI0_BASE))

        ;

    GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_CS, GPIO_PIN_CS); // Set chip select high

}

unsigned char ft_Rd8(unsigned long ftAddress)

{

    unsigned char ftData8;                 // Place-holder for 8-bits being read

    unsigned char cTempAddr[3];                          // FT800 Memory Address

    unsigned char cZeroFill = ZERO;

    GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_CS, 0);        // Set chip select low

    while (SSIDataGetNonBlocking(SSI0_BASE, &pui32DataRx))

        ;

    cTempAddr[2] = (char) (ftAddress >> 16) | MEM_READ; // Compose the command and address to send

    cTempAddr[1] = (char) (ftAddress >> 8);                       // middle byte

    cTempAddr[0] = (char) (ftAddress);                              // low byte

    SSIDataPut(SSI0_BASE, cTempAddr[2]); // Send Memory Write plus high address byte

    SSIDataPut(SSI0_BASE, cTempAddr[1]);

    SSIDataPut(SSI0_BASE, cTempAddr[0]);

    // SSIAdvDataPutFrameEnd(SSI0_BASE, cZeroFill);                    // Send dummy byte

    SSIAdvDataPutFrameEnd(SSI0_BASE, cZeroFill);              // Send dummy byte

    SSIDataGet(SSI0_BASE, &ftData8);                        // Receive data byte

    while (SSIBusy(SSI0_BASE))

        ;

    GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_CS, GPIO_PIN_CS); // Set chip select high

    return ftData8;                                             // Return 8-bits

  • My friend - you've chosen a (very demanding) external device (TFT Controller) with which to start your (assumed) SPI exploration.

    My group always urges 'KISS' - its 'simplicity, directness & ease' have long proven the 'Fastest & most Enhanced means' to develop 'Real Learning.'    May I suggest that you acquire a (very) simple 'Shift Register IC' - one described as, 'Serial In and Parallel Out' and accommodating your 3V3 (MCU) voltage levels.   (from memory - I believe a '595' suffixed IC should get you 'in the ball-park.')   (prefix will determine the speed & voltage acceptance of such devices - that's a good exercise for (your) learning.)

    Should you have a 'Scope' that IC is not required - most always - a scope (or an alternative means) to 'VIEW the Serial Signals' IS Required!    The IC may connect to 8 Leds - and thus provide (some) insight into the correctness of your 'SPI Writes' - just as you seek.   Note too - that the stringent demands which your FT device places upon you - are (almost) totally eliminated - via this FAR SIMPLER, 'KISS' technique.

    After building both your understanding & confidence - you should have a far better chance to move forward w/your 'much more exotic' SPI Challenge.

    To realize the 'full benefits' of the FT device you (really) need to have SPI nicely 'under your belt.'   (i.e. well understood & mastered)   The method proposed intends to build your capability in a gradual & sequenced manner - which proves best for you - long-term.    Gratification may not be 'immediate' - when 'long-term benefits' -prove your central objective...    (as some here - believe best for you...)

  • Hello Raynard,

    As cb1 said, we really need to see the SPI lines to have a chance to help here. This is very application specific, so without having visualization of what is occurring on the SPI lines, I can't do much to help. I don't have a module like that to test your code with.

    Please try and get hold of an oscilloscope or logic state analyzer to get captures of the communication when the write is not working.

    Also I'm not sure why you needed the SSIAdvDataPutFrameEnd for the read operation but if that is working with it, then you may need to look into whether you need to do something similar on the write?

  • Hello,

    I haven't heard back from you, so I’m assuming you were able to resolve your issue.

    I will close this thread now, but if you have not solved this issue then post a reply below (or open a new thread if the thread has locked due to time-out).