Hi
I'm playing .wav -RIFF files throught SPI bus.
The standard FAT16 library gives Some File Read routines, but most of them are buffered.
I tried Mmc_Fat_Read(); and Mmc_Fat_ReadN();
Normally, the buffer is useful, but I need a continuous stream of data.
Buffered reading, though it's fast, until it's empty. Then, It will work for a long time by recharging the buffer again. (2-4ms)
While recharging, i cannout send audio data, because the controller busy with reading sectors.
That causes lagging, breaking, bad, almost terrible sound quality.
How can I get bytes 1 by 1 directly, without buffering?
Pic32MZ Sd Card-> File Single byte Read
- filip.grujcic
- Posts: 822
- Joined: 14 May 2018 08:34
Re: Pic32MZ Sd Card-> File Single byte Read
Hi,
What you're describing doesn't seem to be the problem here.
Could you attach your code where you do this?
Kind regards,
What you're describing doesn't seem to be the problem here.
Could you attach your code where you do this?
Kind regards,
Filip Grujcic
Re: Pic32MZ Sd Card-> File Single byte Read
Maybe I was too complicated. Actually, this is a simple problem.
When SPI used to talk to the SD card, it reads sectors. 1 sector is 512 bytes long.
The Library reads 1 sector and stores it in a 512 byte long block of array. (read functions do this)
To Play Wav files, it needs to Send data about 22,050 or 44,100 times/second. (depends on sample rate)
When that 512 bytes long buffer ends, the PIC needs to read the next 512 bytes.(next sector) <- this is my problem.
Because reading 1 sector takes about 5-1 millisecond. That is way more, than a 22,050 Hz (~45us) signal needs.
To read 1 byte is fast. But reading 512 bytes of "chunks" of data is creating delays!
So the original question is: Is there a function that allow me to Read Single bytes from the card? (Without Puffer)
Or if not, how can i read multiple sectors byte-by-byte not to by sector-by sector?
When SPI used to talk to the SD card, it reads sectors. 1 sector is 512 bytes long.
The Library reads 1 sector and stores it in a 512 byte long block of array. (read functions do this)
To Play Wav files, it needs to Send data about 22,050 or 44,100 times/second. (depends on sample rate)
When that 512 bytes long buffer ends, the PIC needs to read the next 512 bytes.(next sector) <- this is my problem.
Because reading 1 sector takes about 5-1 millisecond. That is way more, than a 22,050 Hz (~45us) signal needs.
To read 1 byte is fast. But reading 512 bytes of "chunks" of data is creating delays!
So the original question is: Is there a function that allow me to Read Single bytes from the card? (Without Puffer)
Or if not, how can i read multiple sectors byte-by-byte not to by sector-by sector?
- filip.grujcic
- Posts: 822
- Joined: 14 May 2018 08:34
Re: Pic32MZ Sd Card-> File Single byte Read
Hi,
Unfortunately, in the current library there are no functions for reading the data from sd card byte by byte. So in that case, you will have to write your own function for this.
Kind regards,
Unfortunately, in the current library there are no functions for reading the data from sd card byte by byte. So in that case, you will have to write your own function for this.
Kind regards,
Filip Grujcic
Re: Pic32MZ Sd Card-> File Single byte Read
Just a quick update:
Recently I've solved the problem.
By using the library for determine wich sector is the file starts, and write my own code for sending commands to the card and reading it, as it should be.
Now it can play up to CD quality sound (44KHz) without any problem.
Recently I've solved the problem.
By using the library for determine wich sector is the file starts, and write my own code for sending commands to the card and reading it, as it should be.
Now it can play up to CD quality sound (44KHz) without any problem.