Quantcast
Channel: Data converters
Viewing all articles
Browse latest Browse all 91209

Forum Post: RE: ADS1256: ADS1256 and TM4C129 SSI communication issue

$
0
0
Hi, Thanks for getting back to me. I made some changes and ran the code. It seems one of the issue is the sclk frequency used. It seems I can read back the values of the registers 01h,03h and 04h. The registers 00h gives random values and 02h returns nothing on the miso line. I am attaching the code and also the spi communication on the oscilloscope. #include #include #include "inc/hw_memmap.h" #include "inc/hw_ssi.h" #include "inc/hw_types.h" #include "driverlib/ssi.h" #include "driverlib/gpio.h" #include "driverlib/pin_map.h" #include "driverlib/sysctl.h" #include "UART.h" #include "driverlib/uart.h" uint32_t ui32SysClkFreq; int i; uint8_t k,j=0; char buffer [sizeof(long)*8+1]; int main(void) { uint32_t ui32Index; long ui32Data[4] =1; ui32SysClkFreq = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000); /*Uart initialization*/ SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); // Port A for Uart GPIOPinConfigure(GPIO_PA0_U0RX); GPIOPinConfigure(GPIO_PA1_U0TX); GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); UARTConfigSetExpClk(UART0_BASE, ui32SysClkFreq, 9600,(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); /*SPI initialization*/ SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI2); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION); // CS control GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_4); GPIOPinTypeGPIOInput(GPIO_PORTN_BASE, GPIO_PIN_5); //DRDY SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); GPIOPinConfigure(GPIO_PD3_SSI2CLK); SSIAdvModeSet(SSI2_BASE,SSI_ADV_MODE_LEGACY); GPIOPinConfigure(GPIO_PD1_SSI2XDAT0); GPIOPinConfigure(GPIO_PD0_SSI2XDAT1); GPIOPinTypeSSI(GPIO_PORTD_BASE,GPIO_PIN_3|GPIO_PIN_2|GPIO_PIN_1|GPIO_PIN_0); SSIConfigSetExpClk(SSI2_BASE, ui32SysClkFreq, SSI_FRF_MOTO_MODE_1, SSI_MODE_MASTER, 2000000, 16); SSIEnable(SSI2_BASE); GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_4,16); GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_4,0); // deasserting CS //send reset command while(GPIOPinRead(GPIO_PORTN_BASE, GPIO_PIN_5)){}; // check DRDY line for(i=0; i<1000;i++) // delay before first SCLK SSIDataPut(SSI2_BASE, 0xfe); // reset command while(SSIBusy(SSI2_BASE)) { } SSIDataPut(SSI2_BASE,0x0f); // SDATAC command while(SSIBusy(SSI2_BASE)) { } //WREG DRATE COMMMAND SSIDataPut(SSI2_BASE, 0x53); for(i=0; i<1000;i++) SSIDataPut(SSI2_BASE, 0x00); for(i=0; i<1000;i++) SSIDataPut(SSI2_BASE, 0xa1); for(i=0; i<1000;i++) while(SSIBusy(SSI2_BASE)) { } for(i=0; i<1000;i++); /*WREG MUX SSIDataPut(SSI2_BASE, 0x51); while(SSIBusy(SSI2_BASE)) { } SSIDataPut(SSI2_BASE, 0x00); while(SSIBusy(SSI2_BASE)) { } SSIDataPut(SSI2_BASE, 0x01); while(SSIBusy(SSI2_BASE)) { }*/ while(1) { GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_4,0); // deasserting CS /*read DRATE register*/ while(GPIOPinRead(GPIO_PORTN_BASE, GPIO_PIN_5)){}; // check DRDY line SSIDataPut(SSI2_BASE, 0x11); // send 1st command byte -0b00010000 for(i=0; i<100;i++) SSIDataPut(SSI2_BASE, 0x00); // send 2nd command byte -0b00000000 while(SSIBusy(SSI2_BASE)) { } // SSIDataGet(SSI2_BASE, &ui32Data[0]); GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_4,16); // asserting CS }} Miso(Purple) - read back value(01h) =01h (13h) read back value = F0h similarly, I got E0h for (14h- register). I cannot also write to the registers it seems.

Viewing all articles
Browse latest Browse all 91209

Trending Articles



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