Hi there!
I am trying to play around with a CS5530 ADC board that I have made; I based my code on the library by Yasir Shahzad CS5530, I had to slightly modify the SPI configuration as I am using a 4809 with MegaCoreX which uses its own SPI library.
CS is not controlled by the library as it is tied to ground.
I am happy with how the system operates although I would like to fine-tune the settings to ensure that all the features of the chip are used correctly as well as using the right configurations.
I find myself in a bit of a struggle as I am very bad when it comes to registers and shifting therefore I would like to reach out to see if someone can help me.
By doing some tests I understood that calling CS5530.writeRegister(CMD_CONFIG_WRITE, *insert command*)
multiple times does not work so I have tried to set all the commands of what I assume is the same register in the same function, seems to be working but I am not entirely sure it is the correct way.
Configuration register information is at p. 19 of the datasheet.
What I intend to do to start with is to set the configuration register:
-
Continuous conversion
-
Unipolar Signal
-
VRS (Voltage Reference Select) to 1 with the option to alternate between 0 and 1 for testing purposes.
-
FRS (Filter Rate Select) to 1 with the option to alternate between 0 and 1 for testing purposes.
-
Set Word Rate (Speed).
-
Read the register back to make sure that all the settings have the right configurations, I have tried to use the
readRegister
function but I am getting a value that I am not able to comprehend.
My code is as follows (library attached):
#include "SPI.h"
#include "5530_ADC.h"
CS5530 CS5530(CS5530_DEFAULT_SPI_FREQUENCY);
void setup() {
CS5530.begin();
CS5530.reset();
CS5530.writeRegister(CMD_CONFIG_WRITE, WORD_RATE_6P25SPS | CS5530_UNIPOLAR | REG_CONFIG_VRS | REG_CONFIG_FRS);
CS5530.write8(CMD_CONVERSION_CONTINUOUS);
}
void loop() {
CS5530.getCount();
}
How wrong is to do as follows:
CS5530.writeRegister(CMD_CONFIG_WRITE, 0x00000000001010000001000001000000);
Setting each bit to 0 or 1 according to what setting I want?
Any help is greatly appreciated, anything you see that looks or is wrong please point it out so that I can fix it!
Library:
5530_ADC.cpp (2.0 KB)
5530_ADC.h (2.2 KB)