<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>LPC2368 SD read problem</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/24690/lpc2368-sd-read-problem</link><description> 
i&amp;#39;m using the example program for LPC236X for testing the SD card
by writing to it and verifying i&amp;#39;m reading back the same value. 
the writing goes fluently without any problems. 
the reading is stacked. 
i realized that i don&amp;#39;t get any data from the</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: LPC2368 SD read problem</title><link>https://community.arm.com/thread/144521?ContentTypeID=1</link><pubDate>Sun, 21 Dec 2008 11:41:25 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:65bcda02-2eee-4828-8daf-56e40e452813</guid><dc:creator>M. Sure</dc:creator><description>&lt;p&gt;&lt;p&gt;
Hi and thank you once more.&lt;br /&gt;
i managed to solve the problem.&lt;br /&gt;
i realized that after identification stage of the SD card the clock
frequency wasn&amp;#39;t changed to the normal frequency (during
identification it should be below 400KHz). once i changed the
frequency the program started functioning properly.&lt;br /&gt;
so thank you for supporting me along this issue.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: LPC2368 SD read problem</title><link>https://community.arm.com/thread/132056?ContentTypeID=1</link><pubDate>Sun, 14 Dec 2008 22:00:35 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:1f859d51-a55f-487f-bf76-68ac72dad5ce</guid><dc:creator>Embedded Device</dc:creator><description>&lt;p&gt;&lt;p&gt;
Hi Meir, I try your code, Iam trying to read 0th block from 1GB SD
card.&lt;br /&gt;
It was hanging in below line:&lt;/p&gt;

&lt;p&gt;
&lt;b&gt;while ( !(MCI_STATUS &amp;amp; MCI_RX_DATA_AVAIL) );&lt;/b&gt; .&lt;br /&gt;
If I comment this line I got Receive OverRun error.&lt;/p&gt;

&lt;p&gt;
Iam using IAR 5.2 with LPC2468 EA OEM Board.&lt;/p&gt;

&lt;p&gt;
Any help....&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: LPC2368 SD read problem</title><link>https://community.arm.com/thread/131804?ContentTypeID=1</link><pubDate>Tue, 02 Dec 2008 06:24:36 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:76c43cf0-731a-49c4-8575-593709bf2107</guid><dc:creator>Embedded Device</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;b&gt;Thank you Meir, I will test it and give the
feedback!!!!&lt;/b&gt;&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: LPC2368 SD read problem</title><link>https://community.arm.com/thread/130393?ContentTypeID=1</link><pubDate>Mon, 01 Dec 2008 22:57:27 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:b4a6dc86-9eea-41cc-b00d-e3eaddfa0fab</guid><dc:creator>M. Sure</dc:creator><description>&lt;p&gt;&lt;p&gt;
Hi again, pls find below the write fifo function where i don&amp;#39;t get
errors.&lt;br /&gt;
look inside for the part of MCI_TX_Active. this part of the program
goes without any problems.&lt;br /&gt;
BTW, in the part of MCI_RX_Active, in the point where the program
stuck in the value of blocksize in the LCD is 4, which indicates that
there is available data in the fifo and yet the condition of
RX_DATD_AVAIL is not set.&lt;/p&gt;

