Other Parts Discussed in Thread: ADC161S626EVM
Hello,
My test application is basically takes the input of an analog signal (sine wave from the signal generator) convert it with the ADC161S626EVM BoosterPack and outputs the same signal without any modifications through the DAC161S055EVM BoosterPack, both BoosterPack communicates by the SPI interface.
The problem is that the output signal (Blue) looks like is freezing, like some part of the code is taking too long to be processed.
In the picture from the oscilloscope: Yellow (Output), Blue (Input signal).
The code is bellow. I made function to initialize the ADC and DAC. In main I just call those functions and also made the read/write routine inside while(1).
I'm now sure what exactly could be freezing the code, or taking too long to process. Any help would be very appreciated.
PS.: I tried to use the code highlighter, I hope it worked...
#include <stdbool.h> #include <stdio.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; uint16_t ui32Index, convertedValue, adcRX[2], value; uint32_t pui32DataRx[3], complement, dummy; // Initializing PORTD ==> FSS for the DAC void InitPORTD(void) { SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); while (!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOD)) { } GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE, GPIO_PIN_2); GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_2, GPIO_PIN_2); } // Initializing PORTD ==> FSS for the ADC 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, GPIO_PIN_4); } void InitADCSSI() { // The SSI0 peripheral must be enabled for use. SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI2); // Configure the pin muxing for SSI0 functions on port A2, A3, A4, and A5. GPIOPinConfigure(GPIO_PD3_SSI2CLK); //GPIOPinConfigure(GPIO_PD2_SSI2FSS); Function held by PORTE4 (InitPORTE) GPIOPinConfigure(GPIO_PD0_SSI2XDAT1); GPIOPinConfigure(GPIO_PD1_SSI2XDAT0); // 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.
GPIOPinTypeSSI(GPIO_PORTD_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_3); SSIConfigSetExpClk(SSI2_BASE, ui32SysClkFreq, SSI_FRF_MOTO_MODE_3, SSI_MODE_MASTER, 5000000, 16); SSIAdvModeSet(SSI2_BASE, SSI_ADV_MODE_LEGACY); // Enable the SSI0 module.
SSIEnable(SSI2_BASE); } void InitDACSSI(void) { //uint32_t pui32DataRx[3]; SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOQ); SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI3); GPIOPinConfigure(GPIO_PQ0_SSI3CLK); GPIOPinConfigure(GPIO_PQ3_SSI3XDAT1); GPIOPinConfigure(GPIO_PQ2_SSI3XDAT0); GPIOPinTypeSSI(GPIO_PORTQ_BASE, GPIO_PIN_0 | GPIO_PIN_2 | GPIO_PIN_3); SSIConfigSetExpClk(SSI3_BASE, ui32SysClkFreq, SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, 20000000, 8); SSIEnable(SSI3_BASE); //while (SSIDataGetNonBlocking(SSI2_BASE, &pui32DataRx[0])) { //} } // Initializing the DAC void InitDAC(void) { // Commands to initialing the DAC uint8_t command[2] = { 0x01, 0x28}; uint8_t first_data[2] = { 0x00, 0x00}; uint8_t second_data[2] = { 0x00, 0x00}; uint8_t uintindex; for (uintindex = 0; uintindex < 2; uintindex++) { GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_2, 0); SSIDataPut(SSI3_BASE, command[uintindex]); while (SSIBusy(SSI3_BASE)) { } SSIDataPut(SSI3_BASE, first_data[uintindex]); while (SSIBusy(SSI3_BASE)) { } SSIDataPut(SSI3_BASE, second_data[uintindex]); while (SSIBusy(SSI3_BASE)) { } GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_2, GPIO_PIN_2); } } int main(void) { ui32SysClkFreq = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000); InitPORTD(); InitPORTE(); InitADCSSI(); InitDACSSI(); InitDAC(); while (1) { // Emptying the FIFO while (SSIDataGetNonBlocking(SSI2_BASE, &pui32DataRx[0])) {} GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_4, 0); // Reading from the SPI for (ui32Index = 0; ui32Index < 2; ui32Index++) { SSIDataPut(SSI2_BASE, 0x00); SSIDataGet(SSI2_BASE, &dummy); adcRX[ui32Index] = dummy; } GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_4, GPIO_PIN_4); convertedValue = ((adcRX[0] << 2) | (adcRX[1] >> 14)); GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_2, 0); // Write Command to SPI SSIDataPut(SSI3_BASE, 0x08); while (SSIBusy(SSI3_BASE)) { } SSIDataPut(SSI3_BASE, convertedValue >> 8); while (SSIBusy(SSI3_BASE)) { } SSIDataPut(SSI3_BASE, convertedValue & 0xFF); while (SSIBusy(SSI3_BASE)) { } GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_2, GPIO_PIN_2); } }