Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
brandiware
Level 4
Level 4
First like given 25 sign-ins 5 solutions authored

Hello Community,

there are several differing statements about the limits of the emFile component. Does anyone have an up to date

definitive answer what the maximum card size is for the current emFile component and libraries (as downloaded from the component website) ?

And second question: has anyone lately succeeded in using a micro SD breakout SPI board with emFile or any other solution ? If yes, pls send me a link to the product that you used. I am having trouble in particular with the breakouts from China.

 

Thanks

Stefan

0 Likes
1 Solution

Yes, you can change from CMOS to LVTTL by writing to the appropriate Port Control register.  Be aware that this change affects the entire port, not just 1 port pin on that port group.

Let's work with Port 0 since that's where you have your hardware connected.

From the 5LP Registers TRM:
PRT0_CTL: 0x40005109 address
vtrip_sel = VTRIP_LVTTL is the bit we want to  change

So, read PRT0_CTL and set the bit in vtrip_sel to VTRIP_LVTTL.

If you read this register using the Debugger and your current code, you'll see that the LSB is cleared to 0 representing CMOS level.  When you set the LSB to 1 (value of VTRIP_LVTTL), it's now at LVTTL level.  You can set this bit using the Debugger and test your hardware.

In software, you'll need to do this after the hardware has been configured for SPI function.  If you make the change too early, the SPI Start (inside emFile) could set it back to CMOS.  To be honest, I don't know exactly when the port is configured.  I assume it's when SPI is invoked but it could be much earlier as the 5LP is booting up.

Let us know how it goes.

View solution in original post

0 Likes
15 Replies
LeoMathews
Moderator
Moderator
Moderator
First question asked 500 replies posted 100 solutions authored

Hi @brandiware 

From the file system documentation, it is mentioned that: "For SD card with capacity of 2 gigabytes or less a FAT 16
library should be used and FAT 32 library should be used in other case".

In this provided repo, https://github.com/hackingchips/PSoC_FatFs, the file system has been tested till 4GB.

For you second query can please check the following link and check if it helps?
https://www.hackster.io/hima/psoc-4-sd-card-interface-3e2270

Thanks and Regards,
Leo

0 Likes
brandiware
Level 4
Level 4
First like given 25 sign-ins 5 solutions authored

Hi Leo, thanks for your answer. I am still stuck with a micro-sd that I cannot seem to successfully connect to a PsOC 5LP. The breakout I use is featuring level shifters so that I can operate it at 5V. Could it be that the emFile component is configured to use 3.3V ?
I did check the example with the psoc4 - that seems to be a bit too far away since the psoc 4 does not have the emFile component. But it is using an SPI component, seemingly - so if my problem is about I/O port voltage levels then this could be an option, potentially. What do you think ?
Cheers
Stefan

0 Likes
LeoMathews
Moderator
Moderator
Moderator
First question asked 500 replies posted 100 solutions authored

HI @brandiware 

Can you please refer to this code example implementation?

https://github.com/holla2040/psoc5EmFileConsoleExample

It is a PSoC5 SD Read example project using emFile component.

Thanks and Regards,
Leo

brandiware
Level 4
Level 4
First like given 25 sign-ins 5 solutions authored

Hi community, I did find the error. The GPIO pins i used to drive SCLK produced degraded signals. No idea why. I checked other free pins with the oscilloscope until I found a beautiful clock signal. And bang! the breakout works even with my 32GB sandisk. I did use fatFs for now but I will also retry with emFile. Thanks Leo for the link I will have a look. Btw. the pins that show "degraded" clock signals are 0.2 0.3 0.4 - I am  now using 0.1 which shows a good signal if I drive it with the SPI SCLK.
Maybe this is useful for some of you struggling with microSD.

 

Cheers

Stefan

0 Likes

Hello.

Good to hear you got the uSD card working.

Assuming you are using KIT-059 (you never disclosed if using a KIT or custom pcb), there are 1uF capacitors attached on port 0.2, 0.3, 0.4, 3.2.  These are shown on KIT-059 schematic.  Hence the poor quality looking signals.

Good luck with your project.

0 Likes
brandiware
Level 4
Level 4
First like given 25 sign-ins 5 solutions authored

@bibi, that explains the signals indeed. Yes, I am using the KIT.

By the way, I tried my breakout board with emFile. No success. Unfortunately I cannot change the pin levels for MISO. My breakout is 5V ready but the DO is not level shifted. Thus, I believe the MISO levels received from the card will not be sufficient to drive the emFile MISO levels. In the fatFs example I must set the MISO pin from CMOS to LVTTL in order to work with the 3.3 V from the card. I do run the 5LP with 5V.

Does anyone know how to change the SPI MISO in emFile to be LVTTL ? Can I shift 3.3V level TTL input to 5V TTL before I feed the emFile component ? Somewhere in the emFile component there may be a place to set the MISO to LVTTL.

0 Likes

Hi.

You could move the MISO to one of the SIO pins on Port 12.  Port 12 SIO pins have programmable input and output voltage thresholds.  See AN60580 for lots of SIO details.

After initializing emFile, you could re-program the SIO register(s) for the voltage threshold for the uSD interface.

That said, if the uSD interface being used adapts 5V signals to 3.3V levels, then it should also be sending 5V on MISO.  Have you checked the MISO voltage levels?

Alternatively, you can remove the Vddio zero Ohm resistor from the KIT-059 and apply 3.3V to that Vddio pad.  There are 4 Vddio's (with zero Ohm resistors) to choose from depending on which bank of GPIO's you want to use.  Of course, you'll also need to supply 3.3V to the Vddio for that GPIO port and adjust the setting in CYDWR System menu (Operating Conditions) in Creator for 3.3V.

0 Likes

