SPI chip that works find on a Uno but will not work with teensy 3.6

Status
Not open for further replies.

owhite

Active member
SPI chip works fine on a Uno but will not work with teensy 3.6

People

I could use some help. I designed a circuit board to drive motors using the teensy 3.6. I've been very happy with the teensies and use them to drive brushless gimbal motors for my robots: example.

So I designed another PCB to drive motors similar to the video but in this case I wanted to use the AMS AS5048A position sensor.
AS5048A brochure and datasheet.

This chip is 3.2v, uses SPI, and seems to be used quite commonly for this application. I have bought several modules from mouser.

There is a PWM out signal on the module that varies with position of a magnet. The module is also supposed to report the position via SPI. This works on the an Uno. When the module is connected to the teensy, the PWM out on the module still works - SPI does not. Indicating the chip is powered, and is reading the position properly, but communications seem to be broken.

The code is at this github repo.
The circuit is here
Board layout is here

The code engages in good SPI hygiene by opening and closing the connection with:

SPI.beginTransaction(settings);
//Send the command
digitalWrite(_cs, LOW);
SPI.transfer(left_byte);
SPI.transfer(right_byte);
digitalWrite(_cs,HIGH);

//Now read the response
digitalWrite(_cs, LOW);
left_byte = SPI.transfer(0x00);
right_byte = SPI.transfer(0x00);
digitalWrite(_cs, HIGH);

//SPI - end transaction
SPI.endTransaction();

Ths max serial clock period on the AS5048A is 100 ns.

I am using the following pins on the teensy 3.6
  • SCK 13
  • MISO 12
  • MOSI 11
  • CS 25
Pin behavior on the scope:
  • SCK - Sporadic spikes highly, normally low
  • MOSI - Sporadic spikes low, normally high
  • MISO - Remains low
  • CS - Sporadic spikes low, normally high
Other debugging items:
  • Nothing else is on the SPI bus.
  • Yes, I have checked all my connections a million times.
  • No, I dont have a digital logic analyzer
Please offer suggestions for things I could do to debug this thing either in software or hardware.

Please help this monster come alive.
 
Last edited:
Might help to know how they are actually wired? Looks like the devices have 8 pins, but your encoder connections have 6? I am assuming you just wire both the 3.3v and 5v to each other to the unit, like the wiring diagrams show in pdf? How long are the wires? ...

Also did you try just trying one unit wired to it?

Also would try adding one or more Pull up resistors to the SPI setup. Probably for sure on MISO pin, maybe SCK as well?

Search forum, to see if any other hints, like: https://forum.pjrc.com/threads/3588...encoder?p=112138&highlight=as5048a#post112138

Maybe try adding in some delays? With the code:
Code:
SPI.beginTransaction(settings);
//Send the command
digitalWrite(_cs, LOW);
SPI.transfer(left_byte);
SPI.transfer(right_byte);
digitalWrite(_cs,HIGH);

//Now read the response
digitalWrite(_cs, LOW);
left_byte = SPI.transfer(0x00);
right_byte = SPI.transfer(0x00);
digitalWrite(_cs, HIGH);

//SPI - end transaction
SPI.endTransaction();
Maybe add something like: delayMicrosoconds(5);
After setting the cs LOW?

Maybe try slower SPI Clock speed. It says a minimum of 50+50ns for the clock but maybe nto working properly... Maybe try something like 8mhz...

Again just doing shotgun answer hopefully something hits...
 
Thanks. I just discovered that before coming back to the forum - one of your suggestions is correct - the transition from the send to the read is too short. Adding a delayMicroseconds() did the trick. Thanks much.
 
Ok, I‘ll clean that up...

Edit: Done. @Paul: if you‘ll need a short break from T4, you might perhaps consider processing the long, long ip blocklist...
 
Ha... I need to get *back* to working on T4. Have really fallen behind the last couple weeks with this damn cold. :(

But yeah, seems spammers are getting back in lately. Will try to get to the IP list next weekend. Doing it in a hurry isn't effective, since the real long-term benefit comes from spending time really looking at patters in the geolocation info and ASN ownership.
 
Status
Not open for further replies.
Back
Top