Quantcast
Channel: Forums - Recent Threads
Viewing all articles
Browse latest Browse all 262198

LM4F120: SPI (SSI) - interrupt receiving and transmitting

$
0
0

Hello all,

I'm new in LM4F family

I want to receive data from SPI using interrupt. Suppose there is any slave module that transmit to us packets of data. The size of packets are different e.g. 5-20 bytes long.

It's not a real problem, I'm just interesting how could I create something like this and I want to ask you for some things.

1. System clock:

// Setup the system clock to run at 50 Mhz from PLL with crystal reference       
SysCtlClockSet(SYSCTL_SYSDIV_4|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ| SYSCTL_OSC_MAIN);

2. SPI configuration:

        // SSI0 enable
        SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);

        // GPIOA pins for SSI0 enable
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);

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

        // SPI pins config
        GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_5 | GPIO_PIN_4 | GPIO_PIN_3 |
                       GPIO_PIN_2);

        // SSI0 config
        SSIConfigSetExpClk(SSI0_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_0,
                           SSI_MODE_MASTER, 8000000, 8);

        // SSI0 enable
        SSIEnable(SSI0_BASE);


       while(SSIDataGetNonBlocking(SSI0_BASE, &ulDataRx[0])); // ulDataRx - declared data table

        // SPI_inter_handler function will be an interrupt handler
        IntRegister(INT_SSI0, SPI_inter_handler);

        // SPI interrupt enable
        IntEnable(INT_SSI0);

        // SPI interrupt from receiving data
        SSIIntEnable(SSI0_BASE, SSI_RXFF);

        // Interrupt enable
        IntMasterEnable();

My questions are:

1. If I receive a byte will I have an interrupt? In DS we can read: "Receive FIFO service (when the receive FIFO is half full or more)". Since a Receive FIFO is 8x16 byte memory will the interrupt occur after 8 received bytes?

2. I've received the byte (or a few bytes) of data. How can I access to it?

3. Need I clear any flag in the interrupt?

4. If I configure a SPI interrupt also for data transmitting, how data transmission looks like?


I will grateful for a help.

Best regards,

Mikolaj


edit.:

In regard to 2nd question, I've found in DS description of the SSIDR register where 16-bit data is stored. Additionally there is a SSIDataGet

function in Stellaris Peripheral Driver Library. Should it be used in the interrupt?


Viewing all articles
Browse latest Browse all 262198

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>