Hi BiBi, unfortunately the breakout only has shifters for the input pins, MISO output is at 3.3V level. Using the plain SPI with fatFS I can solve the issue by setting the MISO input pin to LVTTL. The pins are not visible when using emFile. But I see the generated code. Any chance I can set LVTTL for GPIO also via register programming ? Otherwise I will try the SIO pins. Thanks for your kind assistance.

0 Likes

Yes, you can change from CMOS to LVTTL by writing to the appropriate Port Control register.  Be aware that this change affects the entire port, not just 1 port pin on that port group.

Let's work with Port 0 since that's where you have your hardware connected.

From the 5LP Registers TRM:
PRT0_CTL: 0x40005109 address
vtrip_sel = VTRIP_LVTTL is the bit we want to  change

So, read PRT0_CTL and set the bit in vtrip_sel to VTRIP_LVTTL.

If you read this register using the Debugger and your current code, you'll see that the LSB is cleared to 0 representing CMOS level.  When you set the LSB to 1 (value of VTRIP_LVTTL), it's now at LVTTL level.  You can set this bit using the Debugger and test your hardware.

In software, you'll need to do this after the hardware has been configured for SPI function.  If you make the change too early, the SPI Start (inside emFile) could set it back to CMOS.  To be honest, I don't know exactly when the port is configured.  I assume it's when SPI is invoked but it could be much earlier as the 5LP is booting up.

Let us know how it goes.

0 Likes

Hi again.

I built a test load using KIT-059 where I connected the LED to the Switch (internal 5LP connection) in the schematic.  Note: this uses the address for Port2 CNTRL 0x40005129.
The Switch was configured as Digital Hi-Impedance.
Externally, I connected a resistor divider between Vdd and GND.  The resistor junction wired to the Switch input.

Using 1.8K Ohm resistors in the divider, the junction measured 2.4V (Vdd was 4.8V).  The 5LP LED followed the switch press with the port set to CMOS or LVTTL.

By using a 4.7k Ohm resistor in parallel with the 1.8k Ohm connected to GND, the junction now measures 2.0V.  The LED oscillates ON/OFF when port is set to CMOS.  Using the debugger I set the port to LVTTL and the LED now follows the switch press without oscillation.  I also did the same test building a load with the port set to LVTTL and this also worked.

So, unless the uSD MISO level is under 2.4V, there should be no problem with the port set to either CMOS or LVTTL.  At least not for my setup.  Maybe your 5LP will not be quite so forgiving.

Anyhow, it proves the point that the port register can be programmed to LVTTL after the 5LP has started running.

0 Likes
brandiware
Level 4
Level 4
First like given 25 sign-ins 5 solutions authored

Hi BiBi,

this is really cool. I am not (yet) familiar enough with control register programming but I found that the generated pin code for the emFile component expose the CTL register

reg8 test = SDCard_miso0_CTL;

But that is not for an entire port so it might be the wrong register. A PRT0_CTL I cannot find neither the VTRIP_LVTTL. How do you set this LSB that you mentioned exactly ?

I found something else that could be an alternative approach as well:

https://www.infineon.com/dgdl/Infineon-AN72382_Using_PSoC_3_and_PSoC_5LP_GPIO_Pins-ApplicationNotes-...

see 4.14 Level-Shift Signals

In the mean time I got the fatFs version fully running including long-file-name support. This gives me quite some more control over the SPI comms than using emFile. So I will most likely stick to this route. I do want to read wav files from the SD and play the audio maybe using DMA double buffering. So good control over the SPI might be an advantage after all.

Thanks again for your incredibly competent assistance !

0 Likes

Hello.

You can insert these lines into your main.c file.

#define VTRIP_CMOS 0xFE
#define VTRIP_LVTTL 0x01

SDCard_miso0_CTL = SDCard_miso0_CTL | VTRIP_LVTTL;   /* set trip level to LVTTL  */

If you want to change it back to CMOS levels:

SDCard_miso0_CTL = SDCard_miso0_CTL & VTRIP_CMOS;  /* set trip level to CMOS  */

BTW, the _CTL is for the entire port.  For whatever reason, the compiler assigns the _CTL to each named port pin that is being used.

Sounds like you've made good progress.  Way to go!

Thank you very much BiBi - I will give it a try, you made me curious now. With this even the emFile can be put to work with flexible GPIO levels. Which comes handy since some want to stick with a 5V powered PSoC and then a microSD breakout with or without level shifters. Or even a mixture like with the adafruit product I am using.
I will just use a separate port (say 15) to connect MISO and shift the level to LVTTL with your lines of code. Will keep you posted.

0 Likes
brandiware
Level 4
Level 4
First like given 25 sign-ins 5 solutions authored

If you are curious what I am trying to build here. For a heavily disabled family member, Jonas, I will digitise an old Sony cassette player. One of those for little kids with large buttons. This is the only device he manages to operate to listen to his favourite audio stories (Benjamin Blümchen). Unfortunately all of those, including on the second hand market, by now are broken and there are no spare parts.
So I will gut the cassette player and the old audio cassettes and use RFID technology as well as microSD and some DMA/DAC/OpAmp chain to feed the sony "motherboard" with exactly the right audio story according to the cassette he pluggs into the player. The amplifier of the player can still be put to use.
And I will fit micro switches underneath the big buttons to catch the play, rewind and fast forward events.

So the remaining challenges are now "just" the double-buffered DMA wav file read and convert to audio. With play, fast forward and rewind. The RFID part and the event management is all well established from other projects of mine.

0 Likes
LeoMathews
Moderator
Moderator
Moderator
First question asked 500 replies posted 100 solutions authored

Hi,

Please navigate to this link for more details.

Thanks and Regards,
Leo

0 Likes