|
|
View previous topic :: View next topic |
Author |
Message |
micman Guest
|
Circular buffer for STA013 |
Posted: Mon Jun 21, 2004 10:14 am |
|
|
Hi all,
I have a problem with circular buffer.
I work with a pic18f8720 at 20MHz, an interface atapi and sta013 decoder a MPEG.
I only have a buffer of 2048 byte "int8 mp3data[2048 ]" and I can read byte for byte for "mp3data" and send to STA013 when data request is set.
The problem is: Where reload data to buffer "mp3data".
I've a function "ata_read_sector(0,g,mp3data);" return 512byte data to mp3data
The code example is inclomplete becose i don't write code for circular buffer!
The music load is only 64Kbps!!!
Thank for help me!!
int32 g;
int8 mp3data[2048];
int16 mp3ptr,bufptr;
g = 48119; //Sector where there is gives data mp3
mp3ptr=0; //pointer read
bufptr=0; //pointer write
ata_read_sector(0,g,mp3data); //read sector 512 byte
g++; //incremento sector
ata_read_sector(0,g,&mp3data[512]); //read sector 512 byte
g++;
ata_read_sector(0,g,&mp3data[1024]); //read sector 512 byte
g++;
ata_read_sector(0,g,&mp3data[1536]); //read sector 512 byte
for(;;){
while(input(DATA_REQ)){ //STA013 request data!!!
for(it=7;it<255;it--){
output_low(SCKR);
dato = mp3data[mp3ptr];
output_bit(SDI,((errore>>it)&1));
output_high(SCKR);
}
mp3ptr++;
if(mp3ptr>=2048) mp3ptr=0;
//????????????????? Circular buffer??//how to????
// g++
//ata_read_sector(0,g,&mp3data[]) //function reload 512 chunk
}//while
}//for |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Jun 21, 2004 12:37 pm |
|
|
For sample code on circular buffers, look at the EX_SISR.C
example file, in this folder: c:\Program Files\Picc\Examples
You will have to modify the code somewhat, because that
example is for a small buffer (less than 256 bytes), and
you have a large buffer. ie., the index values must be
16-bit for your program, instead of 8-bit as in the example. |
|
|
|
|
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 vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|