&lt;pre&gt;
/******************************************************************************
        /* Tx active, and Rx active  */
        if ( MCI_STATUS &amp;amp; MCI_TX_ACTIVE )
        {
                DataTxActiveCount++;
#if MCI_DMA_ENABLED
                while ( !(GPDMA_RAW_INT_TCSTAT &amp;amp; 0x01) );
                GPDMA_INT_TCCLR |= 0x01;
#else
                while ( TXBlockCounter &amp;lt; BLOCK_LENGTH )
                {
                        blockSize = 0;
                        if ( MCI_STATUS &amp;amp; MCI_TX_FIFO_EMPTY )
                        {
                                blockSize = FIFO_SIZE * 4;
                        }
                        else if ( MCI_STATUS &amp;amp; MCI_TX_HALF_EMPTY )
                        {
                                blockSize = (FIFO_SIZE/2) * 4;
                        }
                        else if ( !(MCI_STATUS &amp;amp; MCI_TX_FIFO_FULL) )
                        {
                                blockSize = 1 * 4;
                        }

                        for ( i = 0; i &amp;lt; blockSize; i += 4 )
                        {
                                DataWord = (unsigned long)(WriteBlock[TXBlockCounter]) | (unsigned long)(WriteBlock[TXBlockCounter+1] &amp;lt;&amp;lt; 8)
                                        | (unsigned long)(WriteBlock[TXBlockCounter+2] &amp;lt;&amp;lt; 16) | (unsigned long)(WriteBlock[TXBlockCounter+3] &amp;lt;&amp;lt; 24);
                                MCI_FIFO = DataWord;
                                TXBlockCounter += 4;
                        }
                }
#endif
                /* Data has been written, but has not been programmed into the card yet. */
                /* Even it&amp;#39;s a dead while loop inside the ISR, but, during the
                flash writing, there is not much else you should do. If it&amp;#39;s not in the
                TRAN state, per MMC/SD state diagram, send STOP to bail out. */
                if ( MCI_CheckStatus() != TRUE )
                {
                        MCI_Send_Stop();
                }
                MCI_DATA_CTRL = 0;
        }

        if ( MCI_STATUS &amp;amp; MCI_RX_ACTIVE )
        {
                DataRxActiveCount++;
#if MCI_DMA_ENABLED
                while ( !(GPDMA_RAW_INT_TCSTAT &amp;amp; 0x02) );
                GPDMA_INT_TCCLR |= 0x02;
#else
                while ( RXBlockCounter &amp;lt; BLOCK_LENGTH )
                {
//                      if ( !(MCI_STATUS &amp;amp; MCI_RX_FIFO_FULL) )
                        if ( MCI_STATUS &amp;amp; MCI_RX_FIFO_FULL)
                        {
                                blockSize = FIFO_SIZE * 4;
                        }
                        else if ( MCI_STATUS &amp;amp; MCI_RX_HALF_FULL )
                        {
                                blockSize = (FIFO_SIZE/2) * 4;
                        }
//                      else if ( MCI_STATUS &amp;amp; MCI_RX_FIFO_EMPTY )
                        else if (!( MCI_STATUS &amp;amp; MCI_RX_FIFO_EMPTY ))
                        {
                                blockSize = 1 * 4;
                        }
                        else
                        {
                                blockSize = 0;
                        }

                        for ( i = 0; i &amp;lt; blockSize; i += 4 )
                        {
                        sprintf (lcd_buf,&amp;quot;blockSize = %3u &amp;quot;,blockSize);
                        goto_cursor(1,0);
                        lcd_print(lcd_buf);
                                while ( !(MCI_STATUS &amp;amp; MCI_RX_DATA_AVAIL) );
//                              while ( !(MCI_STATUS &amp;amp; MCI_RX_HALF_FULL) );
                        sprintf (lcd_buf,&amp;quot;Got here2 RX_Active&amp;quot;);
                        goto_cursor(1,0);
                        lcd_print(lcd_buf);
                                DataWord = MCI_FIFO;
                                ReadBlock[RXBlockCounter] = DataWord &amp;amp; 0xFF;
                                ReadBlock[RXBlockCounter+1] = (DataWord &amp;gt;&amp;gt; 8) &amp;amp; 0xFF;
                                ReadBlock[RXBlockCounter+2] = (DataWord &amp;gt;&amp;gt; 16) &amp;amp; 0xFF;
                                ReadBlock[RXBlockCounter+3] = (DataWord &amp;gt;&amp;gt; 24) &amp;amp; 0xFF;
                                RXBlockCounter += 4;
                        }
                }
#endif
                if ( MCI_CheckStatus() != TRUE )
                {
                        MCI_Send_Stop();
                        sprintf (lcd_buf,&amp;quot;CMD13,status check&amp;quot;);
                        goto_cursor(0,0);
                        lcd_print(lcd_buf);
                        sprintf (lcd_buf,&amp;quot;Failed RX_Active&amp;quot;);
                        goto_cursor(1,0);
                        lcd_print(lcd_buf);
                        delay (10000000);
                }
                else
                {
                        sprintf (lcd_buf,&amp;quot;CMD13 OK Status Check&amp;quot;);
                        goto_cursor(0,0);
                        lcd_print(lcd_buf);
                        sprintf (lcd_buf,&amp;quot;Pass RX_Active&amp;quot;);
                        goto_cursor(1,0);
                        lcd_print(lcd_buf);
                        delay (10000000);
                }

                MCI_DATA_CTRL = 0;
        }
        VICIntEnable |= MCI_Int;                                /*enable MCI interrupts */
        return;
}
&lt;/pre&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: LPC2368 SD read problem</title><link>https://community.arm.com/thread/135599?ContentTypeID=1</link><pubDate>Mon, 01 Dec 2008 22:55:09 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:a251931a-154f-41eb-8fd7-f015882f1243</guid><dc:creator>Franc  Urbanc</dc:creator><description>&lt;p&gt;&lt;p&gt;
Maybe you could consider the RL-ARM option. In RL-ARM there is a
ready to go &lt;b&gt;MCI_LPC24xx.c&lt;/b&gt; driver for MCB2400. With this driver
MCB2400 works just fine with the File System.&lt;/p&gt;

