Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8051

Compute Module • Re: Issue with WiringPi SPI and MAX5144 DAC on Raspberry Pi CM4(SPI1, CS1)

$
0
0
Hi,

WiringPi CM4 SPI support is very new and the hardware is not included in the unit tests yet, so bugs may still be present.

What I don't understand is, have you tried to replace wiringPiSPISetupMode with wiringPiSPIxSetupMode? The error message suggests you should do that.

The SPI channel is not SPI1; it's SPI0 CE/CS1! The old version 2.x could only access SPI0.

With wiringPiSPIxSetupMode, you can access SPI1 CS1:

Code:

wiringPiSPIxSetupMode(1, 1, 500000, 0);
Steps to Debug the Issue
Verify wiringPiSPIxSetupMode Usage
Ensure you replaced wiringPiSPISetupMode in your MAX5144.cpp file with:

Code:

if (wiringPiSPIxSetupMode(spiChannel, 1, 500000, 0) < 0) {    throw std::runtime_error("SPI initialization failed!");}
The second parameter (1) is the SPI bus (SPI1), and this is critical for CM4.

Clean and Rebuild Again
Run the following commands to ensure no residual files are causing issues:

bash
Copy code
rm -rf build
mkdir build
cd build
cmake ..
make
Image_20250115142721.png

Statistics: Posted by dgy411852 — Wed Jan 15, 2025 10:28 pm



Viewing all articles
Browse latest Browse all 8051

Trending Articles