Shop OBEX P1 Docs P2 Docs Learn Events
SD2.0 FATEngine on PropC3 slow SD-card wait until SPI-bus is free — Parallax Forums

SD2.0 FATEngine on PropC3 slow SD-card wait until SPI-bus is free

StefanL38StefanL38 Posts: 2,292
edited 2011-06-23 15:13 in Propeller 1
Hi,

I tried to run the KyeDOS SD2.0 FatEngine Demo on a C3-board.

I get a VGA-screen with a blinking cursor but if I type on the keyboard connected to the C3-board
nothing happens.

I've tried other VGA/Keyboard code on the C3 and this other code is running properly
C3_unit_test_010VGA all tests passed Flash, SRAM, SD-card mounted

As I get a VGA-screen with a blinking cursor the VGA-pin-assigment seems to be right.

I inserted debug-output to the VGA-screen to analyse how far the code executes
I get feedback on the screen until command-line

fat.mountPartition(0,0) ' mount the sd card

here the systems seems to hang

The C3 !SD_Card-Profiler runs succesfull and delivers this results
### SD Card Profile ###

Disk Signature: 0x00000000

Partition 0 - 0x30656163
NO NAME     FAT16   

512 - Bytes Per Sector
64 - Sectors Per Cluster
3857984 - Total Sectors
60281 - Total Clusters
128 - Used Sectors
3857856 - Free Sectors

32 KB Stride Speed Test:

writeByte - 3 KBs
writeShort - 6 KBs
writeLong - 12 KBs
writeData - 91 KBs
readByte - 3 KBs
readShort - 6 KBs
readLong - 12 KBs
readData - 199 KBs
What do I have to change to make SD2.0 FATEngine Demo run successfully on a C3-board?

best regards

Stefan

Comments

  • Dr_AculaDr_Acula Posts: 5,484
    edited 2011-06-23 07:26
    Isn't there some tiny bit of code that enables the sd card? That will need to be added to kyedos. It is a latch or something.

    I never quite understood it but there is an explanation somewhere in the manual. The best way to describe the solution I think is via the schematic. However, the schematic in the manual does not zoom. Does anyone have a link to the zoomable schematics?
  • Mike GreenMike Green Posts: 23,101
    edited 2011-06-23 07:34
    The FATEngine object has to be modified to support the C3's device selection scheme. Here's my "unofficial" modified version. Note that the FATEngineStart method has been changed to provide for different I/O pins to be passed. Read the comments for that method for details. I've also attached a C3 modified version of the flash and SRAM driver that's in the Object Exchange.

    C3_Template is a program template that uses the modified start calls. It mounts an SD card and displays the flash directory using a PS/2 keyboard and TV display and here is simply meant to illustrate how the start calls have been changed.

    Edited 2012-02-03 to correct Winbond_Driver_C3
  • StefanL38StefanL38 Posts: 2,292
    edited 2011-06-23 08:32
    Hello Mike,

    thank you very much for uploading your code. Right now my son wants to take a walk with me and the dog.
    So I'm gonna try it later.

    best regards

    Stefan
  • StefanL38StefanL38 Posts: 2,292
    edited 2011-06-23 09:35
    I don't have a TV handy on my desk so I changed the IO to PC_Text_advanced and PC_keyboard for PropTerminal.

    I added output to see if the mounting was successfully. SD-card mounted but I also get a message "no flash found".
    Does this mean the Flash-memory of the C3-board is different from the winbond-flash?

    I attach my project to this posting.

    best regards

    Stefan
  • Mike GreenMike Green Posts: 23,101
    edited 2011-06-23 09:56
    This version of the Winbond driver knows about the Microchip flash memory used on the C3 board. Your program works fine on my C3. It displays the size of the flash memory and the amount of flash memory available. I just downloaded your archive, un-zipped it, compiled it using BST, and downloaded it to RAM. I can't explain why it doesn't work for you.
  • StefanL38StefanL38 Posts: 2,292
    edited 2011-06-23 10:59
    Hello Mike,

    first of all thank you for testing my code.
    Did you test it with PropTerminal?

    I made some tests and found out when I comment out the codelines that do test the SD-card,
    the Flashtest is successfull and reports back result 255 (output inserted by me)
    1020K flash free out of 1MB

    If a copy & paste the flash-test-code below the SD-card-test it reports back no flash found

    I took a very close look onto the flash-chip. The partnumber is Atmel 0710 26DF081A SSU.

    The file UnleashingPropellerC3v1.0.pdf talks abouts
    "The FLASH memory on the Propeller C3 is comprised of a single 8 Megabit/1MByte SPI FLASH chip from Atmel part AT26DF081A."
    So might it be that your C3 is from a pre-serial which has a microchip-flash?

    Modified code is attached

    best regards

    Stefan
  • Mike GreenMike Green Posts: 23,101
    edited 2011-06-23 11:25
    I sent the message without checking the code and I mistakenly thought the flash memory was a Microchip device. The code expects an Atmel AT26DF081 flash memory.

    I didn't actually use PropTerminal. I used BST's built-in terminal emulator. It doesn't properly interpret some of the control codes for PropTerminal, but displayed the messages from the program in a very usable fashion.

    I ran your new version and this is what I got:
    Hit <sp?dn?nchronize keyboard
    C3 Template - Version 1.001
    result253
    1012K flash free out of 1MB
    trying to mount SD-card
    SD-card Mounted
    result253
    1012K flash free out of 1MB
    
  • StefanL38StefanL38 Posts: 2,292
    edited 2011-06-23 12:27
    Hello Mike,

    this is really strange.
    I get
    Hit <spacebar> to synchronize keyboard _
    C3 Template - Version 1.001
    result255
    1020K flash free out of 1MB
    trying to mount SD-card
    SD-card Mounted
    No flash memory found ...
    result0
    

    The Sd-Card is a SanDisk 2GB micro.
    I have nothing connected but the USB-cable.

    best regards

    Stefan
  • Mike GreenMike Green Posts: 23,101
    edited 2011-06-23 13:39
    The only things I can think of ...
    1) There's something wrong with your flash memory
    2) The Sandisk SD card is slow to respond to something sent by the driver and doesn't release the SPI bus so the flash memory can use it.

    You might try another SD card and see what happens.
  • StefanL38StefanL38 Posts: 2,292
    edited 2011-06-23 14:12
    Hello Mike,

    you made my day. After inserting a repeat 500-statement now the second test of the flash is successfull.

    Thank you very much.

    This might happen with different SD-cards. So is there an easy way to check if the spi-bus is free?
    Or is it possible to insert some code that does a second try after half a second?

    best regards

    Stefan
  • Mike GreenMike Green Posts: 23,101
    edited 2011-06-23 15:13
    I don't have access to my computer now. The easiest thing to do is to take the IF statement that calls win.start and change it into a REPEAT so it does a WAITCNT for maybe 100ms, then tries again until the win.start succeeds or it's tried 10 times. The win.start routine tries to read the device ID code from the flash memory and it has to match one of the codes in a list. Once this succeeds, further flash access should be ok.

    I'm not sure how to check if the SPI bus is free. I'll have to look at Kye's code to see where additional delays could be added.
Sign In or Register to comment.