Part Number: TM4C1294NCPDT
Hi all,
I am currently working on TM4C1294NCPDT evaluation board microcontroller.
I am trying to configure SSI bus to 3-Wire SPI bus with bitrate 16-bits per frame and external peripheral device is AD9834 waveform generator.
As I was debugging through SPI bus using logic analyzer. The output result are different than the data provided by me in a Code.
If someone can help me with troubleshoot please let me know.
#include <stdbool.h>
#include <stdint.h>
#include <inc/hw_types.h>
#include <inc/hw_ssi.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 <string.h>
#include "main.h"
// Number of bytes to Send.
//
//*****************************************************************************
#define NUM_SSI_DATA 4
#ifdef DEBUG
void
__error__(char *pcFilename, uint32_t ui32Line)
{
}
#endif
uint32_t ui32SysClocks;
//*****************************************************************************
//
// This function sets up UART0 to be used for a console to display information
// as the example is running.
//
//*****************************************************************************
void InitConsole(void){
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
GPIOPinConfigure(GPIO_PA0_U0RX);
GPIOPinConfigure(GPIO_PA1_U0TX);
GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
UARTStdioConfig(0, 9600, ui32SysClocks);
}
void InitSPI(void){
SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
GPIOPinConfigure(GPIO_PA2_SSI0CLK);
GPIOPinConfigure(GPIO_PA3_SSI0FSS);
GPIOPinConfigure(GPIO_PA4_SSI0XDAT0);
GPIOPinConfigure(GPIO_PA5_SSI0XDAT1);
GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_5 | GPIO_PIN_4 | GPIO_PIN_3 | GPIO_PIN_2);
SSIConfigSetExpClk(SSI0_BASE, ui32SysClocks, SSI_FRF_MOTO_MODE_2, SSI_MODE_MASTER, 40000000, 16);
}
void SPI_write(const uint8_t* dataBuffer, uint8_t count){
while(count--){
SSIDataPut(SSI0_BASE, *dataBuffer++);
}
while(SSIBusy(SSI0_BASE));
}
//*****************************************************************************
//Main function Entry.
//
//*****************************************************************************
int
main(void)
{
uint8_t dataTX[4] = {0x40, 0x4F, 0x4F, 0x04};
uint8_t count;
ui32SysClocks = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_240), 120000000);
InitConsole();
UARTprintf("SPI -> Master to Slave\n");
UARTprintf("SPI Bit_Rate: 16-bit\n\n");
InitSPI();
SSIEnable(SSI0_BASE);
SPI_write(dataTX, 4);
for(count = 0; count < NUM_SSI_DATA; count = count + 1){
UARTprintf("The byte is transferred is: %X\n", dataTX[count]);
}
UARTprintf("Done transferring the data\r\n");
UARTprintf("----------------------------------------------------------------------");
UARTprintf("\r\n\n");
while(1);
}
SSI bus configuration
1) SCLk -> 20MHZ,
2) Data is sampled on falling edge and transferred on raising edge.
3) Bit Rate = 16-bits
Please let me know,
Looking forward to hearing from you.
Thanks and Regards,
Sai
