I'm working on a school project where we want to monitor the energy consumption using the atmel M90e26s chip.
I used the mcp2210 library and wrote this little testscript:
void talk(hid_device* handle) {
ChipSettingsDef chipDef;
//set GPIO pins to be CS
chipDef = GetChipSettings(handle);
for (int i = 0; i < 9; i++) {
chipDef.GP[i].PinDesignation = GP_PIN_DESIGNATION_CS;
chipDef.GP[i].GPIODirection = GPIO_DIRECTION_OUTPUT;
chipDef.GP[i].GPIOOutput = 1;
}
int r = SetChipSettings(handle, chipDef);
//configure SPI
SPITransferSettingsDef def;
def = GetSPITransferSettings(handle);
//chip select is GP4
def.ActiveChipSelectValue = 0xffef;
def.IdleChipSelectValue = 0xffff;
def.BitRate = 50000l;
def.SPIMode = 4;
//enable write
byte spiCmdBuffer[3];
//read 8 bytes
def.BytesPerSPITransfer = 3;
r = SetSPITransferSettings(handle, def);
if (r != 0) {
printf("Errror setting SPI parameters.\n");
return;
}
spiCmdBuffer[0] = 0x01; //0000 0011 read
spiCmdBuffer[1] = 0x00; //address 0x00
SPIDataTransferStatusDef def1 = SPISendReceive(handle, spiCmdBuffer, 3);
for (int i = 0; i < 8; i++)
printf("%hhu\n", def1.DataReceived[i]);
}
Any address I try, I get no respons. The problem seems this:
spiCmdBuffer[0] = 0x01; //0000 0011 read
spiCmdBuffer[1] = 0x00; //address 0x00
I know from the datasheet that the spi interface looks like this: spi interface
Can somebody help me to find the address registers from the atm90e26? All the addresses look like '01H', but that is not hexadecimal and it's not 7 bit either.