Teensy 4.1 and ATWINC1500 (can't connect to module)

JurMa1

Member
Hello everyone,
I am currently trying to connect to an adafruit ATWINC1500. However, I can not establish a connection with my Teensy (I tried multiple 4.1, also I tried it with a 3.2 and a 3.6) and I am running out of ideas, what could be the cause.
I am using Arduino 2.2.1 and I installed the Wifi101 Library (0.16.1).
Here is the current pinout I am running with:

pinout.png

However I also tried to wire the ATWINC1500 VIN to the 3.3 V Pin, as well as supplying it with an external power source (laboratory power supply). I wired EN with VIN (so that the chip is always on) and since that is the only chip on the SPI, I wired CS to GND, so that the Chip is always selected (https://cdn-learn.adafruit.com/downloads/pdf/adafruit-atwinc1500-wifi-module-breakout.pdf - page 6: SPI chip select, pull down when transmitting to/from the ATWINC).
I use the following code to check if the module is available:


Code:
#include <SPI.h>
#include <WiFi101.h>

const int8_t PIN_CS = 10;
const int8_t PIN_IRQ = 8;
const int8_t PIN_RST = 9;

int status = WL_IDLE_STATUS;     // the WiFi radio's status

void setup() { 
    Serial.begin(9600);
    while (!Serial) {
        ; // wait for serial port to connect. Needed for native USB port only
    }
    Serial.println("program started");
    // check for the presence of the shield:
    WiFi.setPins(PIN_CS, PIN_IRQ, PIN_RST );
    while (WiFi.status() == WL_NO_SHIELD) {
        Serial.println("WiFi shield not present");
        while(1);
        // don't continue:
        }

    Serial.println("connected!");
}

void loop() {
    ;
}

What really confuses me is, that it works with an Arduino UNO with the same pinout. With the Arduino I am even able to check for networks. I even tried to run it on SPI1 (changing SPI to SPI1 in nm_bus_wrapper_samd21.cpp) but I always get the same result, that the WiFi shield is not present.

Do you have any ideas, what I could check? Am I missing something here?

Thanks in advance
 
You haven't set the SPI frequency - the default is much higher on some Teensys - perhaps your interconnect can't handle fast logic signals?

Also you aren't connecting CS to pin 10 - could that be the issue?

Have you allowed enough time for the chip to reset before hammering it with requests?
 
I would follow what @MarkT was implying.

If it were me, I would try something like:
Code:
void setup() { 
    Serial.begin(9600);
    while (!Serial) {
        ; // wait for serial port to connect. Needed for native USB port only
    }
    Serial.println("program started");
    // check for the presence of the shield:
    delay(500);  // see if waiting a half second helps.

    WiFi.setPins(PIN_CS, PIN_IRQ, PIN_RST );
    while (WiFi.status() == WL_NO_SHIELD) {
...

Also not sure if this is really what you want?
Code:
    while (WiFi.status() == WL_NO_SHIELD) {
        Serial.println("WiFi shield not present");
        while(1);
        // don't continue:
    }
i.e. the while makes no sense as if the first try to WiFI.status() == WL_NO_SHIELD)
you loop for ever in the while(1) ;

Maybe try something like:
Code:
    uint8_t retry_count = 5;
    while (WiFi.status() == WL_NO_SHIELD) {
        Serial.println("WiFi shield not present");
        retry_count--;
        if (retry_count) delay(250); // wait a bit and try again
        else {
            while(1);
            // don't continue:
        }
    }

I assume that when you run from bench you have a common ground between bench, teensy and the device
 
Thanks for the replies

You haven't set the SPI frequency - the default is much higher on some Teensys - perhaps your interconnect can't handle fast logic signals?

As far as I understand, the Wifi101 library sets the for the Chip needed SPISettings here:
https://github.com/arduino-librarie.../bus_wrapper/source/nm_bus_wrapper_samd21.cpp

In line 73 the settings are defined
Code:
static const SPISettings wifi_SPISettings(12000000L, MSBFIRST, SPI_MODE0);
and they are set everytime before a transmit is done (line 92)
Code:
WINC1501_SPI.beginTransaction(wifi_SPISettings);

Also you aren't connecting CS to pin 10 - could that be the issue?
The shield is working on the arduino UNO, so I don't think that this should be an issue. CS is wired to GND, so that the shield is always selected. However, I will talk to my colleague, maybe we can wire it to test it.

Have you allowed enough time for the chip to reset before hammering it with requests?
I haven't tried a delay when the Teensy starts, but prior I had an delay(2000); instead of an while(1);. Tomorrow I will add an delay at the beginning of the program and see if anything happens.

Also not sure if this is really what you want?
The while loop is a remnant part. The code is copied from an example and the while-statement is originally an if-statement. I prior changed the while(1) with an delay(2000); to see, if the chip would initialize after some time - with no success

I assume that when you run from bench you have a common ground between bench, teensy and the device
If you mean the power supply with the bench than yes - I assured that the teensy, the shield and the power supply had a common ground.
 
Maybe post photos of your setup. It might help to see potential wiring issues and the like.
Things like bad solder joints, pins off by one. Pins not soldered to the Teensy. Maybe too long of wires, etc.

Also I would have tendency in cases like this, to edit the library sources and enable or add Serial outputs to try to localize down where the failure is happening.
 
Code:
static const SPISettings wifi_SPISettings(12000000L, MSBFIRST, SPI_MODE0);
Well the Uno cannot run SPI even that fast, so perhaps try something slower.
 
Back
Top