18F26K20 SD Testing

Coding and general discussion relating to user created compiler modules

Moderators: David Barker, Jerry Messina

liak
Registered User
Registered User
Posts: 195
Joined: Fri Oct 05, 2007 12:26 am

Post by liak » Sat Jan 31, 2009 12:18 am

Dear Toley,
Oops, you have gotten it done before I posted. I am waiting for ohararp to see if he has any luck. Thanks for letting us know your results. Hope some of us will get some success in this. To confirm, you used SW option?

Regards,
Liak

Toley
Posts: 32
Joined: Tue Nov 20, 2007 5:47 pm
Location: Canada

Post by Toley » Sat Jan 31, 2009 5:28 pm

More extensive test:
Device = 18F26K20, HSPLL, Write a 1MB file (Steven's sample code 1)

Code: Select all

32MHz   SW              56.158s
32MHz   MSSP   Clk/16   39.899s
32MHz   MSSP   Clk/4    32.416s

40MHz   SW              45.493s
40MHz   MSSP   Clk/16   32.957s
40MHz   MSSP   Clk/4    26.202s

48MHz   SW              41.352s
48MHz   MSSP   Clk/16   30.774s
48MHz   MSSP   Clk/4    25.077s

64MHz   SW              32.293s
64MHz   MSSP   Clk/16   25.216s
64MHz   MSSP   Clk/4    Failed
These results show that at any speed, it is a lot faster to use MSSP Clk/16 than SW.
It also show that if it works at 64MHz Clk/4, it could probably fall under 20s.

liak
Registered User
Registered User
Posts: 195
Joined: Fri Oct 05, 2007 12:26 am

Post by liak » Sun Feb 01, 2009 4:15 am

Dear Toley,
Thanks for the update. Very helpful to know what settings worked. I have gotten my chip. Working on it to setup the card. From what I can see, you have gotten nearly 4% faster working even at MSSP Clock/16. Quite good.

Thanks again for the detailed update. I will let you know if mine works on MSSP Clock/4.

Regards,
Liak

liak
Registered User
Registered User
Posts: 195
Joined: Fri Oct 05, 2007 12:26 am

Post by liak » Sun Feb 01, 2009 4:26 am

Dear Toley,
Again we see some discrepencies. :?
See the quoted table carefully again

Code: Select all

Manufacturer Type Size SD_SPI Clock SPI Speed Write 1 MB Read 1 MB Result 
IT Works SD 64 MB MSSP 32 MHz PLL spiOscDiv4 15.21 sec 17.90 sec Success 
byteStor SD 128 MB MSSP 32 MHz PLL spiOscDiv4 15.73 sec 16.28 sec Success 
Integral SD 128 MB MSSP 32 MHz PLL spiOscDiv4 15.15 sec 16.26 sec Success 
Toshiba MicroSD 256 MB MSSP 32 MHz PLL spiOscDiv4 19.67 sec 15.88 sec Success 
Toshiba SD 512 MB MSSP 32 MHz PLL spiOscDiv4 17.37 sec 15.54 sec Success 
Kingston SD 50X 1 GB MSSP 32 MHz PLL spiOscDiv4 17.22 sec 15.63 sec Success 

 

Manufacturer Type Size SD_SPI Clock SPI Speed Write 1 MB Read 1 MB Result 
IT Works SD 64 MB SW 40 MHz - 22.58 sec 28.38 sec Success 
byteStor SD 128 MB SW 40 MHz - 23.10 sec 24.64 sec Success 
Integral SD 128 MB SW 40 MHz - 22.55 sec 24.64 sec Success 
Toshiba MicroSD 256 MB SW 40 MHz - 27.05 sec 23.17 sec Success 
Toshiba SD 512 MB SW 40 MHz - 24.64 sec 22.31 sec Success 
Kingston SD 50X 1 GB SW 40 MHz - 24.55 sec 22.13 sec Success 

 

Manufacturer Type Size SD_SPI Clock SPI Speed Write 1 MB Read 1 MB Result 
IT Works SD 64 MB MSSP 40 MHz PLL spiOscDiv64 - - Fail 
byteStor SD 128 MB MSSP 40 MHz PLL spiOscDiv64 - - Fail 
Integral SD 128 MB MSSP 40 MHz PLL spiOscDiv64 - - Fail 
Toshiba MicroSD 256 MB MSSP 40 MHz PLL spiOscDiv64 30.41 sec 28.35 sec Success 
Toshiba SD 512 MB MSSP 40 MHz PLL spiOscDiv64 - - Fail 
Kingston SD 50X 1 GB MSSP 40 MHz PLL spiOscDiv64 27.89 sec 26.88 sec Success 
It seems to me that with MSSP 32Mhz, clock/4, the results are faster compared to MSSP 40Mhz, clock/64 which most of the time failed. And the results seem to be better than yours on MSSP 64Mhz, clock/16.

But yours seem consistent though, as the transfer rate improved with increase in clock speed.


Regards,
Liak

User avatar
Steven
BETA Tester
Posts: 406
Joined: Tue Oct 03, 2006 8:32 pm
Location: Cumbria, UK

Post by Steven » Sun Feb 01, 2009 10:20 am

I've just posted a partly updated version of the help file for the SD module on the wiki (http://www.sfcompiler.co.uk/wiki/pmwiki ... temVersion), with my benchmark figures in. The figures in the above post are from an earlier version of the module and it's worth upgrading to the latest version (4.1.4). I made an important change to the SPI code to correct an earlier error that resulted in fails at faster SPI clock speeds. If people have been using the older version (either the one that came with the compiler or an earlier one from the wiki), then I'd encourage them to re-test with 4.1.4.

User avatar
ohararp
Posts: 194
Joined: Tue Oct 03, 2006 11:29 pm
Location: Dayton, OH USA
Contact:

Post by ohararp » Sun Feb 01, 2009 3:21 pm

Sorry gents, no luck here when testing different speeds and sw using 40MHz with PLL. Same hardware but 18F2620 works no problem. I think I have some older silicon that might be causing the issue.

I excerpted a bit from an e-mail with Mark Rodgers about using the spi port and the 18FX6K20 parts below.
The most complicated part of the program in the 24J40 was the SPI comms.
After 3 months of hard work with microchip, including having the guy who developed the core in to the office, I found a well obscure fault in the SPI module that stops a sequential read from the SSPBUF via the intermediary register used to load SSPBUF during the data shift; it now works perfectly and I am waiting for them to do another errata, the fault is not apparent in the C code they use as the reset the SPI module between every byte sent or received which slows it down but maybe some engineer noticed the issue and came up with a good way of not having to admit a fault!
Thanks Ryan
$25 SMT Stencils!!!
www.ohararp.com/Stencils.html

liak
Registered User
Registered User
Posts: 195
Joined: Fri Oct 05, 2007 12:26 am

Post by liak » Sun Feb 01, 2009 3:48 pm

Dear Steven and ohararp,

Thanks again Steven for updating the help file. Now I see all the MSSP at 40Mhz passed the test, and they are almost twice as fast as the SW.

Ohararp, sorry to hear your results. I have just received my chips. Hope they have corrected the silicon error by now. Yours were old stock or bought much much earlier?

Regards,
Liak

Toley
Posts: 32
Joined: Tue Nov 20, 2007 5:47 pm
Location: Canada

Post by Toley » Sun Feb 01, 2009 7:15 pm

Thank you very much Steven for the help file, I will read it carefully.

I also think 18F26K20 have some hardware SPI bugs. Mine is working but it always give Readback errors at any speed.
WARNING - Read Errors Encountered - Readback Not Identical!
But I also have 18F25K20 and these ones works fine.

I have made some other test and discover that the speed is very card dependant. The worst I have are IMPACT 1GB (bought at Wallmart in pack of 4), they are at least 25% slower than the others for write speed. In read mode, all the cards give almost similar speed.

The 18F25K20 work fine but again it don't initialize at 64MHz spiOscDiv4. But at 64MHz spiOscDiv16 it's even faster than at 40MHz spiOscDiv4.

I hope someone will found a solution for the 64MHz full speed SPI.

liak
Registered User
Registered User
Posts: 195
Joined: Fri Oct 05, 2007 12:26 am

Post by liak » Wed Feb 04, 2009 4:51 am

dear Toley,

Sorry to hear the dismay results from you. I am still to test mine.
If failed, will have to try the 18F25K20, but the problem with it is it's much smaller program memory. :cry:. How can they sell such malfunctioning chips?

http://ww1.microchip.com/downloads/en/D ... 80404A.pdf

Regards,
Liak

Doj
Posts: 362
Joined: Wed Apr 11, 2007 10:18 pm
Location: East Sussex

Post by Doj » Wed Feb 04, 2009 11:46 am

Just to defend Microchip and put the other side of the coin, this is a new core and process with a great deal of enhancement over previous cores allowing lower cost production and therefore lower cost to us, it is a true 3volt part and is a step beyond previous processes.
The price these chips cost is significantly lower than previous standard chips and they do perform far faster, but there are some issues and they need addressing.

My own products now use this core in almost every new design, there is not an issue yet which does not have a work around.

If you use SF libraries they are easy to alter to get them to run and even easier is to write your own(sepecially SPI which is really simple).

liak
Registered User
Registered User
Posts: 195
Joined: Fri Oct 05, 2007 12:26 am

Post by liak » Thu Feb 05, 2009 2:18 am

Dear Doj,
Sorry, I was just venting my disappointment. I remembered your reply and attachment on the solution to it. I will study it closely and implement it.

Regards,
Liak

moki
Posts: 1
Joined: Tue Feb 17, 2009 8:25 pm

Steven Wrights Wav Player

Post by moki » Wed Feb 18, 2009 10:28 pm

I don't know whether this is the right forum for this question. I am not familiar with with the workings of SD card readers. Firstly can any SD card be interafced to Steven's wav player or is some additional circuitry required. What I mean is can I simply buy an SD socket and connect it to the PIC? I have enclosed a picture which I found on the web. Secondly will an 8 bit A to D converter like the ones made by Analog Devices improve the sound quality? I have programmed in assembly, not basic. Hope to get to know Basic. Keep up the good works guys![img]F:\SWORDFISH%20COMPILER\SD%20Card%20Reader.jpg[/img]

liak
Registered User
Registered User
Posts: 195
Joined: Fri Oct 05, 2007 12:26 am

Post by liak » Fri Feb 20, 2009 1:42 am

Dear Moki,
Welcome to the forum.
Yes, you can connect the SD card socket directly to the PIC as shown in the diagram in
http://www.sfcompiler.co.uk/wiki/pmwiki ... CWavPlayer.
But care to take note of:

1. the SD card runs on 3.3V as the PIC runs on 5V,

2. you will need to set pull up on the pins from SD card to PIC, ie the SDI pin. Somehow, PIC will not be able to read the output from SD card if this is not done. See threads:
http://www.sfcompiler.co.uk/forum/viewt ... c&start=15. Many of us struggled because of this. The card simply will not initialize. So take note of this.

Hope this helps
Regards,
Liak

RDHeiliger
Registered User
Registered User
Posts: 26
Joined: Sun Oct 12, 2008 11:21 pm
Location: Utah

Post by RDHeiliger » Sat Apr 25, 2009 1:44 am

Looking at the electrical specs for K20's data sheet there are two charts on VDD vs Max Frequency.

Standard chip @ 1.8 - 3.0v max freq is 20MHZ
Standard chip @ 3.0 - 3.6v max freq is 48MHZ
Military chip @ 3.0 - 3.6v max freq is 64MHZ

May have some thing to do with not being able to init the SD card at 64MHZ. Would suspect that most of us do not have the military temp range chip. Perhaps the freq on a standard chip is not stable at 64 MHZ>

RD

RDHeiliger
Registered User
Registered User
Posts: 26
Joined: Sun Oct 12, 2008 11:21 pm
Location: Utah

46K20 Internal oscilator

Post by RDHeiliger » Sat Apr 25, 2009 4:53 am

I have the SDFileSystem running on a 18F46K20 with internal oscilator at 64 MHZ using either MSSP or SW. 47K pullups on DO and DI.

The main problem i ran into is that I was trying to use a 78L33 regulator to run my entire board. I noticed that inserting the card would reset the processor even tho I had all the normal resets turned off. I added a second 78L33 just for the SD card to get the board to work. I looked at the spec for the SD card and it pulls 60 mA durring read or write. Must have been enough with the rest of the board to drop VDD to low for the card to finish initializing.

Code: Select all

// device and clock...
Device = 18F46K20
Clock = 64
Config
   FOSC = INTIO67,
   WDTEN = OFF,   
   BOREN = OFF
   
// import SD file system, cdc and conversion modules...
#option SD_SPI = MSSP     // use hardware SPI
#option SD_CS = PORTC.2                    // SPI CS To SD CS (SD pin 1)
#option SD_DI = PORTC.5                    // SPI SDO to SD DI (SD Pin 2) - use 50k to 100k ohms pull-up resistor
#option SD_CLK = PORTC.3                    // SPI SCK To SD CLK (SD Pin 5)
#option SD_DO = PORTC.4                        // SPI SDI To SD DO (SD Pin 7) - use 50k to 100k ohms pull-up resistor
#option SD_SPI_SPEED = spiOscDiv16
Include "SDFileSystem.bas"
Include "usart.bas"
Include "Convert.bas"

// variables...
Dim Index As Byte
Dim SDError As Word
Dim FormatError As Boolean

'leave the primary oscilator running in sleep mode, this allows tmr1 to wake up chip
OSCCON = %01110000   'set sleep not idle,use 16MHz internal freq,use primary clock
OSCTUNE = %11000000  'use internal 16MHz for ref, use PLL for 4 times 16MHz = 64MHz clock

TRISC.2 = 0
TRISC.3 = 0
TRISC.4 = 1
TRISC.5 = 0

// program start...
SetBaudrate(br19200)
DELAYMS(100)
USART.Write("Initialising card...", 13, 10)
SDError = SD.Init   
If SDError = 0 Then
   
   // format SD card...
   USART.Write("Formatting, please wait...", 13, 10)   
   FormatError = QuickFormat
   USART.Write("FORMAT SD Error..." + DecToStr(FormatError), 13, 10)
   // write data to SD card...
   USART.Write("Writing data, please wait...", 13, 10)
   If SD.NewFile("test.txt") = errOK Then      
      For Index = 0 To 255
         'USART.Write("Line ",DecToStr(Index,3), 13, 10)
         SD.Write("Line ",DecToStr(Index,3), 13, 10)
      Next
      USART.Write("before close file", 13, 10)
      SD.CloseFile
      USART.Write("closed after write...", 13, 10)
   Else
     USART.Write("NewFileFailed..." + DecToStr(SDError), 13, 10)  
   EndIf
   
   // read data back...
   USART.Write("Reading data...", 13, 10)
   If SD.OpenFile("test.txt") = errOK Then
      'usart.write("after open file")
      Repeat
         
         USART.Write(SD.ReadByte())
      Until SD.EOF
         'usart.write("AFTER READ")
      SD.CloseFile
      USART.Write("Finished.", 13, 10)
   EndIf
Else
   USART.Write("SD Error..." + DecToStr(SDError), 13, 10)             
EndIf
This is just a mod on the SDreadwrite sample code.

RD

Post Reply