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.

[参考译文] ADS1298:采用 c 语言的 ADS1298示例代码

Guru**** 2768395 points

Other Parts Discussed in Thread: ADS1298

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

https://e2e.ti.com/support/data-converters-group/data-converters/f/data-converters-forum/758923/ads1298-ads1298-sample-code-in-c-language

器件型号:ADS1298

是否有用于以 c 语言读取 ADS1298的示例代码。  

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

    遗憾的是、我们没有该器件的任何示例代码。
    也许在其他在线社区中、软件编码方面已经开发出了一些可能有所帮助的工具、但我们不会维护这些工具。

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

    您好!

    这是我在互联网上从 Arduino 中参考的代码。

    我能够读取 ID 寄存器上的0x92。

    您能否检查 代码的序列/命令是否正常?

    #include 
    
    #define MOSI1 51 //MOSI
    #define MISO1 50 // MISO
    #define CLK1 52 //SCK
    
    #define PIN_CS 2
    #define PIN_RESET 3
    #define PIN_START 4
    #define PIN_DRDY 5
    
    #define READ 0x20
    #define WRITE 0x40
    
    #define ID 0x00
    #define SDATAC 0x11
    
    
    uint8_t debug_msg = 1U;
    字符串 Sep =------------------------------------------------------- ";
    字符串 hex_to_char (int hex_in){
    int precision = 2;
    char tmp[16];
    char format[128];
    sprintf (format、"0x%.%DX"、 Precision);
    sprintf (tmp、格式、hex_in);
    //Serial.print (tmp);
    return (String (tmp));
    }
    
    
    
    uint8_t read_Byte (uint8_t reg_addr)
    {
    uint8_t out = 0;
    
    digitalWrite (PIN_CS、低电平);
    
    spi.transfer (0x20 | reg_addr);
    delayMicroseconds (5);
    SPI.transfer (0x00);
    delayMicroseconds (5);
    
    OUT = SPI.transfer (0x00);
    delayMicroseconds (1);
    digitalWrite (PIN_CS、HIGH);
    
    if (debug_msg)
    {
    serial.println (Sep);
    serial.println ("sent:\t"+ hex_to_char (reg_addr));
    serial.println (“接收到:\t"+ hex_to_char (out)));
    }
    
    return (out);
    }
    
    
    void send_command (uint8_t cmd)
    {
    digitalWrite (PIN_CS、低电平);
    delayMicroseconds (5);// 5 = 6us (32时)
    spi.transfer (cmd);
    delayMicroseconds (10);
    digitalWrite (PIN_CS,高电平);
    }
    
    
    void setup()
    {
    Serial.begin(9600);
    
    
    引脚模式(CLK1、输出);
    引脚模式(MISO1、输入);
    引脚模式(MOSI1、输出);
    PinMode (PIN_CS、输出);
    引脚模式(PIN_RESET、输出);
    引脚模式(PIN_START、输出);
    引脚模式(PIN_DRDY、输入);
    digitalWrite (PIN_CS、HIGH);
    digitalWrite (PIN_START、LOW);
    
    SPI.begin();
    SPI.setDataMode(SPI_MODE1);
    SPI.setClockDivider(SPI_CLOCK_DIV16);
    SPI.setBitOrder(MSBFIRST);
    延迟(1000);
    
    digitalWrite (PIN_RESET、HIGH);
    延迟(1000);
    digitalWrite (PIN_RESET、LOW);
    延迟(1000);
    digitalWrite (PIN_RESET、HIGH);
    延迟(100);
    
    digitalWrite (PIN_CS、低电平);
    延迟(1000);
    digitalWrite (PIN_CS、HIGH);
    延迟(1000);
    
    
    SEND_COMMAND (SDATAC);
    延迟(10);
    
    for (;;)
    {
    uint8_t chSet = read_Byte (read | ID);
    
    serial.print ("-- ID"+ String (chSet)+"-");
    延迟(1000);
    }
    
    }
    
    
    
    
    void loop()
    {
    
    
    
    } 

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

    您好 Vindhyachal、

    您似乎有一些无关的芯片选择切换(与设置中 SEND_COMMAND (SDATAC)之前的最后一个切换)。 话虽如此、您是否从该代码中获得了预期结果? 使用四通道示波器(首选、但逻辑分析仪也可以正常工作)显示芯片选择、MOSI、MISO 和 SCLK 的屏幕截图是我们确定 ADS1298控制信号是否正确的更简单方法。