Post Go back to editing

AD2S1210

Hi! 

I can not write/read data to the config register in configuration mode. 

I do this on stm32: (parallel interface)


GPIOC->BSRR |= GPIO_BSRR_BS4; //A0=1
GPIOC->BSRR |= GPIO_BSRR_BS5; //A1=1
GPIOB->BSRR |= GPIO_BSRR_BR12; //CS=0

GPIOA->BSRR |= GPIO_BSRR_BS2; //SOE = 1

D15_D0_IN(); //all input

while(1)
{


GPIOC->BSRR |= GPIO_BSRR_BR1; //RESET=0
HAL_Delay(10);
GPIOC->BSRR |= GPIO_BSRR_BS1; //RESET=1
HAL_Delay(1);


D15_D0_OUT(); //all output


GPIOA->BSRR |= GPIO_BSRR_BR1; //WR=0
GPIOD->ODR = 0x0092;
GPIOA->BSRR |= GPIO_BSRR_BS1; //WR=1

HAL_Delay(1);


GPIOA->BSRR |= GPIO_BSRR_BR1; //WR=0
GPIOD->ODR = 0x007e;
GPIOA->BSRR |= GPIO_BSRR_BS1; //WR=1

HAL_Delay(1);

D15_D0_OUT();

GPIOA->BSRR |= GPIO_BSRR_BR1; //WR=0
GPIOD->ODR = 0x0092;
GPIOA->BSRR |= GPIO_BSRR_BS1; //WR=1

D15_D0_IN(); //all input

GPIOC->BSRR |= GPIO_BSRR_BR2; //RD=0

HAL_Delay(1);

HAL_Delay(1); //wait data.....

GPIOC->BSRR |= GPIO_BSRR_BS2; //RD=1

HAL_Delay(100);

}



