WIZ820i/Teensy31 and MicroSD Card Adapter

Status
Not open for further replies.

jpatrick62

Well-known member
Has anyone used the adapter with Teensy 3.1 and WIZ820io? Specifically, I was wondering about the electrical connections. The adapter looks like a great idea for
a smaller form factor. Currently, I power my board off the USB input to the Teensy 3.1, and then use pin 28 (5 VDC) as an input to a NTE 1904 5-3.3 regulator. I then
use the 3.3VDC side of the regulator to supply the WIZ820io. The Electrical Connections table of the adapter shows the adapter's Wiz820 and Teensy 3.1. connections, and it looks
as if the WIZ820 3.3 VDC inputs are not connected to the Teensy 3.1, but I cannot be sure. I need to use the external regulator to supply enough current for the WIZ820io.

As a secondary question, it looks from the photo that the adapter's physical pinout aligns with Teensy 3.1 pins 19-24 and 1-6 on the other side. I ask this because I am trying to get the PCB done in PCB express.
 
So I can basically tie Teensy 3.1. pin 9 Reset pin to a reset button

No, do not connect a button or anything else to pin 9.

The adaptor board connects pin 9 to the reset pin on the WIZ820io module. The Ethernet library will automatically pulse pin 9 as needed to reset the W5200 chip on the WIZ820io.

This is NOT meant for you to manually reset anything. It's for the Ethernet library to be able to reset the W5200 chip. This needs to be done to reliably establish communication if the chip has previously received clock pulses. The Ethernet library will automatically take control of pin 9 if necessary. You should not connect a button or anything else, since you'll only cause conflicts with the signal the Ethernet library creates to control the chip.
 
If you just want the PCB, it's available here as a shared design on OSH Park.

http://www.oshpark.com/shared_projects/LOt9A5hs

You could also order one from PJRC, probably for less than getting it fab'd.

If you're creating your own board, great. Just follow the wiring described. You might also get one of the real boards. They're only $6. Being able to look at the real thing and probe it with an ohm-meter might make a lot of these details clearer for you.
 
Thanks Paul. So if the Ethernet library handles the reset, then all I need is the 16X2 LCD screen and a PCB that houses Teensy 3.1/PRJC Adapter/WIZ 820io and the few pinouts I need for GPIO for the Teensy for some measurement circuitry. Wow - thanks for the help!
 
Paul, I have run into an issue using the Wiz820 SD adapter with Teensy 3.1 and the Wiz820io. I basically start the sketch by reading the contents of the SD card and then use that information to connect to a server indicated by a file on the SD card. In about 40% of the cases, the SD card will not initialize. If I swap out Wiz820io network controllers, it starts to work. Curiously, the same network adapters seem to work, while other 40% of the adapters will see the SD card read fail. I have tried to initialize the SPI
slave select lines to HIGH prior to enabling either SPI device being enabled, and I carefully set the CS line to LOW to enable each and HIGH to disable them. My OScope shows the CS line going low when the SD card is being activated, but for the 40% or so Wiznet network controllers, when connected, the SD card read fails. The Wiznet adapter and actual SD card are constant in this, so they obviously work, but only when certain 820io network adapters are used in conjunction.
 
This is the sketch from the test I have been running. We are using the Teensy 3.1/SD Card Adapter/WizNet 820io ethernet controller combos an about 60% of the combos work fine. The Wiznet adapters (820io) seem to be the critical piece to this. If I take a 820io ethernet controller from a combo that works and place it on the combo the does not work, the failed combo starts working. If I take a Wiznet 820io controller from a combo that fails to read the SD card and swap it out with a 820io controller that does work, that combo will fail to work as well. So the 820io network adapter seems to be the issue...



#include <SPI.h>
#include <Ethernet.h>
#include <Dns.h>
#include <SD.h>
#include <mac.h>

