Recently I have been working on getting the Maxim 13362 chip to work with the Arduino Mega. I'm not to sure what's going on, but every time I try to read the register of the Maxim chip, the value that gets returned is value that I sent. (which seems interesting considering sending a dummy byte will usually send u back the byte in that register.)
#include <SPI.h>
#define CS1 53
byte maximChip_1_Array [4];
void initializing(byte chipArray[], const int pinNum)
{
digitalWrite(pinNum, LOW);
chipArray [0] = SPI.transfer(0x00);
chipArray [1] = SPI.transfer(0x00);
chipArray [2] = SPI.transfer(0x00);
chipArray [3] = SPI.transfer(0x00);
digitalWrite(pinNum, HIGH);
}
void setup()
{
SPI.begin();
SPI.setBitOrder(MSBFIRST);
SPI.setDataMode(SPI_MODE1);
Serial.begin(9600);
SPI.setClockDivider(SPI_CLOCK_DIV4);
pinMode(CS1, OUTPUT);
void loop()
{
initializing(maximChip_1_Array, CS1);
///print out byte in each register
Serial.println("CHIP 1");
Serial.print(" Array 1 - C1: ");
Serial.println(maximChip_1_Array [0]);
Serial.print(" Array 2 - C1: ");
Serial.println(maximChip_1_Array [1]);
Serial.print(" Array 3 - C1: ");
Serial.println(maximChip_1_Array [2]);
Serial.print(" Array 4 - C1: ");
Serial.println(maximChip_1_Array [3]);
}