SD Wave Player

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

SD Wave Player

1,168件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by bobi-one on Fri Nov 29 01:46:55 MST 2013
Hi All,
I am trying to design a wave player that can play 2 wave files simultaneously ( the end project will be  on LPC1769).
But in the mean time I am trying to make simple wave player with LPC1343  to play one file continiosly.
I Connected SDcard to the MMC  and used the code for it from adafruits microtouch.
I made software SPI for the DAC   because  LPC1343 have only one. So the thing I am stuck is:
I have timer32B0 interrupting  with 22050 sample rate to set the DAC value.  But when  all the vallues from the  sd buffer[512] are sent,
another sequence to read 512 more  from the card is called. And that causes delay. I am open for ideas how to read  bytes from the buffer. and make DAC feeding consistent
void FileWriteByte(byte b)
{
    if (_mark == 512)
     FileLoad(_sector + 1); //read 512 more
    if (b != _buffer[_mark])
    {
            _dirty = 1;
            _buffer[_mark] = b;
    }
    _mark++;
}
///////////////////////////////////////////////////////////////////
void TIMER32_0_IRQHandler(void)
{
  LPC_TMR32B0->IR = 1;
   u8 a0 =  FileReadByte();
   u8 a1=  FileReadByte();
   data_sptr=(a0<<8)|a1;
dac_out(data_sptr);
  return;
}
0 件の賞賛
返信
2 返答(返信)

1,104件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by bobi-one on Fri Nov 29 07:43:57 MST 2013
Hi the screen attached is the continuous  dac write, and the time  when fileLoad is called to read 512bytes( causing the dac to delay).
I dont have dma at the moment so i am trying  to improvise.
The DAC routine is optimized as much it could be done for software SPI
void dac_send(u16 val)
{
 int bit =0;

DAC_CS0;
mcpDacSendBit(val, 15);
mcpDacSendBit(val, 14);
mcpDacSendBit(val, 13);
mcpDacSendBit(val, 12);
mcpDacSendBit(val, 11);
mcpDacSendBit(val, 10);
mcpDacSendBit(val, 9);
mcpDacSendBit(val, 8);
mcpDacSendBit(val, 7);
mcpDacSendBit(val, 6);
mcpDacSendBit(val, 5);
mcpDacSendBit(val, 4);
mcpDacSendBit(val, 3);
mcpDacSendBit(val, 2);
mcpDacSendBit(val, 1);
mcpDacSendBit(val, 0);

DAC_CS1;

}
it takes  around 10uS to send
The SD transfer takes around 2,4mS ( the gaps in the DAC routine).
btw: i pasted FileWrite, FileRead is on the same principle using the  buffer marker and FileLoad.
0 件の賞賛
返信

1,104件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Pacman on Fri Nov 29 07:30:35 MST 2013
In your case, it might be the easiest to read one buffer ahead.
Eg. start by reading one buffer. Don't start playing.
Read another buffer, now start playing the first buffer.

You could perhaps use two pointers, a pointer to the next buffer to play, and a pointer to the next buffer to read into.

The normal way of doing this is to have a looping DMA buffer, and using a DMA interrupt to signal that all data has been buffered. When all data are buffered, more data is calculated or read from disk/sd/flash.

Note: You're not listing the most interesting part of the program. It would be more useful to see the reading routine and the routine that sends the data to the DAC. You might be able to speed the routines up a bit.
0 件の賞賛
返信