// ------ LCD ----
const int ADDRESS_BUFFER = 25;
const int SCRATCH_BUFFER = 25;
const int MAX_RES = 15;
const int LCD_NOTE_A = 220;
const int LCD_BACKLIGHT_ON = 17;
const int LCD_CLEAR = 12;
const int LCD_LF = 10;
//--------Network ---------
DNSClient dnsClient;
bool bNetworkAvailable = false;

struct address_struct
{
char szMacAddress[ADDRESS_BUFFER] = {0}; // MAC Address String
char szLcdMacAddress[ADDRESS_BUFFER]={0}; // MAC Address on LCD (no '-' chars...
char szIpAddress[ADDRESS_BUFFER]={0}; // Ip Address String
char szDnsAddress[ADDRESS_BUFFER]={0}; // DNS Address String
char szGatewayAddress[ADDRESS_BUFFER]={0}; // Default Gateway Address String
char szWebServiceAddress[ADDRESS_BUFFER]={0}; // Web Service Address
};

//--------address struct------
address_struct address;

//---------- Buffers -----------
char szHostName[SCRATCH_BUFFER]={0}; // buffer for IP host name
char szLine1[MAX_RES]={0};
char szLine2[MAX_RES]={0};
//---------- SD card stuff--------
bool bCardRead = false;
//-------- SPI Control -----
const int CS_ETHERNET = 10;
const int CS_SDCARD = 4;
/////////////////////////////// Setup /////////////////////

