It is currently 22 May 2019 05:40

All times are UTC + 1 hour




Post new topic Reply to topic  [ 10 posts ] 
Author Message
PostPosted: 27 Apr 2009 12:47 
Offline

Joined: 18 Jun 2008 11:43
Posts: 3778
Location: Nieuwpoort, Belgium
Addendum: most of the issues were corrected in v2.50. Only points 1 and 3 are still there.


Hi, I just started using MMC/SD and I notices something in the help:
In the helptext for the MMC libary there is a code example (program "MMC_Test") at the end of it. I have a few remarks about that:

1. The variable "SectorNo" is never initialised before it is used, perhaps this can be corrected in the help? Thanks in advance.

2. I had to (with a 2GB SD card from EMTEC, speed upto 60x) use the following SPI initialisation:
SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV4, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_HIGH, _SPI_LOW_2_HIGH);
in stead of
SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV16, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_LOW_2_HIGH);
With the initialisation from the example it did work not very well: much errors, especially "content" errors, and after a while the card blocked completely.
The only thing I had to change was "_SPI_CLK_IDLE_LOW" into "_SPI_CLK_IDLE_HIGH".
As you can see I can even use the highest clock frequency (...DIV4 with a 40Mhz CPU clock speed) with this new setting.

I work with the "MMC/SD CARD Proto".

Addendum: apparently setting AN4 to digital causes this problem if the AN4 pin (= RA5) is not set to output or is floating as input. Thanks yo2lio for the solution. So: "_SPI_CLK_IDLE_LOW" is OK provided AN4(RA5) is not floating.


3. The type of parameter for procedure "UART_Write_Line" should be (I think) "var uart_text : array[255] of byte" (or "var uart_text : string[255]"), the same as for routine "UART1_Write_Text", now it is simply a byte var parameter.
procedure UART_Write_Line( var uart_text : byte ); // <----
  begin
    UART1_Write_Text(uart_text); // <----
    ...



Then a few remarks on the help content itself:

4. In mmc_init the help says:
Quote:
Parameters:
port: chip select signal port address.
cspin: chip select pin.
The parameters (of the function) are not there. In stead global variables are used.

Fixed in v2.50

5. In mmc_read_sector the help says:
Quote:
Parameters:
sector: MMC/SD card sector to be read.
data: buffer of minimum 512 bytes in length for data storage.
The "data" parameter has an other name in the prototype (same in mmc_write_sector also).

Fixed in v2.50

6. In mmc_fat_quickformat the help says:
Quote:
Parameters:
port: chip select signal port address.
pin: chip select pin.
mmc_fat_label:
Port and Pin are no longer there, they have been replaced by global variables.

Fixed in v2.50

Keep up the good work! :D

Thanks for the corrections done in v2.50! :D

_________________
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)


Last edited by Dany on 05 Jul 2009 09:19, edited 6 times in total.

Top
 Profile  
 
PostPosted: 05 May 2009 10:41 
Offline
mikroElektronika team
User avatar

Joined: 28 Dec 2005 12:47
Posts: 1552
Location: Serbia
2: We did not experience such behavior, it will be investigated.
1, 3, 4, 5, 6: will be checked and fixed if necessary.
Thanks.


Top
 Profile  
 
PostPosted: 05 May 2009 11:56 
Offline

Joined: 18 Jun 2008 11:43
Posts: 3778
Location: Nieuwpoort, Belgium
srdjan wrote:
2: We did not experience such behavior, it will be investigated.
1, 3, 4, 5, 6: will be checked and fixed if necessary.
Thanks.
Thanks SrdJan! :D

_________________
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)


Top
 Profile  
 
 Post subject:
PostPosted: 27 Jun 2009 15:06 
Offline

Joined: 18 Jun 2008 11:43
Posts: 3778
Location: Nieuwpoort, Belgium
Hi SrdJan,

Regarding point 2:
Dany wrote:
The only thing I had to change was "_SPI_CLK_IDLE_LOW" into "_SPI_CLK_IDLE_HIGH".

SrdJan wrote:
2: We did not experience such behavior, it will be investigated.


I discovered that SPI goes wrong with "_SPI_CLK_IDLE_LOW" when I assign $0F to ADCON1. In general, as soon as I try to switch AN4 to digital (so all values from $0B onwards), SPI needs "_SPI_CLK_IDLE_HIGH" in stead of "_SPI_CLK_IDLE_LOW" (on P18F2620 in SPI master mode, where AN4 is the same pin as SS, an SPI slave pin).

