Other Parts Discussed in Thread: ADC161S626EVM, STRIKE
Tool/software: Code Composer Studio
I'm using SSI to communicate the EK-TM4C94XL with the ADC161S626EVM booster pack.
Debugging my code, I saw that it was stopping in the part that of the SSIDataGet(...). Stepping into this function the part it was stopping is below:
// Wait until there is data to be read.
//
while(!(HWREG(ui32Base + SSI_O_SR) & SSI_SR_RNE))
{
}
Here's the code:
#include <stdbool.h>
#include <stdint.h>
#include "inc/hw_memmap.h"
#include "driverlib/gpio.h"
#include "driverlib/pin_map.h"
#include "driverlib/ssi.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"
#include "utils/uartstdio.h"
#include "inc/hw_types.h"
uint32_t ui32SysClkFreq;
void
UARTprompt(uint32_t str[])
{
uint8_t i = 0;
while(str[i] != '\0'){
UARTCharPut(UART0_BASE, str[i]);
i++;
}
}
void
InitPORTE(void)
{
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOE))
{
}
GPIOPinTypeGPIOOutput(GPIO_PORTE_BASE, GPIO_PIN_4);
GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_4, 1);
}
void
InitConsole(void)
{
//
// Enable UART0 so that we can configure the clock.
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
//
// Enable GPIO port A which is used for UART0 pins.
// TODO: change this to whichever GPIO port you are using.
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
//
// Configure the pin muxing for UART0 functions on port A0 and A1.
// 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_PA0_U0RX);
GPIOPinConfigure(GPIO_PA1_U0TX);
//
// Select the alternate (UART) function for these pins.
// TODO: change this to select the port/pin you are using.
//
GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
//
// Use the internal 16MHz oscillator as the UART clock source.
//
//UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC);
//
// Initialize the UART for console I/O.
//
UARTConfigSetExpClk(UART0_BASE, ui32SysClkFreq, 115200,
(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));
}
int
main(void)
{
uint32_t pui32DataRx[3];
uint32_t ADCRx[16];
uint8_t i;
//
// 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.
//
ui32SysClkFreq = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
SYSCTL_OSC_MAIN | SYSCTL_USE_PLL |
SYSCTL_CFG_VCO_480), 120000000);
//
// 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();
InitPORTE();
SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI2);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
GPIOPinConfigure(GPIO_PD3_SSI2CLK);
GPIOPinConfigure(GPIO_PD2_SSI2FSS);
GPIOPinConfigure(GPIO_PD0_SSI2XDAT1);
GPIOPinConfigure(GPIO_PD1_SSI2XDAT0);
GPIOPinTypeSSI(GPIO_PORTD_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 |
GPIO_PIN_3);
SSIConfigSetExpClk(SSI2_BASE, ui32SysClkFreq, SSI_FRF_MOTO_MODE_1,
SSI_MODE_MASTER, 1000000, 8);
HWREG(SSI2_BASE + 0x004) = 0x00000001;
SSIEnable(SSI2_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(SSI2_BASE, &pui32DataRx[0]))
{
}
GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_4, 0);
UARTCharPut(UART0_BASE, 'T');
UARTCharPut(UART0_BASE, '\n');
for(i=0 ; i<16 ; i++){
SSIDataGet(SSI2_BASE, &ADCRx[i]);
}
UARTprompt(ADCRx);
return(0);
}