change
[edited by: denis_nal at 12:58 PM (GMT -4) on 16 Aug 2021]
  • Denis,

    One question should your read of the data bus command D15_D0_IN() not come after you pull RD low?  Otherwise you are reading the output bus when it is inhibited.

    If modifying the read doesn't work can you please try and send scope or Logic Analyzer captures of your parallel interface timing.  This will help us diagnose the trouble.

    Sean

  • Made a transfer over SPI.

    AD2S1210_init();
    
      GPIOC->BSRR |= GPIO_BSRR_BS4; //A0=1
      GPIOC->BSRR |= GPIO_BSRR_BS5; //A1=1
    
      while(1)
      {
    
    	buf_tx[0] = 0x92;
    	buf_tx[1] = 0x92;
    
    
    	GPIOA->BSRR |= GPIO_BSRR_BR1; //wr = 0
    	HAL_SPI_Transmit(&hspi2, &buf_tx[0],1, 100);
    	GPIOA->BSRR |= GPIO_BSRR_BS1; //wr = 1
    
    
    	GPIOA->BSRR |= GPIO_BSRR_BR1; //wr = 0
    	HAL_SPI_Transmit(&hspi2, &buf_tx[1],1, 100);
    	HAL_SPI_Receive(&hspi2, buf_rx,1, 100);
    	GPIOA->BSRR |= GPIO_BSRR_BS1; //wr = 1
    
    	HAL_Delay(100);
    
      }

    Send 0х92 0х92   Answer 0x12 0x12....

  • AD2S1210_init();
    
      GPIOC->BSRR |= GPIO_BSRR_BS4; //A0=1
      GPIOC->BSRR |= GPIO_BSRR_BS5; //A1=1
    
      while(1)
      {
    
    	buf_tx[0] = 0x92;
    	buf_tx[1] = 0x92;
    
    
    	GPIOA->BSRR |= GPIO_BSRR_BR1; //wr = 0
    	HAL_SPI_Transmit(&hspi2, &buf_tx[0],1, 100);
    	GPIOA->BSRR |= GPIO_BSRR_BS1; //wr = 1
    
    
    	GPIOA->BSRR |= GPIO_BSRR_BR1; //wr = 0
    	HAL_SPI_Transmit(&hspi2, &buf_tx[1],1, 100);
    	HAL_SPI_Receive(&hspi2, buf_rx,1, 100);
    	GPIOA->BSRR |= GPIO_BSRR_BS1; //wr = 1
    
    	HAL_Delay(100);
    
      }

    I send 0x92 0x92 answer 0x12...register 0x92 nor read not write....

  • Denis,

    First thing is I want to verify is that you are using SPI_MODE = 1, CPOL = 0, CPHA = 1.

    Second is to make sure you have CS driven low and RDB driven high (which I believe you do as you're getting data).

    Also please try not to use IMGBB as there is extraneous (and somewhat inappropriate) content attached to your images and that will cause havoc with our system.  It tends to see that content as malicious and will put your post in a holding pattern for moderation. 

    Sean

  • Victor can you zoom in on the serial data timing so I can look at the setup and hold settings?

    What happens during your AD2S1210_init() function?

    Are you allowing time for the AVDD and DVDD power rails to reach 4.75V before releasing RESET?  Please note that there is a device on the EVB that holds the device in reset for several hundred milliseconds after power up so be sure to avoid that time when you start.  In fact if you are applying reset in your init function I would make sure that it still isn't asserted when you start your configuration access in the While loop.

    Please share your call of HAL_SPI_init() so that I can review the settings there.

    Please also confirm that you are using VDRIVE = 3.3V to match the STM32 IO voltage and that your SPI clock frequency is <25MHz (which it appears to be from your image).  Also make sure you have the minimum WR high time between each 8'bit transfer and I would use HAL_SPI_TransmitReceive() to execute your reads and writes.  Only one byte should be transmitted per WR frame.

    Sean

  • Voltages after reset are normal.  

    If you send 8 bits, the AD2S1210 does not respond at all.

    static void MX_SPI2_Init(void)
    {
    
      /* USER CODE BEGIN SPI2_Init 0 */
    
      /* USER CODE END SPI2_Init 0 */
    
      /* USER CODE BEGIN SPI2_Init 1 */
    
      /* USER CODE END SPI2_Init 1 */
      /* SPI2 parameter configuration*/
      hspi2.Instance = SPI2;
      hspi2.Init.Mode = SPI_MODE_MASTER;
      hspi2.Init.Direction = SPI_DIRECTION_2LINES;
      hspi2.Init.DataSize = SPI_DATASIZE_8BIT;
      hspi2.Init.CLKPolarity = SPI_POLARITY_LOW;
      hspi2.Init.CLKPhase = SPI_PHASE_1EDGE;
      hspi2.Init.NSS = SPI_NSS_SOFT;
      hspi2.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_128;
      hspi2.Init.FirstBit = SPI_FIRSTBIT_MSB;
      hspi2.Init.TIMode = SPI_TIMODE_DISABLE;
      hspi2.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
      hspi2.Init.CRCPolynomial = 10;
      if (HAL_SPI_Init(&hspi2) != HAL_OK)
      {
        Error_Handler();
      }
      /* USER CODE BEGIN SPI2_Init 2 */
    
      /* USER CODE END SPI2_Init 2 */
    
    }
    
    
    void AD2S1210_init()
    {
    	HAL_Delay(100);
    
    	GPIOA->BSRR |= GPIO_BSRR_BR2; //SOE=0
    	GPIOB->BSRR |= GPIO_BSRR_BS0; //SAMPLE =1
    	GPIOA->BSRR |= GPIO_BSRR_BS1; //WR=1
    
    	GPIOC->BSRR |= GPIO_BSRR_BS1; //RESET=1
    	HAL_Delay(1);
    	GPIOC->BSRR |= GPIO_BSRR_BR1; //RESET=0
    	HAL_Delay(500);
    	GPIOC->BSRR |= GPIO_BSRR_BS1; //RESET=1
    
    	GPIOC->BSRR |= GPIO_BSRR_BS4; //A0=1
    	GPIOC->BSRR |= GPIO_BSRR_BS5; //A1=1
    	HAL_Delay(1);
    
    	GPIOB->BSRR |= GPIO_BSRR_BR12; //CS=0
    	GPIOC->BSRR |= GPIO_BSRR_BS2;  //RD=1
    }
    
    
      AD2S1210_init();
    
      GPIOC->BSRR |= GPIO_BSRR_BS4; //A0=1
      GPIOC->BSRR |= GPIO_BSRR_BS5; //A1=1
      GPIOB->BSRR |= GPIO_BSRR_BR12; //CS=0
    
      while(1)
      {
    
    	buf_tx[0] = 0x92;
    
    	GPIOA->BSRR |= GPIO_BSRR_BR1; //wr = 0
    	HAL_SPI_TransmitReceive(&hspi2, &buf_tx[0], &buf_rx[0],1, 100);
    	GPIOA->BSRR |= GPIO_BSRR_BS1; //wr = 1
    
    	buf_tx[0] = 0x88;
    	_delay_us(100);
    
    	GPIOA->BSRR |= GPIO_BSRR_BR1; //wr = 0
    	HAL_SPI_TransmitReceive(&hspi2, &buf_tx[0], &buf_rx[0],1, 100);
    	GPIOA->BSRR |= GPIO_BSRR_BS1; //wr = 1
    
    	_delay_us(100);
    
      }

  • static void MX_SPI2_Init(void)
    {
    
      /* USER CODE BEGIN SPI2_Init 0 */
    
      /* USER CODE END SPI2_Init 0 */
    
      /* USER CODE BEGIN SPI2_Init 1 */
    
      /* USER CODE END SPI2_Init 1 */
      /* SPI2 parameter configuration*/
      hspi2.Instance = SPI2;
      hspi2.Init.Mode = SPI_MODE_MASTER;
      hspi2.Init.Direction = SPI_DIRECTION_2LINES;
      hspi2.Init.DataSize = SPI_DATASIZE_8BIT;
      hspi2.Init.CLKPolarity = SPI_POLARITY_LOW;
      hspi2.Init.CLKPhase = SPI_PHASE_1EDGE;
      hspi2.Init.NSS = SPI_NSS_HARD_OUTPUT;
      hspi2.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_128;
      hspi2.Init.FirstBit = SPI_FIRSTBIT_MSB;
      hspi2.Init.TIMode = SPI_TIMODE_DISABLE;
      hspi2.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
      hspi2.Init.CRCPolynomial = 10;
      if (HAL_SPI_Init(&hspi2) != HAL_OK)
      {
        Error_Handler();
      }
      /* USER CODE BEGIN SPI2_Init 2 */
    
      /* USER CODE END SPI2_Init 2 */
    
    }
    
    
    
    
    
    AD2S1210_init();
    
    void AD2S1210_init()
    {
    	HAL_Delay(100);
    
    	GPIOA->BSRR |= GPIO_BSRR_BR2; //SOE=0
    	GPIOB->BSRR |= GPIO_BSRR_BS0; //SAMPLE =1
    	GPIOA->BSRR |= GPIO_BSRR_BS1; //WR=1
    
    	GPIOC->BSRR |= GPIO_BSRR_BS1; //RESET=1
    	HAL_Delay(1);
    	GPIOC->BSRR |= GPIO_BSRR_BR1; //RESET=0
    	HAL_Delay(500);
    	GPIOC->BSRR |= GPIO_BSRR_BS1; //RESET=1
    
    	GPIOC->BSRR |= GPIO_BSRR_BS4; //A0=1
    	GPIOC->BSRR |= GPIO_BSRR_BS5; //A1=1
    	HAL_Delay(1);
    
    	GPIOB->BSRR |= GPIO_BSRR_BR12; //CS=0
    	GPIOC->BSRR |= GPIO_BSRR_BS2;  //RD=1
    }
    
      GPIOC->BSRR |= GPIO_BSRR_BS4; //A0=1
      GPIOC->BSRR |= GPIO_BSRR_BS5; //A1=1
      GPIOB->BSRR |= GPIO_BSRR_BR12; //CS=0
    
      while(1)
      {
    
    	buf_tx[0] = 0x92;
    
    	GPIOA->BSRR |= GPIO_BSRR_BR1; //wr = 0
    	HAL_SPI_TransmitReceive(&hspi2, &buf_tx[0], &buf_rx[0],1, 100);
    	GPIOA->BSRR |= GPIO_BSRR_BS1; //wr = 1
    
    	buf_tx[0] = 0x88;
    	_delay_us(100);
    
    	GPIOA->BSRR |= GPIO_BSRR_BR1; //wr = 0
    	HAL_SPI_TransmitReceive(&hspi2, &buf_tx[0], &buf_rx[0],1, 100);
    	GPIOA->BSRR |= GPIO_BSRR_BS1; //wr = 1
    
    	_delay_us(100);
    
      }
    

    If you send in 1 byte, the AD2S1210 does not respond.

    Why do all the pictures go to spam ????
    How to attach a screenshot ??

    https://rataku.com/i/pzXfz

  • Denis,

    Having looked at your initialization you need to change your SPI configuration to call out SPI_PHASE_2EDGE so that data is read in on the trailing edge of clock as I had mentioned previously when referencing the SPI mode.

    WIth regards to sending only 8-bits I may have caused you a bit of confusion there as I meant to use the SPI_TransmitReceive function but to send it multiple times.  The first time you send it of course you can ignore the receive data but each subsequent time you do a transmit the data on the MISO/SDO pin should be the content you expect.

    So for example if I wanted to write the following sequence to the AD2S1210 

    0x91, 0x20, 0x92, 0x70, 0xFF which equates to

    • ADDRESS EXCITATION REGISTER
    • WRITE 32d to the EXCITATION REGISTER
    • ADDRESS CONTROL REGISTER
    • WRITE CONTROL TO enable 44 degree phase lock, Hystersis enabled, 10bit encoder, 10 bit resolution
    • ADDRESS FAULT REGISTER

    I should expect 

    0xXX, 0x28, 0x20, 0x7E, 0x70,....

    because

    • IGNORE first transfer. State of Address unknown.
    • EXCITATION REGISTER IS ADDRESSED, READ DEFAULT OF 40d (0x28h)
    • EXCITATION REGISTER IS ADDRESSED, READ NEW VALUE OF 32d (0x20h)
    • CONTROL REGISTER IS ADDRESSED, READ DEFAULT VALUE OF 0x7Eh
    • CONTROL REGISTER IS ADDRESSED, READ NEW VALUE OF 0x70h.
    • The next transfer would read the fault register contents.....

    Hope this gets you up and running.

    I will look over the rest of your init code but the SPI init was probably the issue.