AnsweredAssumed Answered

Can't read any register on ADE7758 through SPI comunication with Arduino Mega

Question asked by Mutuca_42 on Apr 23, 2016
Latest reply on Jun 1, 2016 by dlath

I'm trying to read data from ADE7758 through SPI protocol in Arduino mega. I first tried read tempereture from register ( address 0x11) , but I only got 0 or random numbers like 255. I didn't try to write on regsiters yet. Any help on it would be gladly welcome!

Could anyone help me find what is wrong both in hardware and source code? thanks!

circuit.jpgpcb.jpg

#include "Arduino.h"

#include <SPI.h>

#include <avr/wdt.h>

 

 

// Configura Velocidade (clock), data order e data mode

SPISettings settingsA(2500000, MSBFIRST, SPI_MODE0);

SPISettings settingsB(2500000, MSBFIRST, SPI_MODE1);

 

 

int  Temperature;

 

 

void setup(){

 

 

  digitalWrite(SS, HIGH); //Impede uma falsa comunicação (disable comunication)

 

  // Configura os pinos da SPI

  pinMode(53, OUTPUT); //SS

  pinMode(51, OUTPUT); //MOSI

  pinMode(50, INPUT); // MISO

  pinMode(52, OUTPUT); //SCK

 

 

  //digitalWrite(SCK, LOW);

  //digitalWrite(MOSI, LOW);

 

 

Serial.begin(9600);

  Serial.println("ADE7758 Inicia");

    delay(1000);

   

SPI.begin();

   

  SPI.beginTransaction(settingsA);

 

}

 

 

void loop(){

 

 

digitalWrite(SS, LOW); // Habilita  a comunicação ( enable comunication)

  delay(30);

SPI.transfer16(0x11);

  delay(20);

  Temperature =  SPI.transfer(0);

Serial.println( Temperature, DEC);

delay(10);

SPI.endTransaction;

delay(1500);

 

 

}

Outcomes