Skip to content

unable to connect ESp32 S3 using SPI to a TRF7970A (works on arduino) #8314

@marunlejo

Description

@marunlejo

Board

ESP32 S3

Device Description

UM Feather S3 board

Hardware Configuration

There will be multiple devices connected at the end but while testing the sensor, it is the only device connected using SPI lines, GPIO 10 for SS and, GPIO 7 for enable

Version

latest development Release Candidate (RC-X)

IDE Name

Arduino IDE

Operating System

Windows 11

Flash frequency

80Mhz

PSRAM enabled

yes

Upload speed

115200

Description

Using the Arduino IDE with ESP IDF I have try to communicate with a TRF7970. The commands seem to go out of the microcontroller but the sensor does not respond to it. Also I am unable to read commands back. this is only happening with this sensor. I can use the same microcontroller with other devices. The TRF7970 sensor is in good condition since I can control it with two other microcontrollers (the MSP430 and the Arduino UNO) I tried multiple SPI configurations but nothing has work so far for the ESP. the sketch example is only trying to read the values of some of the registers after sending a reset to the TRF7970A

Sketch

#include <Arduino.h>
#include <SPI.h>

#define TRF_ENABLE 6
#define TRF_CS 10

void setup() {
  Serial.begin(9600);

  Serial.println("starting");

  pinMode(TRF_ENABLE, OUTPUT);
	pinMode(TRF_CS, OUTPUT);

  digitalWrite(TRF_CS, HIGH);
  delay(4); //required delay between CS and enable pin only once
	digitalWrite(TRF_ENABLE, HIGH);
  delay(5);

  SPI.setDataMode(SPI_MODE1);
	SPI.setBitOrder(MSBFIRST);
  SPI.begin();

  delay(5);

  SPI_directCommand(0x03);  // soft init
	SPI_directCommand(0x00);  // idle
  delay(1);
  SPI_directCommand(0x0F);
  Serial.println("after rst");
}

void loop() {
  while(1){
    SPI_directCommand(0x03);  // soft init
    SPI_directCommand(0x00);  // idle

    Serial.print("ISO control: ");
    Serial.println(SPI_readReg(0x41));
    delay(1000);

    Serial.print("Chip status control: ");
    Serial.println(SPI_readReg(0x40));
    delay(1000);

    Serial.print("RSSI levels and oscillator status: ");
    Serial.println(SPI_readReg(0x4F));
    delay(1000);
  }
}

void SPI_directCommand(uint8_t ui8Command)
{	
	digitalWrite(TRF_CS, LOW); 						// Start SPI Mode

	// set Address/Command Word Bit Distribution to command
	ui8Command = (0x80 | ui8Command);					// command
	ui8Command = (0x9f & ui8Command);					// command code

	SPI.transfer(ui8Command);

	digitalWrite(TRF_CS, HIGH);  						//Stop SPI Mode
}

//-------------------------------------------------------

uint8_t SPI_readReg(uint8_t reg)
{
  uint8_t received;
	digitalWrite(TRF_CS, LOW);	 					// Start SPI Mode

	SPI.transfer(reg);
	received = SPI.transfer(0);

	digitalWrite(TRF_CS, HIGH); 						// Stop SPI Mode
  return received;
}

Debug Message

On ESP32 S3:
ISO control: 0
Chip status control: 0
RSSI levels and oscillator status: 0

on arduino uno:
ISO control: 33
Chip status control: 1
RSSI levels and oscillator status: 64

Other Steps to Reproduce

the program communicate correctly on Arduino uno and the MSP430. the sensor receive the commands correctly and responds back in these two.
I have also try to change the esp32 in case that the one I am using has any kind of problem but none of the other ones connect to the sensor correctly

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions