Hello , i’m an new member.
I’m working on an energy metering application based on ATM90E32AS METERING IC and i’m working with a nucleo 64 board (F401RE) . I am trying to access ATM90E32AS’s registers but data returned are incoherent .
The communication between both devices is through SPI .
#include "mbed.h"
#include "ATM90E32AS.h"
SPI device(PA_7, PA_6, PA_5);
DigitalOut ssPin (PA_10);
DigitalOut PM0 (PA_8);
DigitalOut PM1 (PB_10);
Serial pc (SERIAL_TX,SERIAL_RX);
int main() {
int response = 0;
//Idle Mode
wait(1);
//Pass In Normal Mode
PM0 = 1;
PM1= 1;
device.format(16,2);
device.frequency(1000000);
while(1) {
ssPin = 0;
device.write(WRITE|0x69);// WRITE = 0x0000
device.write(0);
response = device.write(READ|0x69);//READ = 0x8000
ssPin = 1;
pc.printf ("0x%X / %d \n\r", response,response);
wait(1);
}
}
Here is the serial capture .
Best Regards