Read/write sd card

Use this section to discuss your embedded Flowcode projects.
WingNut
Posts: 254
http://meble-kuchenne.info.pl
Joined: Tue Jul 13, 2021 1:53 pm
Has thanked: 33 times
Been thanked: 23 times

Read/write sd card

Post by WingNut »

Hi. I've been battling with a sd card read write for a while now. The flowcode below has stripped out of a bigger project to try and figure out why it doesnt work in hardware but simulates. Its messy but thats because ive been stripping things out adding things etc. Can you give me apointer? The circuit also uses an RTC which is working and I have spent quite a while figuring out which PIC to use, settling onPIC16F1887 for its ram size and features. Any help pointers greatly appreciated. Flowcode has greatly improved development speed up to now but I need your help now
Attachments
SD card test.fcfx
(21.62 KiB) Downloaded 137 times

WingNut
Posts: 254
Joined: Tue Jul 13, 2021 1:53 pm
Has thanked: 33 times
Been thanked: 23 times

Re: Read/write sd card

Post by WingNut »

I should have added that I was using an sd card module with a 3.3 v regulator but changed to a micro sd module with regulator and level adjuster on board

stefan.erni
Valued Contributor
Posts: 738
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 149 times
Been thanked: 170 times

Re: Read/write sd card

Post by stefan.erni »

Hi WingNut


Only SDHC or (microSDHC) card will work
32Giga is the largest that still works.

Set the Speed Prescaler to 64
divider_2021-11-30_8-36-50.png
divider_2021-11-30_8-36-50.png (46.03 KiB) Viewed 3664 times

Try to make a loop like this (name is fileSD ):
loop_2021-11-30_9-18-21.png
loop_2021-11-30_9-18-21.png (28.76 KiB) Viewed 3664 times
regards


Stefan

WingNut
Posts: 254
Joined: Tue Jul 13, 2021 1:53 pm
Has thanked: 33 times
Been thanked: 23 times

Re: Read/write sd card

Post by WingNut »

Stefan, thanks for your suggestion I'll give it a go when i get home tonight. I did think it might have been a clocking seed issue but had no idea where to start

WingNut
Posts: 254
Joined: Tue Jul 13, 2021 1:53 pm
Has thanked: 33 times
Been thanked: 23 times

Re: Read/write sd card

Post by WingNut »

I tried as you suggested. Changed high speed prescaler value to 64 and made some changes to see what was being returned. So from the flowcode it displays 255 continuously as i wanted to give it as much time to initialise but to no avail

I'm using a 2GB micro sd card but i swapped for a 32GB sdhc card and same result. Checked all connections too
Attachments
SD card test.fcfx
(22.07 KiB) Downloaded 133 times

stefan.erni
Valued Contributor
Posts: 738
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 149 times
Been thanked: 170 times

Re: Read/write sd card

Post by stefan.erni »

Hi WingNut

Can you try to switch the SPI Mode to software mode?
regards
Stefan
Attachments
Software_2021-12-01_8-07-18.png
Software_2021-12-01_8-07-18.png (45.24 KiB) Viewed 3616 times

WingNut
Posts: 254
Joined: Tue Jul 13, 2021 1:53 pm
Has thanked: 33 times
Been thanked: 23 times

Re: Read/write sd card

Post by WingNut »

Same result Stefan

stefan.erni
Valued Contributor
Posts: 738
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 149 times
Been thanked: 170 times

Re: Read/write sd card

Post by stefan.erni »

ok. What hardware do you have?

Here is my hardware as a sample how to connect a micro sd card to a PIC and set the port in FC.
Pin_SD_2021-12-01_11-30-46.png
Pin_SD_2021-12-01_11-30-46.png (206.98 KiB) Viewed 3599 times
pin_FC_2021-12-01_11-35-00.png
pin_FC_2021-12-01_11-35-00.png (42.44 KiB) Viewed 3599 times

WingNut
Posts: 254
Joined: Tue Jul 13, 2021 1:53 pm
Has thanked: 33 times
Been thanked: 23 times

Re: Read/write sd card

Post by WingNut »

This one connected as per the pinout on the device view
I have no pull up resistors or voltage dividers as the device has a regulator and level shifter

https://www.amazon.co.uk/gp/product/B07 ... UTF8&psc=1

stefan.erni
Valued Contributor
Posts: 738
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 149 times
Been thanked: 170 times

Re: Read/write sd card

Post by stefan.erni »

So your PIC and your SD-card are both on 3.3v or 5.0 Volt?

The wiring is here

https://mschoeffler.com/2017/02/22/how- ... duino-uno/

Can you check if your SD card is FAT32 format (Windos click on drive and choose propertis)
Fat-2021-12-01_11-51-12.png
Fat-2021-12-01_11-51-12.png (22.12 KiB) Viewed 3596 times

Post Reply