CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

128kbps MP3 stream on a bit-banged SPI

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
kender



Joined: 09 Aug 2004
Posts: 768
Location: Silicon Valley

View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger

128kbps MP3 stream on a bit-banged SPI
PostPosted: Mon Feb 25, 2008 7:36 pm     Reply with quote

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

View user's profile Send private message

Re: 128kbps MP3 stream on a bit-banged SPI
PostPosted: Mon Feb 25, 2008 8:00 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Feb 25, 2008 8:19 pm     Reply with quote

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

View user's profile Send private message

Re: 128kbps MP3 stream on a bit-banged SPI
PostPosted: Mon Feb 25, 2008 8:34 pm     Reply with quote

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

View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger

Re: 128kbps MP3 stream on a bit-banged SPI
PostPosted: Mon Feb 25, 2008 9:12 pm     Reply with quote

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

View user's profile Send private message

Re: 128kbps MP3 stream on a bit-banged SPI
PostPosted: Mon Feb 25, 2008 10:14 pm     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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