&lt;p&gt;
Franc&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: LPC2368 SD read problem</title><link>https://community.arm.com/thread/125094?ContentTypeID=1</link><pubDate>Mon, 01 Dec 2008 22:09:26 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:3c279ae1-1bd8-49b9-b885-0112dea53888</guid><dc:creator>Embedded Device</dc:creator><description>&lt;p&gt;&lt;p&gt;
Hi Meir, No I haven&amp;#39;t tried your code.I am reviewing my code, in
which I got the above errors.I will try your code.&lt;br /&gt;
Using DMA in MCI is more useful than fifo where we can overcome the
above errors.&lt;br /&gt;
If possible can you send read and write the fifo functions where you
haven&amp;#39;t get the errors?&lt;br /&gt;
Iam working on KEIL IDE with LPC2468 Embedded Artists board.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: LPC2368 SD read problem</title><link>https://community.arm.com/thread/114455?ContentTypeID=1</link><pubDate>Mon, 01 Dec 2008 03:49:10 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:de111896-1a72-487b-a445-7cb0000b07d1</guid><dc:creator>M. Sure</dc:creator><description>&lt;p&gt;&lt;p&gt;
Hi.did you try the code i attached or the original code? i didn&amp;#39;t
get any of the above mentioned errors. i was afraid that the SW is
stuck in nested interrupt so i trap all interrupts handling with
notices to my LCD display, but the program doesn&amp;#39;t go there. so, as
far as i can see this is not a problem of receive overrun.&lt;br /&gt;
with the original code receive overrun is expected as it fixes the
blockSize to the FIFO size even if the FIFO buffer is not full.&lt;br /&gt;
anyhow in the example code there is a treatment for the various types
of error and interrupts (separate handling for data and for
commands), in most of the cases the &amp;quot;treatment&amp;quot; is just increasing a
counter and interrupt flag reset.&lt;br /&gt;
as i mentioned earlier, i tried to catch the problem with this type
of code in the routine tha handles each type of interrupt:&lt;/p&gt;

&lt;pre&gt;
        /* Underrun or overrun */
        if ( MCIStatus &amp;amp;  MCI_TX_UNDERRUN )
        {
                DataTxUnderrunErrCount++;
                sprintf (lcd_buf,&amp;quot;TX_UNDERRUN FAIL   &amp;quot;);
                goto_cursor(0,0);
                lcd_print(lcd_buf);
                delay (1000000);
                MCI_CLEAR = MCIStatus | MCI_TX_UNDERRUN;
        }
        if ( MCIStatus &amp;amp;  MCI_RX_OVERRUN )
        {
                DataRxOverrunErrCount++;
                sprintf (lcd_buf,&amp;quot;RX_OVERRUN FAIL   &amp;quot;);
                goto_cursor(0,0);
                lcd_print(lcd_buf);
                delay (1000000);
                MCI_CLEAR = MCIStatus | MCI_RX_OVERRUN;
        }
