Post Go back to editing

AD2S1210 reading issue

I have interfaced EVAL-CN0276-SDPZ with STM32f303 using SPI .my issue is write now is Am able to write register (i tried to change frequency and checked), but am not able to read registers (either i get 0x80 or 0xFF). i tried many possibilities but, didn't worked.Help me on this , give me sample driver for any microcontroller. #ad2s1210

  • Sandeep

    Can you tell me a bit more about the connectivity between the CN0276 hardware and your controller?   Also if you are willing to share the code you have I may be able to get you back on track

    Sean

  • this just test code am currently working on i shared

    /* Main function */

    //serial interface is selected by holding the SOE pin low.
    HAL_GPIO_WritePin(GPIOC, GPIO_PIN_8, GPIO_PIN_RESET);

    // A0, A1 pins should default LOW
    HAL_GPIO_WritePin(GPIOC, GPIO_PIN_10, GPIO_PIN_RESET);
    HAL_GPIO_WritePin(GPIOC, GPIO_PIN_11, GPIO_PIN_RESET);

    // FSYNC default HIGH
    HAL_GPIO_WritePin(GPIOC, GPIO_PIN_12, GPIO_PIN_SET);

    // SAMPLE default HIGH
    HAL_GPIO_WritePin(GPIOD, GPIO_PIN_2, GPIO_PIN_SET);

    // RES0, RES1 pins should be HIGH for 16-bit resolution
    HAL_GPIO_WritePin(GPIOC, GPIO_PIN_10, GPIO_PIN_SET);
    HAL_GPIO_WritePin(GPIOC, GPIO_PIN_11, GPIO_PIN_SET);


    ///////////////////////////////// To Change Excitation Frequency ////////////////////////////////////////////////
    // A0, A1 pins should HIGH for configuration mode
    HAL_GPIO_WritePin(GPIOC, GPIO_PIN_10, GPIO_PIN_SET);
    HAL_GPIO_WritePin(GPIOC, GPIO_PIN_11, GPIO_PIN_SET);

    // Enable write enable latch (allow write operations)
    HAL_GPIO_WritePin(GPIOC, GPIO_PIN_12, GPIO_PIN_RESET);
    HAL_SPI_Transmit(&hspi1, (uint8_t *)&AD2S1210_REG_EXCIT_FREQ, 1, 100);
    HAL_GPIO_WritePin(GPIOC, GPIO_PIN_12, GPIO_PIN_SET);

    Txdata[0] = 0x14;
    // Enable write enable latch (allow write operations)
    HAL_GPIO_WritePin(GPIOC, GPIO_PIN_12, GPIO_PIN_RESET);
    HAL_SPI_Transmit(&hspi1, (uint8_t *)&Txdata, 1, 100);
    HAL_GPIO_WritePin(GPIOC, GPIO_PIN_12, GPIO_PIN_SET);

    /*// // A0, A1 pins should default LOW*/
    HAL_GPIO_WritePin(GPIOC, GPIO_PIN_10, GPIO_PIN_RESET);
    HAL_GPIO_WritePin(GPIOC, GPIO_PIN_11, GPIO_PIN_RESET);
    HAL_Delay(1000);

    ///////////////////////////////// END OF Excitation Frequency Change////////////////////////////////////////////////

    ///////////////////////////////// To Change Excitation Frequency ////////////////////////////////////////////////
    // A0, A1 pins should HIGH for configuration mode
    HAL_GPIO_WritePin(GPIOC, GPIO_PIN_10, GPIO_PIN_SET);
    HAL_GPIO_WritePin(GPIOC, GPIO_PIN_11, GPIO_PIN_SET);

    Txdata[0]=AD2S1210_REG_CONTROL|0x80;
    Txdata[1]=AD2S1210_REG_FAULT;

    // Enable write enable latch (allow write operations)
    HAL_GPIO_WritePin(GPIOC, GPIO_PIN_12, GPIO_PIN_RESET);
    HAL_SPI_TransmitReceive(&hspi1,&Txdata,&Rxdata , 2, 100);
    HAL_GPIO_WritePin(GPIOC, GPIO_PIN_12, GPIO_PIN_SET);

    //HAL_SPI_Receive(&hspi1, (uint8_t *)&Rxdata, 1, 100);

    // A0, A1 pins should default LOW
    HAL_GPIO_WritePin(GPIOC, GPIO_PIN_10, GPIO_PIN_RESET);
    HAL_GPIO_WritePin(GPIOC, GPIO_PIN_11, GPIO_PIN_RESET);
    HAL_Delay(1000);

    Txdata[0]=0x80|0x80;
    Txdata[1]=0x81|0x80;

    // Enable write enable latch (allow write operations)
    HAL_GPIO_WritePin(GPIOC, GPIO_PIN_12, GPIO_PIN_RESET);
    HAL_SPI_TransmitReceive(&hspi1,&Txdata,&Rxdata , 2, 100);
    HAL_GPIO_WritePin(GPIOC, GPIO_PIN_12, GPIO_PIN_SET);

  • SPI configuration using

    hspi1.Instance = SPI1;
    hspi1.Init.Mode = SPI_MODE_MASTER;
    hspi1.Init.Direction = SPI_DIRECTION_2LINES;
    hspi1.Init.DataSize = SPI_DATASIZE_8BIT;
    hspi1.Init.CLKPolarity = SPI_POLARITY_HIGH;
    hspi1.Init.CLKPhase = SPI_PHASE_1EDGE;
    hspi1.Init.NSS = SPI_NSS_SOFT;
    hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_64;
    hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
    hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
    hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
    hspi1.Init.CRCPolynomial = 7;
    hspi1.Init.CRCLength = SPI_CRC_LENGTH_DATASIZE;
    hspi1.Init.NSSPMode = SPI_NSS_PULSE_DISABLE; 

    Currently CLK polarity and Phase is 1 and 0 , tried with 1 and 1 also

  • Sandeep

    Please try clock polarity 0 phase=1.    Also please make sure RDB is driven high and CS is low or data interface may misbehave.  

    sean

  • Tried with Polarity 0 and Phase 1 but still getting 0xFF only