This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] ADS131M08:SPI 短帧

Guru**** 2460850 points
Other Parts Discussed in Thread: ADS131M08

请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/data-converters-group/data-converters/f/data-converters-forum/1383189/ads131m08-spi-short-frames

器件型号:ADS131M08

工具与软件:

我使用的是 STM32L4P5 发现套件中读取寄存器的默认值 ADS131M08 . 当我在 SPI 发送和接收之间引入4ms 的最小延迟时、我成功获得了预期的默认值。 没有这个延迟、我收到一个不正确的值。

例如、在读取 ID 寄存器时:

  • 无延迟: id = 0x0007
  • 4ms 延迟: id = 0x2801

为什么这种延迟是必要的?如何在潜在情况下消除它?

SPI 参数设置:

SPI MODE = MODE 1 (CPOL = 0、CPHA = 1)
SCK = 3MHz  



uint16_t ads131m08_rreg (uint8_t addr) {

	// 24 bits word length
    uint8_t cmd[3];
    uint8_t res[3]; // response

    uint16_t read_cmd = OPCODE_RREG | (addr << 7);

    cmd[0] = read_cmd >> 8;
    cmd[1] = (uint8_t) read_cmd & 0x00FF;
    cmd[2] = 0x00; // zero padding to match 24 bits word length

    /*chip select*/
    HAL_GPIO_WritePin(CS_GPIO_Port, CS_Pin, GPIO_PIN_RESET);

    if (HAL_SPI_Transmit_DMA(&hspi2, cmd, 3) != HAL_OK) {
        // Handle error
        HAL_GPIO_WritePin(CS_GPIO_Port, CS_Pin, GPIO_PIN_SET);
        return 0;
    }

    HAL_Delay(4); // Delay required to get the response 

    // Wait for the transmit to complete
    while (HAL_SPI_GetState(&hspi2) != HAL_SPI_STATE_READY) {
        // Do nothing, just wait
    }

    if (HAL_SPI_Receive_DMA(&hspi2, res, 3) != HAL_OK) {
        // Handle error
        HAL_GPIO_WritePin(CS_GPIO_Port, CS_Pin, GPIO_PIN_SET);
        return 0;
    }

    // Wait for the receive to complete
    while (HAL_SPI_GetState(&hspi2) != HAL_SPI_STATE_READY) {
        // Do nothing, just wait
    }

    HAL_GPIO_WritePin(CS_GPIO_Port, CS_Pin, GPIO_PIN_SET);

    uint16_t ret = ((uint16_t) res[0] << 8) | res[1];

    return ret;
}

 

- Srihari

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的  Srihari:

    您是否需要提供包括/CS、SCLK、DIN 和 DOUT 在内的时序图?

    BR、

    戴尔