View previous topic :: View next topic |
Author |
Message |
kender
Joined: 09 Aug 2004 Posts: 768 Location: Silicon Valley
|
128kbps MP3 stream on a bit-banged SPI |
Posted: Mon Feb 25, 2008 7:36 pm |
|
|
Colleagues,
What are the highest reasonable (or highest possible) data rates for the SPI bus bit-banged by a PIC16F690 with 12.228 MHz clock?
I’d like to read the MP3 data from an SD card and push it into the MP3 decoder (VS1011e). Both SD card and decoder will be on the same SPI bus.
I need to embed an MP3 player into my instrument. In the instrument, I2C is the bus of choice for command and control. The PIC that pushes the MP3 stream will be an I2C slave. I2C slave functionality will use-up the SSP module, which could otherwise be used for hardware SPI.
Thanks,
- Nick _________________ Read the label, before opening a can of worms. |
|
|
RLScott
Joined: 10 Jul 2007 Posts: 465
|
Re: 128kbps MP3 stream on a bit-banged SPI |
Posted: Mon Feb 25, 2008 8:00 pm |
|
|
Five instructions per bit for the raw transfer (about 1.6 usec), plus a little more for overhead. Since you have to read the SD card and write to decoder and can only do one at a time, it will take about 3.2 usec. to move each bit, or 312kbps, so I think you could do 128kbps quite easily. You have to unroll the 8-bits per byte loop to go this fast.
Robert Scott
Real-Time Specialties
Embedded Systems Consulting |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Feb 25, 2008 8:19 pm |
|
|
Here's an example of an unrolled loop, for transmit only. It's not tested.
Look at the .LST file to see the code size.
Code: |
#include <16F877.h>
#fuses XT,NOWDT,NOPROTECT,NOPUT, NOLVP
#use delay(clock=4000000)
#use fast_io(B)
#define SDO PIN_B0
#define SCLK PIN_B1
#define CS PIN_B2
#define send_bit(data, bitnum) \
output_bit(SDO, bit_test(data, bitnum)); \
output_high(SCLK); \
output_low(SCLK)
//====================================
void main()
{
int8 i;
int8 value;
int8 array[96];
output_low(SDO);
output_low(SCLK);
output_high(CS);
set_tris_b(0xF8);
for(i = 0; i < sizeof(array); i++)
{
value = array[i];
output_low(CS);
send_bit(value, 7);
send_bit(value, 6);
send_bit(value, 5);
send_bit(value, 4);
send_bit(value, 3);
send_bit(value, 2);
send_bit(value, 1);
send_bit(value, 0);
output_high(CS);
}
while(1);
}
|
|
|
|
Neutone
Joined: 08 Sep 2003 Posts: 839 Location: Houston
|
Re: 128kbps MP3 stream on a bit-banged SPI |
Posted: Mon Feb 25, 2008 8:34 pm |
|
|
kender wrote: | Colleagues,
What are the highest reasonable (or highest possible) data rates for the SPI bus bit-banged by a PIC16F690 with 12.228 MHz clock?
I’d like to read the MP3 data from an SD card and push it into the MP3 decoder (VS1011e). Both SD card and decoder will be on the same SPI bus.
I need to embed an MP3 player into my instrument. In the instrument, I2C is the bus of choice for command and control. The PIC that pushes the MP3 stream will be an I2C slave. I2C slave functionality will use-up the SSP module, which could otherwise be used for hardware SPI.
Thanks,
- Nick |
I think that SD cards can be read in a continuous stream that crosses block boundaries. There is no reason I can think of why the data would have to go through the the PIC during playback. The PIC could play the part of managing the data flow but only moving data through the PIC while loading the SD card. Use an external gate to route data. |
|
|
kender
Joined: 09 Aug 2004 Posts: 768 Location: Silicon Valley
|
Re: 128kbps MP3 stream on a bit-banged SPI |
Posted: Mon Feb 25, 2008 9:12 pm |
|
|
Neutone wrote: | I think that SD cards can be read in a continuous stream that crosses block boundaries. There is no reason I can think of why the data would have to go through the the PIC during playback. The PIC could play the part of managing the data flow but only moving data through the PIC while loading the SD card. Use an external gate to route data. |
The MP3 decoder can't pull the data out of SD card. (I wish it could.) It's designed only to have the data pushed into it. _________________ Read the label, before opening a can of worms. |
|
|
Neutone
Joined: 08 Sep 2003 Posts: 839 Location: Houston
|
Re: 128kbps MP3 stream on a bit-banged SPI |
Posted: Mon Feb 25, 2008 10:14 pm |
|
|
kender wrote: | Neutone wrote: | I think that SD cards can be read in a continuous stream that crosses block boundaries. There is no reason I can think of why the data would have to go through the the PIC during playback. The PIC could play the part of managing the data flow but only moving data through the PIC while loading the SD card. Use an external gate to route data. |
The MP3 decoder can't pull the data out of SD card. (I wish it could.) It's designed only to have the data pushed into it. |
But the data out of the SD card can be connected to the data in MP3 decoder. The PIC would have to continue to clock the data. With some tri-state gates to control where data goes it should be easy. This would allow the PIC to send commands to both devices to initiate the transfer and then start the data stream without data going through the PIC. You could use the PWM to clock data. |
|
|
|