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.

unable to transmit data from tm4c123gh6pm using spi protocol

Other Parts Discussed in Thread: TM4C123GH6PM

Hello,

I have started working on TM4C123GH6PM in SPImode. I have also referred spi_master code provided in example but I am still unable to transmit my data from my controller to slave.Data I want to send consists of 8 bit,16 bit and 32 bit data. SO if anyone can suggest me with proper example and with connection. To make a proper interface.

Thank you,

Mitesh

  • Hi Mitesh,

         Post your code so others can review it.

    -kel

  • Hi,

    This is just the basic code I have written. Using this code I am getting data on UART but unable to transmit.

    #include <stdint.h>
    #include <stdbool.h>
    #include "inc/hw_ints.h"
    #include "inc/hw_memmap.h"
    #include "inc/hw_ssi.h"
    #include "inc/hw_types.h"
    #include "driverlib/debug.h"
    #include "driverlib/fpu.h"
    #include "driverlib/gpio.h"
    #include "driverlib/interrupt.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/rom.h"
    #include "driverlib/ssi.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/timer.h"
    #include "driverlib/uart.h"
    #include "utils/uartstdio.h"

    uint32_t g_ui32Flags;

    #ifdef DEBUG void
    __error__(char *pcFilename, uint32_t ui32Line)
    {
    }
    #endif

    void Timer0IntHandler(void)
    {
    char cOne, cTwo;
    ROM_TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
    HWREGBITW(&g_ui32Flags, 0) ^= 1;
    GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1, g_ui32Flags << 1);
    ROM_IntMasterDisable();
    cOne = HWREGBITW(&g_ui32Flags, 0) ? '1' : '0';
    cTwo = HWREGBITW(&g_ui32Flags, 1) ? '1' : '0';
    UARTprintf("\rT1: %c T2: %c", cOne, cTwo);
    ROM_IntMasterEnable();
    }

    void Timer1IntHandler(void)
    {
    char cOne, cTwo;
    ROM_TimerIntClear(TIMER1_BASE, TIMER_TIMA_TIMEOUT);
    HWREGBITW(&g_ui32Flags, 1) ^= 1;
    GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, g_ui32Flags << 1);
    ROM_IntMasterDisable();
    cOne = HWREGBITW(&g_ui32Flags, 0) ? '1' : '0';
    cTwo = HWREGBITW(&g_ui32Flags, 1) ? '1' : '0';
    UARTprintf("\rT1: %c T2: %c", cOne, cTwo);
    ROM_IntMasterEnable();
    }

    void ConfigureUART(void)
    {
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
    ROM_GPIOPinConfigure(GPIO_PA0_U0RX);
    ROM_GPIOPinConfigure(GPIO_PA1_U0TX);
    ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
    UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC);
    UARTStdioConfig(0, 9600, 16000000);
    }

    int main(void)
    {
    int n;
    n=0x00;

    uint32_t pui32DataTx[0];
    uint32_t pui32DataRx[0];

    SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);

    ConfigureUART();

    UARTprintf("start\n");

    SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);

    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);

    GPIOPinConfigure(GPIO_PA2_SSI0CLK);
    GPIOPinConfigure(GPIO_PA3_SSI0FSS);
    GPIOPinConfigure(GPIO_PA4_SSI0RX);
    GPIOPinConfigure(GPIO_PA5_SSI0TX);

    GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_5 | GPIO_PIN_4 | GPIO_PIN_3 | GPIO_PIN_2);

    SSIConfigSetExpClk(SSI0_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, 1000000, 8);

    // Enable the SSI0 module.
    SSIEnable(SSI0_BASE);

    while(SSIDataGetNonBlocking(SSI0_BASE, &pui32DataRx[0]))
    {
    }
    while(1)
    {
    // Initialize the data to send.
    pui32DataTx[0] = n;
    UARTprintf("data: %d \n", pui32DataTx[0]);
    SSIDataPut(SSI0_BASE, pui32DataTx[0]);
    while(SSIBusy(SSI0_BASE))
    {
    }
    n++;
    }
    }

    Thank You, 

    Mitesh