Hi all,
I am using the following code to read the VERSIONR Register in Wiz5500 ethernet chip.
/* Dated: 4th April
*
* A sketch to read the VERSIONR Register using SPI in Arduino.
* Module is RTL8720 (BW16)
* Ameba Arduino SDK - 3.1.7
*
*/
#include <SPI.h>
#include "definitions.h"
#define SPI_MODE 'M'
SPISettings mySPI(1000000, MSBFIRST, 0);// SPI setup, 1 MHz clock speed
void setup() {
pinMode(9,OUTPUT); // CS/SS Pin See Section-2 of W5500 datasheet
pinMode(10,OUTPUT); // CLK Pin
pinMode(11,INPUT); // MISO Pin
pinMode(12,OUTPUT); // MOSI Pin
Serial.begin(115200);
Serial.println("VERSIONR Register Test!");
SPI.begin(9);
delay(1);
}
void loop() {
// **************** 3-Phase Data Transfer: Address, Control & Data Phases*******************
uint16_t address = SPI.transfer16(PA15, VERSIONR, SPI_CONTINUE); // First- Address Phase. See Section 2.2.1 of W5500 datasheet @ (https://docs.wiznet.io/Product/iEthernet/W5500/overview.
// For PHYCFGR, see lines 56-59 in "definitions.h"
uint8_t control = SPI.transfer(PA15, 0b00000000, SPI_CONTINUE);// Second- Control Phase. See Section 2.2.2 of datasheet
uint16_t reg_data = SPI.transfer(PA15, SPI_LAST);// Third: Data Phase. See Section 2.2.3 of datasheet.
//*****************************************************************************************
Serial.print("VERSIONR Address -- ");
Serial.println (VERSIONR, HEX);
Serial.print ("CONTROL -- ");
Serial.println (control);
Serial.print ("VERSIONR -- ");
Serial.println (reg_data);
Serial.println (); Serial.println ();
delay(1000);
}
I am only getting a ‘0’ in response.
What am I doing wrong?
Also please point out any superfluous/redundant code.
TIA and Regards
azhaque
PS:
uint16_t address = SPI.transfer16(PA15, VERSIONR, SPI_CONTINUE)
Should I replace SPI_CONTINUE with SPI_LAST?