&lt;/pre&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: LPC2368 SD read problem</title><link>https://community.arm.com/thread/101367?ContentTypeID=1</link><pubDate>Sun, 30 Nov 2008 21:12:24 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:52021c48-f468-4556-8d60-0219f93398f0</guid><dc:creator>Embedded Device</dc:creator><description>&lt;p&gt;&lt;p&gt;
Hi Meir, In your testing you got receive overrun,transmit underrun
and data timeout errors during read and write from the card. When
these errors occurred what you did?&lt;/p&gt;

&lt;p&gt;
In my case i got above errors and I tried to read and write once
again from the above errors,but it&amp;#39;s not working. You have any idea
how to overcome these errors?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: LPC2368 SD read problem</title><link>https://community.arm.com/thread/76922?ContentTypeID=1</link><pubDate>Sat, 29 Nov 2008 22:44:43 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:fc43c84e-9f5d-44a4-858d-dec422409324</guid><dc:creator>M. Sure</dc:creator><description>&lt;p&gt;&lt;p&gt;
Hi, thanks for the reply.&lt;br /&gt;
i realized that writing to sector 0 will be a problem, that&amp;#39;s why i
tried to read SD_Status and find out the size of the protected area.
any how i added 0x1000* block_size as base address so i bypassed this
problem.&lt;br /&gt;
i think that in the example program there is a bug in the RX_Active
handling, the conditions for setting the blocksize are wrong. i
attached here this part of the code. i turned the original code into
remark and located my substitute code&lt;/p&gt;

&lt;pre&gt;
        if ( MCI_STATUS &amp;amp; MCI_RX_ACTIVE )
        {
                DataRxActiveCount++;
#if MCI_DMA_ENABLED
                while ( !(GPDMA_RAW_INT_TCSTAT &amp;amp; 0x02) );
                GPDMA_INT_TCCLR |= 0x02;
#else
                while ( RXBlockCounter &amp;lt; BLOCK_LENGTH )
                {
//                      if ( !(MCI_STATUS &amp;amp; MCI_RX_FIFO_FULL) )
                        if ( MCI_STATUS &amp;amp; MCI_RX_FIFO_FULL)
                        {
                                blockSize = FIFO_SIZE * 4;
                        }
                        else if ( MCI_STATUS &amp;amp; MCI_RX_HALF_FULL )
                        {
                                blockSize = (FIFO_SIZE/2) * 4;
                        }
//                      else if ( MCI_STATUS &amp;amp; MCI_RX_FIFO_EMPTY )
                        else if (!( MCI_STATUS &amp;amp; MCI_RX_FIFO_EMPTY ))
                        {
                                blockSize = 1 * 4;
                        }
                        else
                        {
                                blockSize = 0;
                        }
&lt;/pre&gt;

&lt;p&gt;
&lt;br /&gt;
i&amp;#39;m using the Keil uVision 3 as IDE and my board is CP-JR ARM7
LPC2368 from Futurlec.&lt;br /&gt;
those are my first steps with ARM series (3 weeks since first time i
use it) so i didn&amp;#39;t cover yet the DMA part. i plan that (DMA) to be
the next feature i&amp;#39;ll try to get through.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: LPC2368 SD read problem</title><link>https://community.arm.com/thread/52934?ContentTypeID=1</link><pubDate>Wed, 26 Nov 2008 22:19:55 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:6f082bc5-3fc9-412e-a49a-1ba88328066d</guid><dc:creator>Embedded Device</dc:creator><description>&lt;p&gt;&lt;p&gt;
Hi Meir Sudry, Don&amp;#39;t read the data in FIFO mode, use GPDMA
mode.&lt;br /&gt;
In my case Iam getting Receive Overrun error in FIFO mode so i
shifted to DMA mode.&lt;br /&gt;
I think You are writing the data on 0th block, which is a boot sector
for file system, which was corrupted.&lt;br /&gt;
When the bootsector was corrupted it won&amp;#39;t work in camera because it
won&amp;#39;t format(not sure my guess) and if you connect to PC it shows as
a removable disk but it will ask to format before trying to open
it.&lt;/p&gt;

&lt;p&gt;
Can you tell me which IDE and board you are using?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>