Hi
.I am using this code for ADS1252 and this is what i have on serial plotter when I disconnect jumper from PA6, when jumper is connected serial plotter is freezing.
No responds to shorting input pins 1 and 2 of ADS1252 .
#include <SPI.h>
// ADS1252 Connections
const int CLK_PIN = PA0; // PWM output for ADS1252 Clock, ADS1252 pin # 4
const int DOUT_PIN = PA6; // SPI1 MISO ADS1252 pin # 5
const int SCLK_PIN = PA5; // SPI1 SCK ADS1252 pin # 6
void setup() {
Serial.begin(115200);
// Set up 1 MHz Clock on PA0 for ADS1252
pinMode(CLK_PIN, OUTPUT);
// Configure Timer to produce a 1MHz-2MHz clock here.
// Simplified: Using analogWrite to produce PWM (may need frequency adjustment)
analogWrite(CLK_PIN, 128);
// Initialize SPI for reading
SPI.begin();
SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE0));
pinMode(DOUT_PIN, INPUT);
}
void loop() {
// Wait for /DRDY (DOUT/DRDY goes low)
if (digitalRead(DOUT_PIN) == LOW) {
long result = 0;
// Read 24-bit (3 bytes)
byte b1 = SPI.transfer(0x00);
byte b2 = SPI.transfer(0x00);
byte b3 = SPI.transfer(0x00);
// Assemble 24 bits
result = ((long)b1 << 16) | ((long)b2 << 8) | (long)b3;
// Handle 24-bit signed conversion
if (result & 0x800000) {
result |= 0xFF000000;
}
Serial.print(" analog = "); Serial.print( analogRead (PA2));
Serial.print(" result = ");Serial.print(result);
Serial.println();
}
}

