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.

SSI and TivaWare Issues

Other Parts Discussed in Thread: TM4C1294NCPDT

I can't seem to get *any* output on the MOSI pin utilizing SSI via the TivaWare software package.  I'm using the Tiva C Series Connected Launchpad for a test base. The SSI writeup is pretty straight-forward and I seem to have everything setup correctly.  The the section 20 SSI description does not mention enabling the SSI peripheral, but I do that myself.

Anybody else out there having fun with SSI?

Thanks,

Gary L. Coakley

  • Suspect that you'd have, "bit more fun" by providing (some) needed detail such as:
    MCU
    which board   [edit]  see now that you're using C Series Cntd LPad - I don't know if that escapes the 0-ohm, MCU-MCU connections, later mentioned...
    connections to any/all SSI pins
    your SSI set-up, config and transfer code

    Some boards employ (always helpful) MCU to MCU direct connections. Should that involve your board - and your MOSI pin - solution is quick/easy - should your MCU MOSI output have survived.

    If that MOSI pin is unique and freed from its "dead-short, ill-fated launch" it's often helpful to config it as GPIO Output - and then toggle & observe.

    Hundreds here have succeeded w/SSI - although the process may not (fully) rise to "fun."

  • Thanks for reading the question in the vein it was intended.  I'm sure the SSI works and, indeed, am quite willing to accept "Pilot error" as a valid criticism!

    Using the "blinky.c" program as a starting point, I added to it and here's what I now have:

     

    #define RESET_PERIPH       SYSCTL_PERIPH_GPIOM

    #define DISP_RESET_N       0x01                 // DEBUG 0

    #define DISP_RESET_N_BASE   GPIO_PORTM_BASE

     

    #define A0_PERIPH           SYSCTL_PERIPH_GPIOL

    #define DISP_A0             0x10                 // PL4

    #define DISP_A0_BASE       GPIO_PORTL_BASE

     

    #define SPI_PERIPH         SYSCTL_PERIPH_SSI0

    #define DISP_MOSI           0x10                 // PA4

    #define DISP_CS_N           0x08                 // PA3

    #define DISP_SCLK           0x04                 // PA2

    #define DISP_SPI_BASE       SSI0_BASE

     

     

    //*****************************************************************************

    //

    //! \addtogroup example_list

    //! <h1>Blinky (blinky)</h1>

    //!

    //! A very simple example that blinks the on-board LED using direct register

    //! access.

    //

    //*****************************************************************************

     

    //*****************************************************************************

    //

    // Blink the on-board LED.

    //

    //*****************************************************************************

    int

    main(void)

    {

       volatile uint32_t ui32Loop;

     

       //

       // Enable the GPIO port that is used for the on-board LED.

       //

       SYSCTL_RCGCGPIO_R = SYSCTL_RCGCGPIO_R12;

     

       //

       // Do a dummy read to insert a few cycles after enabling the peripheral.

       //

       ui32Loop = SYSCTL_RCGCGPIO_R;

     

       //

       // Enable the GPIO pin for the LED (PN0). Set the direction as output, and

       // enable the GPIO pin for digital function.

       //

       GPIO_PORTN_DIR_R = 0x01;

       GPIO_PORTN_DEN_R = 0x01;

     

       // set pin directions

     

           // RESET pin

           SysCtlPeripheralEnable(RESET_PERIPH);

           GPIOPinTypeGPIOOutput(DISP_RESET_N_BASE, DISP_RESET_N);

     

           GPIOPinWrite(DISP_RESET_N_BASE, DISP_RESET_N, 0);

       //

             // Delay for a bit.

             //

             for(ui32Loop = 0; ui32Loop < 200000; ui32Loop++)

             {

             }

     

       GPIOPinWrite(DISP_RESET_N_BASE, DISP_RESET_N, DISP_RESET_N);

     

        //     SPI pins

           SysCtlPeripheralEnable(SPI_PERIPH);

     

           // A0 pin

           SysCtlPeripheralEnable(A0_PERIPH);

           GPIOPinTypeGPIOOutput(DISP_A0_BASE, DISP_A0);

     

           // toggle RST low to reset; CS low so it'll listen to us

           //GPIOPinWrite(DISP_SPI_BASE, DISP_CS_N, 0);

     

           //     Now Let's initialize the SSI interface

     

           SSIClockSourceSet(DISP_SPI_BASE, SSI_CLOCK_SYSTEM);

           SSIConfigSetExpClk( DISP_SPI_BASE,               // Port base address

                              120000000,           // get the system clock rate

                               SSI_FRF_MOTO_MODE_0,         // setup proper mode

                               SSI_MODE_MASTER,             // we are the master

                               2000000,                     // 2 MHz to start with

                               8                            // 8 databits

                              );

           SSIEnable ( DISP_SPI_BASE );                     // enable the SSI controller

     

           while(1)

           {

                  //     set A0 low

                  GPIOPinWrite(DISP_A0_BASE, DISP_A0, 0);

                  //     set A0 high

                  GPIOPinWrite(DISP_A0_BASE, DISP_A0, DISP_A0);

                  SSIDataPut( DISP_SPI_BASE, 0x55);

           }

    }

    As further information, I'm simply toggling the A0 line for a sanity check on the scope to make sure I'm seeing something.  Additionally, I do *not* have anything connected to MOSI, just a wire inserted into the header pin location.  I'm just trying to get anything on the pin at this point.  So, only two wires/antennas plugged into two of the Launchpad headers - one in PL4 ( my A0 line ) and one in PA4 ( MOSI ).  And I am seeing the PL4 pulse.

    Also, I am going to experiment with toggling the MOSI line as a GPIO.  Thanks for that hint.

    More fun, please!

    Gary

  • My (fun) friend - thanks for your (reciprocated) "read in the correct/open vein..."   (not all here, "get it.")

    Now - from time to time - my (dreaded) "for pay" job intrudes into time/effort I can spend here/elsewhere.   (Damn judge forced upon me as "community service" - I'd advise against tres fast, red, sports car)

    Know that you're not alone - ARM MCUs "thrill" w/their capability - "bring tears" w/their complexity.  (welcome to the club)

    My earlier point - might the pin you've chosen as MOSI be "direct connected" to another MCU pin on your board?   (as unlikely as that seems - that was (deliberately) done on many launch (use the word very loosely) pad (i.e. Econo boards).

    We note you've mixed direct register & vendor's API - direct register IS fun - but a plague for hapless helpers - who haven't time/energy to grab for the Register manual - and delve therein.  Stick w/APIs - there are many code examples for SSI - search/find - and if still frustrated - I'll try & return.   (when client's screams enable hearing to return...)

    Just in case - can you migrate to another SSI Port - try there.  And indeed - switch to GPIO Output - insure that the pin has "some chance" to toggle...

  • Lots of info to share - lots of fun had by all!

    First, using simple GPIO I was able to verify the operation of SSI0 pins and SSI3 pins, on the Launchpad Tiva board and on our product board.  That was a GOOD thing.

    Second, I found some code here on TI that *almost* got me there.  It DID change the behavior enough to give me some hope, finally!

    What happens now is that eight bytes are placed into the FIFO, nothing is removed and the program hangs waiting to insert byte #9.  Before everything just kept running like nothing was happening - maybe nothing was, since I didn't see any bits toggling.  So - something changed.

    One big thing that I think had the major impact was that - previously - I was NOT enabling GPIOA bits, I was simply using the SSI enable, which evidently is not sufficient.  I think that addition is what got me to just about working.

    I am including the code, but there are a lot of #defines since I was trying a lot of tests.

    #define RESET_PERIPH       SYSCTL_PERIPH_GPIOM

    #define    DISP_RESET_N         0x01                 // DEBUG 0

    #define DISP_RESET_N_BASE   GPIO_PORTM_BASE

     

    #define A0_PERIPH           SYSCTL_PERIPH_GPIOL

    #define DISP_A0             0x10                 // PL4

    #define DISP_A0_BASE       GPIO_PORTL_BASE

     

    #define    USE_SSI

    //#define  USE_GPIO_SSI

     

    #define    USE_SSI0

    //#define  USE_SSI3

     

     

    #ifdef          USE_SSI

    #ifdef   USE_SSI0

       #define SPI_PERIPH         SYSCTL_PERIPH_SSI0

       #define DISP_SPI_BASE       SSI0_BASE

    #endif

     

    #ifdef   USE_SSI3

       #define SPI_PERIPH         SYSCTL_PERIPH_SSI3

       #define DISP_SPI_BASE       SSI3_BASE

    #endif

    #endif

     

    #ifdef          USE_GPIO_SSI

    #ifdef   USE_SSI0

       #define     SPI_PERIPH           SYSCTL_PERIPH_GPIOA

       #define     DISP_SPI_BASE        GPIO_PORTA_BASE

    #endif

     

    #ifdef   USE_SSI3

       #define     SPI_PERIPH           SYSCTL_PERIPH_GPIOQ

       #define     DISP_SPI_BASE        GPIO_PORTQ_BASE

    #endif

    #endif

     

    #ifdef     USE_SSI0

    //              SSI 0 pins

    #define DISP_MISO           0x20                 // PA5

    #define DISP_MOSI           0x10                 // PA4

    #define DISP_CS_N           0x08                 // PA3

    #define DISP_SCLK           0x04                 // PA2

    #endif

     

    #ifdef     USE_SSI3

    //              SSI 2 pins

    #define DISP_MISO           0x08                 // PQ3

    #define DISP_MOSI           0x04                 // PQ2

    #define DISP_CS_N           0x02                 // PQ1

    #define DISP_SCLK           0x01                 // PQ0

    #endif

     

     

     

     

     

     

     

     

     

     

     

     

     

     

       // set pin directions

     

         // RESET pin

           SysCtlPeripheralEnable(RESET_PERIPH);

           GPIOPinTypeGPIOOutput(DISP_RESET_N_BASE, DISP_RESET_N);

     

         GPIOPinWrite(DISP_RESET_N_BASE, DISP_RESET_N, 0);

       //

             // Delay for a bit.

             //

             for(ui32Loop = 0; ui32Loop < 200000; ui32Loop++)

             {

             }

     

       GPIOPinWrite(DISP_RESET_N_BASE, DISP_RESET_N, DISP_RESET_N);

     

       //     from example code

       SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);

     

         //   SPI pins

           SysCtlPeripheralEnable(SPI_PERIPH);

     

     

     

     

         // A0 pin

           SysCtlPeripheralEnable(A0_PERIPH);

     

           GPIOPinTypeGPIOOutput(DISP_A0_BASE, DISP_A0);

     

           // toggle RST low to reset; CS low so it'll listen to us

     

     

    #ifdef          USE_GPIO_SSI

       GPIOPinTypeGPIOOutput(DISP_SPI_BASE, DISP_MISO);

       GPIOPinTypeGPIOOutput(DISP_SPI_BASE, DISP_MOSI);

       GPIOPinTypeGPIOOutput(DISP_SPI_BASE, DISP_SCLK);

       GPIOPinTypeGPIOOutput(DISP_SPI_BASE, DISP_CS_N);

    #endif

     

    #ifdef          USE_SSI

    //   GPIOPinTypeSSI(DISP_SPI_BASE, DISP_MISO);

    //   GPIOPinTypeSSI(DISP_SPI_BASE, DISP_MOSI);

    //   GPIOPinTypeSSI(DISP_SPI_BASE, DISP_SCLK);

    //   GPIOPinTypeSSI(DISP_SPI_BASE, DISP_CS_N);

     

         //   from example code

         GPIOPinTypeSSI(GPIO_PORTA_BASE, DISP_MISO | DISP_MOSI | DISP_SCLK | DISP_CS_N );

         //   from example code

         //GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, DISP_CS_N);

     

     

       //     Now Let's initialize the SSI interface

         SSIClockSourceSet(DISP_SPI_BASE, SSI_CLOCK_SYSTEM);

     

         SSIConfigSetExpClk( DISP_SPI_BASE,               // Port base address

                            120000000,           // get the system clock rate

                                    SSI_FRF_MOTO_MODE_0,         // setup proper mode

                                    SSI_MODE_MASTER,             // we are the master

                                    100000,                     // 100KHz to start with

                                    8                           // 8 databits

                            );

         SSIEnable ( DISP_SPI_BASE );                     // enable the SSI controller

    #endif

     

     

         while(1)

         {

              int        i;

               int        ch;

     

               //   set A0 low

               GPIOPinWrite(DISP_A0_BASE, DISP_A0, 0);

               //   set A0 high

               GPIOPinWrite(DISP_A0_BASE, DISP_A0, DISP_A0);

               ch = 0x55;

     

    #ifdef          USE_SSI

               SSIDataPut( DISP_SPI_BASE, ch);

              GPIOPinWrite(DISP_SPI_BASE, DISP_CS_N, 0);

              GPIOPinWrite(DISP_SPI_BASE, DISP_CS_N, DISP_CS_N);

    #endif

     

    #ifdef          USE_GPIO_SSI

              GPIOPinWrite(DISP_SPI_BASE, DISP_CS_N, 0);

               for ( i = 0; i <= 7; i++ )

               {

                    int  bit = ((ch>>(7-i))&1);

                    GPIOPinWrite(DISP_SPI_BASE, DISP_MOSI, bit?DISP_MOSI:0);

                   GPIOPinWrite(DISP_SPI_BASE, DISP_SCLK, DISP_SCLK);

                   GPIOPinWrite(DISP_SPI_BASE, DISP_SCLK, 0);

               }

              GPIOPinWrite(DISP_SPI_BASE, DISP_CS_N, DISP_CS_N);

    #endif

     

      }

     

    #define RESET_PERIPH       SYSCTL_PERIPH_GPIOM

    #define    DISP_RESET_N         0x01                 // DEBUG 0

    #define DISP_RESET_N_BASE   GPIO_PORTM_BASE

     

    #define A0_PERIPH           SYSCTL_PERIPH_GPIOL

    #define DISP_A0             0x10                 // PL4

    #define DISP_A0_BASE       GPIO_PORTL_BASE

     

    #define    USE_SSI

    //#define  USE_GPIO_SSI

     

    #define    USE_SSI0

    //#define  USE_SSI3

     

     

    #ifdef          USE_SSI

    #ifdef   USE_SSI0

       #define SPI_PERIPH         SYSCTL_PERIPH_SSI0

       #define DISP_SPI_BASE       SSI0_BASE

    #endif

     

    #ifdef   USE_SSI3

       #define SPI_PERIPH         SYSCTL_PERIPH_SSI3

       #define DISP_SPI_BASE       SSI3_BASE

    #endif

    #endif

     

    #ifdef          USE_GPIO_SSI

    #ifdef   USE_SSI0

       #define     SPI_PERIPH           SYSCTL_PERIPH_GPIOA

       #define     DISP_SPI_BASE        GPIO_PORTA_BASE

    #endif

     

    #ifdef   USE_SSI3

       #define     SPI_PERIPH           SYSCTL_PERIPH_GPIOQ

       #define     DISP_SPI_BASE        GPIO_PORTQ_BASE

    #endif

    #endif

     

    #ifdef     USE_SSI0

    //              SSI 0 pins

    #define DISP_MISO           0x20                 // PA5

    #define DISP_MOSI           0x10                 // PA4

    #define DISP_CS_N           0x08                 // PA3

    #define DISP_SCLK           0x04                 // PA2

    #endif

     

    #ifdef     USE_SSI3

    //              SSI 2 pins

    #define DISP_MISO           0x08                 // PQ3

    #define DISP_MOSI           0x04                 // PQ2

    #define DISP_CS_N           0x02                 // PQ1

    #define DISP_SCLK           0x01                 // PQ0

    #endif

     

       // set pin directions

     

         // RESET pin

           SysCtlPeripheralEnable(RESET_PERIPH);

           GPIOPinTypeGPIOOutput(DISP_RESET_N_BASE, DISP_RESET_N);

     

         GPIOPinWrite(DISP_RESET_N_BASE, DISP_RESET_N, 0);

       //

             // Delay for a bit.

             //

             for(ui32Loop = 0; ui32Loop < 200000; ui32Loop++)

             {

             }

     

       GPIOPinWrite(DISP_RESET_N_BASE, DISP_RESET_N, DISP_RESET_N);

     

       //     from example code

       SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);

     

         //   SPI pins

           SysCtlPeripheralEnable(SPI_PERIPH);

     

     

     

     

         // A0 pin

           SysCtlPeripheralEnable(A0_PERIPH);

     

           GPIOPinTypeGPIOOutput(DISP_A0_BASE, DISP_A0);

     

           // toggle RST low to reset; CS low so it'll listen to us

     

     

    #ifdef          USE_GPIO_SSI

       GPIOPinTypeGPIOOutput(DISP_SPI_BASE, DISP_MISO);

       GPIOPinTypeGPIOOutput(DISP_SPI_BASE, DISP_MOSI);

       GPIOPinTypeGPIOOutput(DISP_SPI_BASE, DISP_SCLK);

       GPIOPinTypeGPIOOutput(DISP_SPI_BASE, DISP_CS_N);

    #endif

     

    #ifdef          USE_SSI

    //   GPIOPinTypeSSI(DISP_SPI_BASE, DISP_MISO);

    //   GPIOPinTypeSSI(DISP_SPI_BASE, DISP_MOSI);

    //   GPIOPinTypeSSI(DISP_SPI_BASE, DISP_SCLK);

    //   GPIOPinTypeSSI(DISP_SPI_BASE, DISP_CS_N);

     

         //   from example code

         GPIOPinTypeSSI(GPIO_PORTA_BASE, DISP_MISO | DISP_MOSI | DISP_SCLK | DISP_CS_N );

         //   from example code

         //GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, DISP_CS_N);

     

     

       //     Now Let's initialize the SSI interface

         SSIClockSourceSet(DISP_SPI_BASE, SSI_CLOCK_SYSTEM);

     

         SSIConfigSetExpClk( DISP_SPI_BASE,               // Port base address

                            120000000,           // get the system clock rate

                             SSI_FRF_MOTO_MODE_0,         // setup proper mode

                             SSI_MODE_MASTER,             // we are the master

                             100000,                     // 100KHz to start with

                             8                           // 8 databits

                            );

         SSIEnable ( DISP_SPI_BASE );                     // enable the SSI controller

    #endif

     

     

         while(1)

         {

              int        i;

               int        ch;

     

               //   set A0 low

               GPIOPinWrite(DISP_A0_BASE, DISP_A0, 0);

               //   set A0 high

               GPIOPinWrite(DISP_A0_BASE, DISP_A0, DISP_A0);

               ch = 0x55;

     

    #ifdef          USE_SSI

               SSIDataPut( DISP_SPI_BASE, ch);

              GPIOPinWrite(DISP_SPI_BASE, DISP_CS_N, 0);

              GPIOPinWrite(DISP_SPI_BASE, DISP_CS_N, DISP_CS_N);

    #endif

     

    #ifdef          USE_GPIO_SSI

              GPIOPinWrite(DISP_SPI_BASE, DISP_CS_N, 0);

               for ( i = 0; i <= 7; i++ )

               {

                    int  bit = ((ch>>(7-i))&1);

                    GPIOPinWrite(DISP_SPI_BASE, DISP_MOSI, bit?DISP_MOSI:0);

                   GPIOPinWrite(DISP_SPI_BASE, DISP_SCLK, DISP_SCLK);

                   GPIOPinWrite(DISP_SPI_BASE, DISP_SCLK, 0);

               }

              GPIOPinWrite(DISP_SPI_BASE, DISP_CS_N, DISP_CS_N);

    #endif

     

      }

     

    As usual, thanks and have fun, always!

    Gary

    PS - I have a 1966 Mercury Parklane convertible that takes my spare time and money.  It was my dad's, so I kinda have to keep it!  But, big as  a boat and doesn't lend itself to racing around.  Cars ARE fun!

  • @fun Gary,

    Read the first hundred or so "defines" - then eyes crossed/watered (bit more than normal) gave up.

    Would you believe that - should you switch to vendor supplied APIs - most all (and far, far fewer) of those pesky defines are created/managed for you?   (they are)

    In fact - those defines - force spectacular extra effort upon any here - seeking to assist.  (bad idea)

    Numerous well tested/illustrated SSI examples exist - suggest that you devote more (i.e. some) time to search and discover.

    And my bad to not mention that you MUST enable both the port (pins) and the peripheral.   I recall your earlier code spanned several ports - in it's attempt to utilize SSI.   All such ports must be enabled - in addition to your targeted peripheral.

    I don't want to deprive you of the pleasure derived from "investigating" - yet "spi_master.c" is a treasure trove of code-example gold.   Find it under: xxxWare\examples\peripherals\ssi\

    Ticket-launching (real launch) here escaped Modena factory, fire-red, vintage 1977 "prancer" 308GTB.   (bears our 1st all digital (plasma bar-graphs) dash...)  Not too bad for a 1981 design - got me on L.A. TV...

  • WHEW!!!!!!!!!

    First, I *was* unaware of all of the example code that was on my drive via the install!  I had been searching the TI website for the SSI examples that were on my machine.  OK, got by that and got the spi_master.c stripped down and running as a brief test function in the "blinky" program - just to keep things simple.

    My best guess is that I'm screwing up the clock initialization, somehow; especially since I get back the value zero ( 0 ) from the SysCtlClockGet() function!

    I see the three pulses that mean I tried to put the three values into the FIFO, but nothing moved on the MOSI pin.

    Now remember, I only have wires poked into the headers with nothing on the other side - I'm assuming that since the CVS is supposedly selecting the correct device, the FIFO should just spit the values out, no "ready" checking.

    Here's the simplified test code:

     

    #include <stdint.h>

    // Standard library includes

     

    #include <stdbool.h>

    #include "inc/tm4c1294ncpdt.h"

     

    // Project includes

    //#include "support_DEV_01522_01_MAINBOARD_MK01.h"

    #include "driverlib/debug.h"

     

    #include "inc/hw_memmap.h"

    #include "driverlib/gpio.h"

    #include "driverlib/sysctl.h"

    #include "driverlib/ssi.h"

     

     

    #define A0_PERIPH           SYSCTL_PERIPH_GPIOL

    #define DISP_A0             0x10                 // PL4

    #define DISP_A0_BASE       GPIO_PORTL_BASE

     

    //              SSI 0 pins

    //#define DISP_MISO           0x20                 // PA5

    //#define DISP_MOSI           0x10                 // PA4

    #define DISP_MOSI           0x20                 // PA4

    #define DISP_CS_N           0x08                 // PA3

    #define DISP_SCLK           0x04                 // PA2

     

     

     

    #define GPIO_PA2_SSI0CLK             DISP_SCLK

    #define GPIO_PA3_SSI0FSS             DISP_CS_N

    //   #define GPIO_PA4_SSI0RX               DISP_MISO

    #define GPIO_PA5_SSI0TX               DISP_MOSI

     

    int SSITest(void);

     

     

    //*****************************************************************************

    //

    //! \addtogroup example_list

    //! <h1>Blinky (blinky)</h1>

    //!

    //! A very simple example that blinks the on-board LED using direct register

    //! access.

    //

    //*****************************************************************************

     

    //*****************************************************************************

    //

    // Blink the on-board LED.

    //

    //*****************************************************************************

    int

    main(void)

    {

       volatile uint32_t ui32Loop;

     

       //

       // Enable the GPIO port that is used for the on-board LED.

       //

       SYSCTL_RCGCGPIO_R = SYSCTL_RCGCGPIO_R12;

     

       //

       // Do a dummy read to insert a few cycles after enabling the peripheral.

       //

       ui32Loop = SYSCTL_RCGCGPIO_R;

     

       //

       // Enable the GPIO pin for the LED (PN0). Set the direction as output, and

       // enable the GPIO pin for digital function.

       //

       GPIO_PORTN_DIR_R = 0x01;

       GPIO_PORTN_DEN_R = 0x01;

     

         // A0 pin

           SysCtlPeripheralEnable(A0_PERIPH);

           GPIOPinTypeGPIOOutput(DISP_A0_BASE, DISP_A0);

     

            SSITest();

       //

       // Loop forever.

       //

       while(1)

       {

           //

           // Turn on the LED.

           //

           GPIO_PORTN_DATA_R |= 0x01;

     

           //

           // Delay for a bit.

           //

           for(ui32Loop = 0; ui32Loop < 200000; ui32Loop++)

           {

           }

     

           //

           // Turn off the LED.

           //

         GPIO_PORTN_DATA_R &= ~(0x01);

     

           //

           // Delay for a bit.

           //

           for(ui32Loop = 0; ui32Loop < 200000; ui32Loop++)

           {

           }

       }

     

    }

     

     

    //*****************************************************************************

    //

    //! \addtogroup ssi_examples_list

    //! <h1>SPI Master (spi_master)</h1>

    //!

    //! This example shows how to configure the SSI0 as SPI Master. The code will

    //! send three characters on the master Tx then polls the receive FIFO until

    //! 3 characters are received on the master Rx.

    //!

    //! This example uses the following peripherals and I/O signals. You must

    //! review these and change as needed for your own board:

    //! - SSI0 peripheral

    //! - GPIO Port A peripheral (for SSI0 pins)

    //! - SSI0Clk - PA2

    //! - SSI0Fss - PA3

    //! - SSI0Rx - PA4

    //! - SSI0Tx - PA5

    //!

    //! The following UART signals are configured only for displaying console

    //! messages for this example. These are not required for operation of SSI0.

    //! - UART0 peripheral

    //! - GPIO Port A peripheral (for UART0 pins)

    //! - UART0RX - PA0

    //! - UART0TX - PA1

    //!

    //! This example uses the following interrupt handlers. To use this example

    //! in your own application you must add these interrupt handlers to your

    //! vector table.

    //! - None.

    //

    //*****************************************************************************

     

    //*****************************************************************************

    //

    // Number of bytes to send and receive.

    //

    //*****************************************************************************

    #define NUM_SSI_DATA           3

     

    //*****************************************************************************

    //

    // This function sets up UART0 to be used for a console to display information

    // as the example is running.

    //

    //*****************************************************************************

     

    volatile uint32_t clockrateGLC;

     

    //*****************************************************************************

    //

    // Configure SSI0 in master Freescale (SPI) mode. This example will send out

    // 3 bytes of data, then wait for 3 bytes of data to come in. This will all be

    // done using the polling method.

    //

    //*****************************************************************************

    int SSITest(void)

    {

       uint32_t pui32DataTx[NUM_SSI_DATA];

       uint32_t pui32DataRx[NUM_SSI_DATA];

       uint32_t ui32Index;

     

       //

       // Set the clocking to run directly from the external crystal/oscillator.

       // TODO: The SYSCTL_XTAL_ value must be changed to match the value of the

       // crystal on your board.

       //

     

       //SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |

       //               SYSCTL_XTAL_25MHZ);

        

       SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_OSC_MAIN |SYSCTL_USE_PLL | SYSCTL_XTAL_25MHZ );

     

       clockrateGLC = SysCtlClockGet();

     

     

       //

       // Set up the serial console to use for displaying messages. This is

       // just for this example program and is not needed for SSI operation.

       //

       //////////////////////////////////////////////////////////////////////////////////////////////////////////////////InitConsole();

     

       //

       // Display the setup on the console.

       //

       //////////////////////////////////////////////////////////////////////////////////////////////////////////////////UARTprintf("SSI ->\n");

       //////////////////////////////////////////////////////////////////////////////////////////////////////////////////UARTprintf(" Mode: SPI\n");

       //////////////////////////////////////////////////////////////////////////////////////////////////////////////////UARTprintf(" Data: 8-bit\n\n");

     

       //

       // The SSI0 peripheral must be enabled for use.

       //

       SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);

     

       //

       // For this example SSI0 is used with PortA[5:2]. The actual port and pins

       // used may be different on your part, consult the data sheet for more

       // information. GPIO port A needs to be enabled so these pins can be used.

       // TODO: change this to whichever GPIO port you are using.

       //

       SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);

     

       //

       // Configure the pin muxing for SSI0 functions on port A2, A3, A4, and A5.

       // This step is not necessary if your part does not support pin muxing.

       // TODO: change this to select the port/pin you are using.

       //

       GPIOPinConfigure(GPIO_PA2_SSI0CLK);

       GPIOPinConfigure(GPIO_PA3_SSI0FSS);

       //GPIOPinConfigure(GPIO_PA4_SSI0TX);

       GPIOPinConfigure(GPIO_PA5_SSI0TX);

     

     //

       // Configure the GPIO settings for the SSI pins. This function also gives

       // control of these pins to the SSI hardware. Consult the data sheet to

       // see which functions are allocated per pin.

       // The pins are assigned as follows:

       //     PA5 - SSI0Tx

       //     PA4 - SSI0Rx

       //     PA3 - SSI0Fss

       //     PA2 - SSI0CLK

       // TODO: change this to select the port/pin you are using.

       //

       GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_5 | GPIO_PIN_4 | GPIO_PIN_3 |

                      GPIO_PIN_2);

     

       //

       // Configure and enable the SSI port for SPI master mode. Use SSI0,

       // system clock supply, idle clock level low and active low clock in

       // freescale SPI mode, master mode, 1MHz SSI frequency, and 8-bit data.

       // For SPI mode, you can set the polarity of the SSI clock when the SSI

       // unit is idle. You can also configure what clock edge you want to

       // capture data on. Please reference the datasheet for more information on

       // the different SPI modes.

       //

       SSIConfigSetExpClk(SSI0_BASE, 120000000, SSI_FRF_MOTO_MODE_0,

                           SSI_MODE_MASTER, 1000000, 8);

     

       //

       // Enable the SSI0 module.

       //

       SSIEnable(SSI0_BASE);

     

       //

       // Read any residual data from the SSI port. This makes sure the receive

       // FIFOs are empty, so we don't read any unwanted junk. This is done here

       // because the SPI SSI mode is full-duplex, which allows you to send and

       // receive at the same time. The SSIDataGetNonBlocking function returns

       // "true" when data was returned, and "false" when no data was returned.

       // The "non-blocking" function checks if there is any data in the receive

       // FIFO and does not "hang" if there isn't.

       //

       while(SSIDataGetNonBlocking(SSI0_BASE, &pui32DataRx[0]))

       {

       }

     

       //

       // Initialize the data to send.

       //

       pui32DataTx[0] = 's';

       pui32DataTx[1] = 'p';

       pui32DataTx[2] = 'i';

     

       //

       // Display indication that the SSI is transmitting data.

       //

       //////////////////////////////////////////////////////////////////////////////////////////////////////////////////UARTprintf("Sent:\n ");

     

       //

       // Send 3 bytes of data.

       //

       for(ui32Index = 0; ui32Index < NUM_SSI_DATA; ui32Index++)

       {

           //

           // Display the data that SSI is transferring.

           //

           //////////////////////////////////////////////////////////////////////////////////////////////////////////////////UARTprintf("'%c' ", pui32DataTx[ui32Index]);

     

           //

           // Send the data using the "blocking" put function. This function

         // will wait until there is room in the send FIFO before returning.

           // This allows you to assure that all the data you send makes it into

           // the send FIFO.

           //

               //   set A0 low

               GPIOPinWrite(DISP_A0_BASE, DISP_A0, 0);

               //   set A0 high

               GPIOPinWrite(DISP_A0_BASE, DISP_A0, DISP_A0);

           SSIDataPut(SSI0_BASE, pui32DataTx[ui32Index]);

       }

     

       //

       // Wait until SSI0 is done transferring all the data in the transmit FIFO.

       //

       while(SSIBusy(SSI0_BASE))

       {

       }

     

       //

       // Return no errors

       //

       return(0);

    }

     

     

    The fun never stops!  And, again, thanks for your patience and help.

    Gary

  • Gary Coakley said:
    First, I *was* unaware of all of the example code that was on my drive via the install! 

    Who isn't?   Despite my/others "implore" of hallowed vendor to "better stress the basics" - much time devoted (instead) to, "Non MCU - extraneous issues!"  (i.e. "I wanna talk to xyz chip - it Doesn't Work!  It's (of course) Urgent!!!")   Oh well...

    Now while (appearing) simple - blinky code does not fully/properly enable all the hooks/catches w/in vendor's APIs and IDE.

    Code you show is beyond the example I offered - and may be held hostage by the limitations w/in blinky.c.

    KISS demands that you (always) FIRST start w/"known good" - get that test/verified - and only then, "roll your own."

    Wish you well - my job done here...

  • Hello Gary,

    The SysCtlClockSet and SysCtlClockGet are TM4C123 functions. These two have been replaced by SysCtlClockFreqSet for the TM4C129 Connected LaunchPad.

    Regards
    Amit