Caltex SD Adapter and 23LC1024

Status
Not open for further replies.

vangalvin

Member
Still waiting for my audio adapter to arrive, Shipping down to this part of the planet is a little slow so it looks like its still about 3 weeks away.
In the interim I have hooked up a Calted SD card adapter and that seems to be working well and wired in the 23LC1024 however before using it I wanted to check to see if the 23LC1024 was actually working before setting up the delayEXT.

The CF is working a treat however I do not seem to be able to initialise the 23LC1024.

All I am getting is Unable to access SPI Flash chip.


Wiring is prety simple
23LC1024
Pin1 - 10K resistor from to 3.3v (CS)
Pin2 - Teensy pin 7 (MOSI)
Pin3 - 3.3V
Pin4 - gnd
Pin5 - Teensy pin 12 (MISO)
Pin6 - Teensy pin 14 (SCK)
Pin7 - 3.3v
Pin8 - 3.3v

The code.

Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>


#define SDCARD_CS_PIN    10   // CS on Caltex Card
#define SDCARD_MOSI_PIN  7   //MOSI on Caltex Card
#define SDCARD_MISO_PIN  12   //MISO on Caltex Card
#define SDCARD_SCK_PIN   14   //SCK on caltex card


#define SPIRAM_CS_PIN    6      //23LC1024 pin 1
#define SPIRAM_MOSI_PIN  7   //23LC1024 pin 5
#define SPIRAM_MISO_PIN  12   //23LC1024 pin 2
#define SPIRAM_SCK_PIN   14   //23LC1024 pin 6


void setup() {
  Serial.begin(115200);
    AudioMemory(20);
    Sd2Card card;
    boolean status;
  
  // Configure SPI
  SPI.setMOSI(SDCARD_MOSI_PIN);
  SPI.setSCK(SDCARD_SCK_PIN);
  SPI.setMISO(SDCARD_MISO_PIN);


  // Now open the SD card normally
  status = SD.begin(SDCARD_CS_PIN);
  if (status) {
    Serial.println(F("SD library is able to access the filesystem"));
  } else {
    Serial.println(F("SD library can not access the filesystem!"));
  }


  // First, detect the card
  status = card.init(SPI_FULL_SPEED, SDCARD_CS_PIN);
  if (status) {
    Serial.println("SD card is connected :-)");
  } else {
    Serial.println("SD card is not connected or unusable :-(");
    return;
  }


  if (!SerialFlash.begin(SPIRAM_CS_PIN)) {
    while (1) {
      Serial.println("Unable to access SPI Flash chip");
      delay(1000);
    }
  }
  
}


void loop() {


}
 
HA, I think i found the issue....
The Caltex board is a 5V board. Although it is supposed to be 3.3V compliant and have a level converter it looks like if you try and run it with the 23LC1024 on the same SPI lines it will not work. I removed the board and the SRAM is working a treat. Add the board and it stops working. I do need to double check that the CS line is not causing an issue as if both devices are trying to read/write on the line at the same time then this could also be a problem.

 
I'd try setting both CS pins to OUTPUT mode and use digitalWrite to HIGH, as the very first lines in setup(), so the pins are at 3.3V before you do anything on the SPI pins. Or you could add real pullup resistors on both pins.

Could also be hardware related. I tried a quick search for "caltex sd adapter" and found youtube videos, but not a page with a schematic or other tech info on this product.

We default to using 24 MHz for the SPI to these memory devices. That usually works fine with direct wires, and it works well with level shifters using fast logic chips, like 74LCX125. But use of only resistors, or the mosfet+resistors circuit, or old logic chips like CD4050 are usually too slow for 24 MHz.
 
I'd try setting both CS pins to OUTPUT mode and use digitalWrite to HIGH, as the very first lines in setup(), so the pins are at 3.3V before you do anything on the SPI pins. Or you could add real pullup resistors on both pins.

Could also be hardware related. I tried a quick search for "caltex sd adapter" and found youtube videos, but not a page with a schematic or other tech info on this product.

We default to using 24 MHz for the SPI to these memory devices. That usually works fine with direct wires, and it works well with level shifters using fast logic chips, like 74LCX125. But use of only resistors, or the mosfet+resistors circuit, or old logic chips like CD4050 are usually too slow for 24 MHz.


I have added a pull-up on the SRAM and ended up hard wiring a MicroSD adapter similar to this as well as added the pullup on the CS pin.
SD+Card004.jpg

now the ram is working OK but the CF is not. I will go back to the Caltex card and see if adding a pullup on the CS pin helps.

hehe, Super stoked with the DelayEXT example. the frequency you set for the test ping and echo really carries a long way, My workshop is out in the garage detached form the house and my son just came in to complain about the PING noise .. Bwahahaha.
 
Neither option seemed to work.
The Caltex card is using an LCV125A.

I wonder if the regulator could be causing an issue. the version board I have has not way to bypass it with a jumper/pads. I guess i could just short the in/out pins to bypass it.


Catalex-mSD-Card-Module_SCH.jpg
 
That looks like it ought to work, if you just power it from 5V.

Yes, that's what I thought. Must be something else going on somewhere possibly in my test code.

I have tried the 5V rail and jumpered the regulator so it will run on 3.3V direct.

I have altered the test code to use the delayExt much like in your example, when doing so with the power going to the CF I get no delay at all and only the original pass through ping. Remove the jumper going to the caltex board and I get a delay.

interestingly with the delay code I also get a warning "SD card is not connected or unusable :-("

So either my code is not working correctly or there is some weird conflict going.
 
The issue seems to be with the MISO connection, it seems as if the Caltex adapter is holding the MISO line at 3.3V when its not in use.
 
Well it would appear that the issue is Hardware and not software. If i pull the MISO link to the CF the sram works. connect the MISO to the CF and it stops working.
I have it all running on 3.3V just to be sure there are not issues with the voltage.

CS on the CF is sitting at 3.3V with no drops
CS on the SRAM is sitting at 3.26V and drops to 0.01V then accessing the SRAM

MISO when the CF is connected I get peaks of 0.02v
With MSIO to the CF removed I get peaks of 3.01V

It would seem that the circuit on the Caltex is pulling the MISO line LOW all the time when its connected and this is what is causing the problem.

Although i cant see why they would I am starting to wonder if they have not added a pulldown resistor to the MISO pin on the Caltex board.
 
FIXED!!!! Well it turns out that there is a fix!!!! and it works a treat.
Kind of stunned I managed to do this with my beast soldering iron that has a tip measuring about 2mm in diamiter :) but its still not the most insane surface mount alteration I have done to date.

List the leg of Pin 13 of the LCV125A. it is currently tied to ground and that will cause issues with any other device trying to communicate with the SPI.
Run a wire from pin 13 to R3 (the side that connects to the CS pin and install a 10K pull up resistor between the CS pin and the 3.3V line.

Presto! MISO ends up in a high Z state until you pull the CS low :)

I stick a dab is superglue on the wire to stick it to the top of the LCV125A and make sure it will not wiggle and break off the floating pin.

IMG_0208[1].jpg
 
@PaulStoffregen would I have been better off running two SPI's one for the CF and the other for RAM? especially if i am going to be recording and playing audio using the SD and passing it through a delayEXT. am i likely to set myself up for problems or performance issues?

Also is there a way with delayEXT to add several 23LC1024's without having to use a buffer chip? I had a look around and it appears that people are either just using one or using a specific board that has a buffer IC?
 
Status
Not open for further replies.
Back
Top