supermedia_art
Member
Hello,
The following program hangs. It first detects the SDcard, the starts the network, but then as soon as I do anything with SD, it hangs. The only difference between my schematic and the WIZ820io & Micro SD Card Adaptor, is that I am using pin 3 and 4 as CS pins and toggling the reset pin in code. I really dont know how to debug this any further.
The following program hangs. It first detects the SDcard, the starts the network, but then as soon as I do anything with SD, it hangs. The only difference between my schematic and the WIZ820io & Micro SD Card Adaptor, is that I am using pin 3 and 4 as CS pins and toggling the reset pin in code. I really dont know how to debug this any further.
Code:
// All the pins
#define RX1_PIN 0
#define TX1_PIN 1
#define DATA_1_PIN 2
#define SDCARD_CS_PIN 3
#define WIZNET_CS_PIN 4
#define DATA_8_PIN 5
#define DATA_5_PIN 6
#define DATA_3_PIN 7
#define DATA_4_PIN 8
#define RX2_PIN 9
#define TX2_PIN 10
#define SPI_DOUT_PIN 11
#define SPI_DIN_PIN 12
#define SPI_CLK_PIN 13
#define DATA_2_PIN 14
#define POT1_PIN 15
#define POT2_PIN 16
#define BUTTON_PIN 17
#define I2C_SDA_PIN 18
#define I2C_SCL_PIN 19
#define DATA_6_PIN 20
#define DATA_7_PIN 21
#define STATUS_LED_PIN 22
#define WIZNET_RESET_PIN 23
#include "SPI.h"
#include "Ethernet.h"
#include "TeensyID.h"
#include "SD.h"
uint8_t mac[6];
void setup(){
Serial.begin(115200);
delay(100);
Serial.println("hi");
pinMode(STATUS_LED_PIN, OUTPUT);
pinMode(WIZNET_RESET_PIN, OUTPUT);
digitalWrite(WIZNET_RESET_PIN, LOW); // begin reset the WIZ820io
pinMode(WIZNET_CS_PIN, OUTPUT);
digitalWrite(WIZNET_CS_PIN, HIGH); // de-select WIZ820io
pinMode(SDCARD_CS_PIN, OUTPUT);
digitalWrite(SDCARD_CS_PIN, HIGH); // de-select the SD Card
digitalWrite(WIZNET_RESET_PIN, HIGH);
digitalWrite(WIZNET_CS_PIN, LOW);
if(SD.begin(SDCARD_CS_PIN)){
Serial.println("sd detected");
}
else {
Serial.println("no SD");
}
Ethernet.init(WIZNET_CS_PIN);
IPAddress ipAddress;
ipAddress.fromString("10.0.0.42");
teensyMAC(mac);
Ethernet.begin(mac, ipAddress);
// this line will make it crash
File _file = SD.open("config.jso", FILE_READ);
}
void loop(){
digitalWrite(STATUS_LED_PIN, millis()%200 < 20);
}