I cannot establish an SPI connection between the Arduino Uno and the MAX11300PMB1 module. There is no voltage at the output pins. My Arduino code configured all 20 pins to DAC.
Here is my example code:
#include <SPI.h>
// Define SPI pin connections
#define CS_PIN 10 // Chip Select (Active Low)
// MAX11300 Registers
#define MAX11300_DEVICE_CONTROL 0x10
#define MAX11300_PORT_CONFIG_BASE 0x20
#define MAX11300_DAC_DATA_BASE 0x40
// Function to initialize SPI and MAX11300
void setup() {
Serial.begin(115200);
SPI.begin();
pinMode(CS_PIN, OUTPUT);
digitalWrite(CS_PIN, HIGH);
// Reset MAX11300
writeRegister(MAX11300_DEVICE_CONTROL, 0x0001);
delay(100); // Allow time to reset
// Configure all 20 pins as DAC outputs
for (uint8_t i = 0; i < 20; i++) {
writeRegister(MAX11300_PORT_CONFIG_BASE + i, 0x4300); // 0x4300 = DAC Mode
}
Serial.println("MAX11300 Configured: All pins set to DAC mode.");
}
// Function to write DAC values
void loop() {
for (uint8_t i = 0; i < 20; i++) {
uint16_t dacValue = (i * 2000) & 0xFFF; // Example: Incremental DAC values
writeRegister(MAX11300_DAC_DATA_BASE + i, dacValue);
Serial.print("DAC Pin ");
Serial.print(i);
Serial.print(" set to ");
Serial.println(dacValue);
delay(500);
}
}
// Function to write to MAX11300 registers
void writeRegister(uint8_t address, uint16_t value) {
uint16_t command = (address << 1) | 0x8000; // Format: [Address | Write bit]
digitalWrite(CS_PIN, LOW);
SPI.transfer16(command);
SPI.transfer16(value);
digitalWrite(CS_PIN, HIGH);
}
// Function to read from MAX11300 registers (optional)
uint16_t readRegister(uint8_t address) {
uint16_t command = (address << 1) & 0x7FFF; // Format: [Address | Read bit]
digitalWrite(CS_PIN, LOW);
SPI.transfer16(command);
uint16_t result = SPI.transfer16(0x0000);
digitalWrite(CS_PIN, HIGH);
return result;
}