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.

[参考译文] ADS1258:DRDY 读取

Guru**** 2391935 points
Other Parts Discussed in Thread: ADS1258

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

https://e2e.ti.com/support/data-converters-group/data-converters/f/data-converters-forum/1270669/ads1258-drdy-read

器件型号:ADS1258

大家好、

我使用的是针对 ADS1258的直接数据读取。 当我遇到 DRDY 为低电平时、它将进入控制器中的中断处理程序。 因此、在该处理程序中、我首先必须将 START 引脚设置为低电平以使器件处于空闲状态。 然后、我必须读取数据。 对吗? 我在该论坛中看到过此方法、您的团队在该论坛中向其他人提及此方法。  

到目前为止、我在中断处理程序中执行这样的程序流。

// When DRDY is low
void Interrupt_handler(){

    disable_the_interrupt();
    start_pin_to_low();
    read_data();
    start_pin_to_high();
    enable_the_interrupt();
    
}

任何建议

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

    尊敬的 Fahad K R:

    首先确保中断在下降沿触发、 边沿 而不是电平触发器。  在中断处理程序例程中,确保在 enable_the_interrupt ()函数之前清除中断。  设置 START_PIN_TO_LOW()不会停止正在进行的转换。  它将在下一次转换完成后停止、因此您不处于空闲状态、因为 ADC 仍在转换。  对于此序列、您很可能会在实际达到 IDLE 状态之前读取转换数据并设置 START_PIN_TO_HIGH ()。  该过程如 ADS1258数据表的图53所示。

    我想您要进行单次转换、在 DRDY 变为低电平时读取数据并开始下一次转换(数据表中的图54)。  如果是这种情况、那么您应该在要开始下一次转换时只对 START 引脚施加低电平-高电平-低电平脉冲。  为此、您可以在进入主循环之前的开头对 START 引脚施加脉冲、以启动第一次转换。  在中断例程中、您将删除现有的 START_PIN_函数、 而是添加 START 脉冲(或切换)函数。

    尽管此中断例程应该可以正常工作、但根据系统的复杂性、存在一些潜在的问题。  一般而言、良好的编程做法是确认中断并尽快退出。  限制时间量的一种方法是针对可用的新数据将布尔标志设置为 true。  然后在主循环中、您会检查标志的值、如果设置了标志、则会读取数据。  当可能发生多个中断而可能影响程序循环的整体时序时、这一点很重要。  ADS1258示例 C 代码中提供了相关操作的示例。

    此致、

    鲍勃 B

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

    尊敬的 Bob:

    这是来自 SPI 通信的数据。

    蓝色- DRDY

    绿色-来自 ADC 的数据输出

    黄色-时钟

    1) 1)我正在直接模式下读取它。 我尝试了3个字节和4个字节(带和不带状态字节)。 但得到相同的输出、 8时钟 数据始终是相同的(数据是 0x92 )。  

    2) 2)我对示例代码有疑问。 如果我要在 ISR 中设置一个标志、我只需调用函数 waitForDRDY 中断 函数当我需要读取数据并启用中断时、我必须等待中断。 在本章中、  waitForDRDY 中断  函数、我必须读取数据。 您是指之前的建议吗?

     

    bool waitForDRDYinterrupt(uint32_t timeout_ms)
    {
        /* --- TODO: INSERT YOUR CODE HERE ---
         * Poll the nDRDY GPIO pin until it goes low. To avoid potential infinite
         * loops, you may also want to implement a timer interrupt to occur after
         * the specified timeout period, in case the nDRDY pin is not active.
         * Return a boolean to indicate if nDRDY went low or if a timeout occurred.
         */
    
        // Convert ms to # of loop iterations or use a timer
        uint32_t timeout = timeout_ms * 6000;   // convert to # of loop iterations
    
        // Reset interrupt flag
        flag_nDRDY_INTERRUPT = false;
    
        // Enable interrupts
        IntMasterEnable();
    
        // Wait for nDRDY interrupt or timeout - each iteration is about 20 ticks
        do {
            timeout--;
        } while (!flag_nDRDY_INTERRUPT && (timeout > 0));
    
        // Reset interrupt flag
        flag_nDRDY_INTERRUPT = false;
    
        return (timeout > 0);           // Did a nDRDY interrupt occur?
    }
    
     

    谢谢!  

    法哈德·克里

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

    尊敬的 Fahad K R:

    1)我正在直接模式下读取它。 我尝试了3个字节和4个字节(带和不带状态字节)。 但得到相同的输出、 8时钟 数据始终是相同的(数据是 0x92 )。  [/报价]

    我在这里对你想做什么有点困惑。  您是通过设置 START 引脚还是通过脉冲启动新的转换?  此外、微控制器会启动 SCLK、所以您是说您只看到一个字节的 SCLK 吗?

    2)我对示例代码有疑问。 如果我要在 ISR 中设置一个标志、我只需调用函数 waitForDRDY 中断 函数当我需要读取数据并启用中断时、我必须等待中断。 在本章中、  waitForDRDY 中断  函数、我必须读取数据。 这是你之前的建议的意思吗?

    在主循环中,您可以使用 waitForDRDYinterrupt(),但不需要使用此函数。  我试图演示的是使用一个旗帜。  下面是使用您的原始代码的另一个示例:

    // When DRDY is low
    void Interrupt_handler(){
    
        disable_the_interrupt();
        flag_nDRDY_INTERRUPT = true;
        
        // check to make sure that the interrupt gets cleared before reenabling
        enable_the_interrupt();
    }
    
    void main {
        bool flag_nDRDY_INTERRUPT = false;
        
        // setup the ADC and enable the interrupt
        // toggle the START pin to initiate the first ADC conversion
        start_pin_to_high();
        start_pin_to_low();
        
        // main loop
        while(.t.) {
            // this is the main processing loop so add what ever you would like to 
            // do in this loop
            
            // if the flag has been set, then there is new data
            if(flag_nDRDY_INTERRUPT==true) {
                read_data(); 
                // reset the status flag
                flag_nDRDY_INTERRUPT = false;
                // toggle the START pin to initiate the next ADC conversion
                start_pin_to_high();
                start_pin_to_low();
        }
    }

    请注意、在中断内所做的一切就是设置标志、并且您的主处理循环会检查标志的状态、并在新数据可用时读取数据。

    此致、

    鲍勃 B

    [/quote]