pic18f67j60 mmc card read

Status
Not open for further replies.

opensys

Newbie level 1
Joined
Nov 13, 2010
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,294
Hello folks,

I need to read from the mmc card a web page to display in web server, but i have problems loading files with like 300 chars or more.
I tested with 10 chars and is reading the file ok , but problem is when is bigger it freezes the pic or print random chars loop.

I need to put the file reading in chunks because the memory is 3kb

In this example i set the buffer to 512 bytes some of mmc card, and send it to serial console.

i use mikroc software.

unsigned long ii, file_size;
const BUFFER_SIZE = 512;
char BufferLarge[BUFFER_SIZE];

void go(){

SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV64, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_LOW_2_HIGH);
Delay_ms(10);

Mmc_Fat_Init();
SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV16, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_LOW_2_HIGH);

char hfilename[13] = "test.html";
Mmc_Fat_Assign(&hfilename, 0);
Mmc_Fat_Reset(&file_size);
while (file_size+1 > BUFFER_SIZE) {

for (ii=0; ii<BUFFER_SIZE; ii++)
Mmc_Fat_Read(BufferLarge + ii);

for (ii=0; ii<BUFFER_SIZE; ii++)
UART1_Write(BufferLarge[ii]);
file_size -= BUFFER_SIZE;
}


for (ii=0; ii<file_size; ii++)
Mmc_Fat_Read(BufferLarge + ii);
for (ii=0; ii<file_size; ii++)
UART1_Write(BufferLarge[ii]);

}


Can any one help ?
thank you
 
Last edited:

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…