void setup()
{
Serial3.begin(9600);
pinMode(4, INPUT_PULLUP);
pinMode(10, INPUT_PULLUP);
LCD_Display("Initializing", "Please wait");
delay(1000);

bCardRead = TestCardAccess();
if(bCardRead == true)
{
Serial.println("Card Reader OK");
}
else
{
//Failure to read the configuration card
LCD_Display("SD Card Read", "-FAILED-");
Serial3.write(LCD_NOTE_A);
Serial3.write(LCD_NOTE_A);
exit(1);
}

Serial3.write(LCD_BACKLIGHT_ON);
LCD_Display("Test", "Ready");

//Use DHCP if possible

bNetworkAvailable=MakeDHCPRequest(true);
if(bNetworkAvailable == true)
{
// print the Ethernet board/shield's IP address:-
LCD_Display("IP Address:", address.szIpAddress);
}
else
{
LCD_Display("DHCP Request", "-FAILED-");
}
}
///////////////////////////// The main loop ////////////////////////////
void loop()
{

delay(5000);
Serial.println("Testing");
}
/*------------------------------------------------------------------
LCD_Display
Display contents of a buffer on the 16x2 LCD grid. The first line
is used to identify Lenox Laser's controller, while the 2nd line
can be used for custom display.
IN: pointer to a char buffer for line 1 (16 chars max)
IN: pointer to a char buffer for line 2 (16 chars max)
Returns: void
------------------------------------------------------------------*/
void LCD_Display(char* szLine1, char* szLine2)
{
Serial3.write(LCD_CLEAR);
if(szLine1)
{
Serial3.println(szLine1);
}
if(szLine2)
{
Serial3.write(LCD_LF);
Serial3.println(szLine2);
}
Serial3.write(LCD_NOTE_A
}
/*------------------------------------------------------------------
TestCardAccess
This function updates a value on the SDCard
Returns: void
------------------------------------------------------------------*/
bool TestCardAccess()
{
bool bCardRead = false;

if (!SD.begin(CS_SDCARD))
{
Serial.println("A SD Card was not found...");
}
else
{
Serial.println("A SD Card was successfully initialized...");
}

return bCardRead;
}
/*---------------------------------------------------------------
MakeDHCPRequest()

Attempts a DHCP request for network connectivity.

IN: bLCD - Boolean to indicate whether to display the network
initialization attempt.
Returns: Boolean result
---------------------------------------------------------------*/
bool MakeDHCPRequest(bool bLCD)
{
if(bLCD == true)
{
LCD_Display("Initializing", "Network...");
}
Serial.println("Getting address information, please wait...");

if (Ethernet.begin(GetFirmwareMAC()))
{
Serial3.write(LCD_NOTE_A);
dnsClient.begin(Ethernet.dnsServerIP());
return true;
}
else
{
Serial.println("Failed to get address from DHCP server");
Serial3.write(LCD_CLEAR);
Serial3.println("Address FAIL!");
Serial3.write(LCD_NOTE_A);
return false;
}
}
/*------------------------------------------------------------------
GetFirmwareMAC
Reads the firmware MAC burned into teensy 3.0+. Needs the mac.h
header...
IN: void
Returns: a pointer to a SRAM byte buffer that can be used by the
Ethernet object's begin() method.
-----------------------------------------------------------------*/
byte* GetFirmwareMAC()
{
read_mac();
sprintf(address.szMacAddress, "%02x-%02x-%02x-%02x-%02x-%02x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
sprintf(address.szLcdMacAddress, "%02x%02x%02x%02x%02x%02x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
sprintf(szHostName, "WIZnet0%01x%02x%02x", mac[3], mac[4], mac[5]);
return mac;
}
 
Thanks!
It would be even better if you could edit your post and put code tags around your code. That can be achieved by editing your post, highlighting the code and clicking on the hash tag "#" in the "Go Advanced" editing options.
 
Thanks!
It would be even better if you could edit your post and put code tags around your code. That can be achieved by editing your post, highlighting the code and clicking on the hash tag "#" in the "Go Advanced" editing options.[/QUOT

Ok, let me try this again :)

This is the sketch from the test I have been running. We are using the Teensy 3.1/SD Card Adapter/WizNet 820io ethernet controller combos an about 60% of the combos work fine. The Wiznet adapters (820io) seem to be the critical piece to this. If I take a 820io ethernet controller from a combo that works and place it on the combo the does not work, the failed combo starts working. If I take a Wiznet 820io controller from a combo that fails to read the SD card and swap it out with a 820io controller that does work, that combo will fail to work as well. So the 820io network adapter seems to be the issue,since by swapping them out I can get this thing to work.



Code:
 #include <SPI.h>
    #include <Ethernet.h>
    #include <Dns.h>
    #include <SD.h>
    #include <mac.h>

    // ------ LCD ----
    const int ADDRESS_BUFFER = 25;
    const int SCRATCH_BUFFER = 25;
    const int MAX_RES = 15;
    const int LCD_NOTE_A = 220;
    const int LCD_BACKLIGHT_ON = 17;
    const int LCD_CLEAR = 12;
    const int LCD_LF = 10;
    //--------Network ---------
    DNSClient dnsClient;
    bool bNetworkAvailable = false;

    struct address_struct
    {
    char szMacAddress[ADDRESS_BUFFER] = {0}; // MAC Address String
    char szLcdMacAddress[ADDRESS_BUFFER]={0}; // MAC Address on LCD (no '-' chars...
    char szIpAddress[ADDRESS_BUFFER]={0}; // Ip Address String
    char szDnsAddress[ADDRESS_BUFFER]={0}; // DNS Address String
    char szGatewayAddress[ADDRESS_BUFFER]={0}; // Default Gateway Address String
    char szWebServiceAddress[ADDRESS_BUFFER]={0}; // Web Service Address
    };

    //--------address struct------
    address_struct address;

    //---------- Buffers -----------
    char szHostName[SCRATCH_BUFFER]={0}; // buffer for IP host name
    char szLine1[MAX_RES]={0};
    char szLine2[MAX_RES]={0};
    //---------- SD card stuff--------
    bool bCardRead = false;
    //-------- SPI Control -----
    const int CS_ETHERNET = 10;
    const int CS_SDCARD = 4;
    /////////////////////////////// Setup /////////////////////

    void setup()
    {
    Serial3.begin(9600);
    pinMode(4, INPUT_PULLUP);
    pinMode(10, INPUT_PULLUP);
    LCD_Display("Initializing", "Please wait");
    delay(1000);

    bCardRead = TestCardAccess();
    if(bCardRead == true)
    {
    Serial.println("Card Reader OK");
    }
    else
    {
    //Failure to read the configuration card
    LCD_Display("SD Card Read", "-FAILED-");
    Serial3.write(LCD_NOTE_A);
    Serial3.write(LCD_NOTE_A);
    exit(1);
    }

    Serial3.write(LCD_BACKLIGHT_ON);
    LCD_Display("Test", "Ready");

    //Use DHCP if possible

    bNetworkAvailable=MakeDHCPRequest(true);
    if(bNetworkAvailable == true)
    {
    // print the Ethernet board/shield's IP address:-
    LCD_Display("IP Address:", address.szIpAddress);
    }
    else
    {
    LCD_Display("DHCP Request", "-FAILED-");
    }
    }
    ///////////////////////////// The main loop ////////////////////////////
    void loop()
    {

    delay(5000);
    Serial.println("Testing");
    }
    /*------------------------------------------------------------------
    LCD_Display
    Display contents of a buffer on the 16x2 LCD grid. The first line
    is used to identify Lenox Laser's controller, while the 2nd line
    can be used for custom display.
    IN: pointer to a char buffer for line 1 (16 chars max)
    IN: pointer to a char buffer for line 2 (16 chars max)
    Returns: void
    ------------------------------------------------------------------*/
    void LCD_Display(char* szLine1, char* szLine2)
    {
    Serial3.write(LCD_CLEAR);
    if(szLine1)
    {
    Serial3.println(szLine1);
    }
    if(szLine2)
    {
    Serial3.write(LCD_LF);
    Serial3.println(szLine2);
    }
    Serial3.write(LCD_NOTE_A
    }
    /*------------------------------------------------------------------
    TestCardAccess
    This function updates a value on the SDCard
    Returns: void
    ------------------------------------------------------------------*/
    bool TestCardAccess()
    {
    bool bCardRead = false;

    if (!SD.begin(CS_SDCARD))
    {
    Serial.println("A SD Card was not found...");
    }
    else
    {
    Serial.println("A SD Card was successfully initialized...");
    }

    return bCardRead;
    }
    /*---------------------------------------------------------------
    MakeDHCPRequest()

    Attempts a DHCP request for network connectivity.

    IN: bLCD - Boolean to indicate whether to display the network
    initialization attempt.
    Returns: Boolean result
    ---------------------------------------------------------------*/
    bool MakeDHCPRequest(bool bLCD)
    {
    if(bLCD == true)
    {
    LCD_Display("Initializing", "Network...");
    }
    Serial.println("Getting address information, please wait...");

    if (Ethernet.begin(GetFirmwareMAC()))
    {
    Serial3.write(LCD_NOTE_A);
    dnsClient.begin(Ethernet.dnsServerIP());
    return true;
    }
    else
    {
    Serial.println("Failed to get address from DHCP server");
    Serial3.write(LCD_CLEAR);
    Serial3.println("Address FAIL!");
    Serial3.write(LCD_NOTE_A);
    return false;
    }
    }
    /*------------------------------------------------------------------
    GetFirmwareMAC
    Reads the firmware MAC burned into teensy 3.0+. Needs the mac.h
    header...
    IN: void
    Returns: a pointer to a SRAM byte buffer that can be used by the
    Ethernet object's begin() method.
    -----------------------------------------------------------------*/
    byte* GetFirmwareMAC()
    {
    read_mac();
    sprintf(address.szMacAddress, "%02x-%02x-%02x-%02x-%02x-%02x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
    sprintf(address.szLcdMacAddress, "%02x%02x%02x%02x%02x%02x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
    sprintf(szHostName, "WIZnet0%01x%02x%02x", mac[3], mac[4], mac[5]);
    return mac;
    } 

Reply With Quote Reply With Quote
 
Status
Not open for further replies.
Back
Top