I can not find in the datasheet why this should be the case.

Important:
In the help example "program MMC_Test", the statement
ADCON1 := ADCON1 or 0x0F;                  // Configure AN pins as digital
is present which causes above described behaviour.

So, I think you can ignore point 2, it works with "_SPI_CLK_IDLE_LOW" (provided... see above).

Thanks! :D

_________________
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)


Top
 Profile  
 
 Post subject:
PostPosted: 30 Jun 2009 09:17 
Offline
mikroElektronika team
User avatar

Joined: 28 Dec 2005 12:47
Posts: 1552
Location: Serbia
Hi,
Dany wrote:
So, I think you can ignore point 2, it works with "_SPI_CLK_IDLE_LOW" (provided... see above).
Thanks! :D

Thank you for the report.


Top
 Profile  
 
 Post subject:
PostPosted: 30 Jun 2009 09:25 
Offline

Joined: 19 Sep 2006 12:57
Posts: 1868
Location: Romania, Arad City
Dany, I had the same problem with PIC18F2620, in the past with my UDP bootloader ENC28J60. (my SPI library and my ENC library)

This problem was solved, I don't remember exactly how, I kept SS pin LOW or HIGH via 4k7 resistor.

Please try mikroe example again with pull up or pull down resistor on SS pin.

_________________
Best regards, Florin Andrei Medrea.

http://www.microelemente.ro/
http://www.microelemente.ro/produse-si-servicii/
http://www.microelemente.ro/custom-software/

mail : florin@microelemente.ro


Top
 Profile  
 
 Post subject:
PostPosted: 30 Jun 2009 10:31 
Offline

Joined: 18 Jun 2008 11:43
Posts: 3778
Location: Nieuwpoort, Belgium
yo2lio wrote:
Dany, I had the same problem with PIC18F2620, in the past with my UDP bootloader ENC28J60. (my SPI library and my ENC library)

This problem was solved, I don't remember exactly how, I kept SS pin LOW or HIGH via 4k7 resistor.

Please try mikroe example again with pull up or pull down resistor on SS pin.
Thanks, I will. :D

_________________
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)


Top
 Profile  
 
 Post subject:
PostPosted: 30 Jun 2009 11:26 
Offline

Joined: 18 Jun 2008 11:43
Posts: 3778
Location: Nieuwpoort, Belgium
Dany wrote:
yo2lio wrote:
Dany, I had the same problem with PIC18F2620, in the past with my UDP bootloader ENC28J60. (my SPI library and my ENC library)

This problem was solved, I don't remember exactly how, I kept SS pin LOW or HIGH via 4k7 resistor.

Please try mikroe example again with pull up or pull down resistor on SS pin.
Thanks, I will. :D

Hi Yo2Lio, a pullup or pulldown resistor (I used 1K0) on the SS pin is indeed the solution!
Good to know. Thanks! :D :D

Added later: also setting the PortA.5 (= the SS pin) direction to output is a solution. No pullup/down resistor needed in this case.

_________________
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)


Top
 Profile  
 
 Post subject:
PostPosted: 30 Jun 2009 13:31 
Offline

Joined: 19 Sep 2006 12:57
Posts: 1868
Location: Romania, Arad City
Dany wrote:
Hi Yo2Lio, a pullup or pulldown resistor (I used 1K0) on the SS pin is indeed the solution!
Good to know. Thanks! :D :D

Added later: also setting the PortA.5 (= the SS pin) direction to output is a solution. No pullup/down resistor needed in this case.


It's a silicon BUG I think !

_________________
Best regards, Florin Andrei Medrea.

http://www.microelemente.ro/
http://www.microelemente.ro/produse-si-servicii/
http://www.microelemente.ro/custom-software/

mail : florin@microelemente.ro


Top
 Profile  
 
 Post subject:
PostPosted: 18 Aug 2009 09:41 
Offline

Joined: 18 Jun 2008 11:43
Posts: 3778
Location: Nieuwpoort, Belgium
yo2lio wrote:
It's a silicon BUG I think !

Seems it is, but I can not find it in any "errata" document. Also some users on the Microchip forum report this problem (for another PIC however), see:
http://www.microchip.com/forums/tm.aspx?m=369346.

_________________
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: