<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: SD Wave Player in LPCXpresso IDE</title>
    <link>https://community.nxp.com/t5/LPCXpresso-IDE/SD-Wave-Player/m-p/542463#M7858</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by bobi-one on Fri Nov 29 07:43:57 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi the screen attached is the continuous&amp;nbsp; dac write, and the time&amp;nbsp; when fileLoad is called to read 512bytes( causing the dac to delay).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I dont have dma at the moment so i am trying&amp;nbsp; to improvise. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The DAC routine is optimized as much it could be done for software SPI&lt;/SPAN&gt;&lt;BR /&gt;&lt;DIV class="j-rte-table"&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca" style="border:1px solid black;background-color:#cacaca;"&gt; &lt;PRE&gt;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;

}&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;SPAN&gt; it takes&amp;nbsp; around 10uS to send&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The SD transfer takes around 2,4mS ( the gaps in the DAC routine).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;btw: i pasted FileWrite, FileRead is on the same principle using the&amp;nbsp; buffer marker and FileLoad.&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 16 Jun 2016 00:28:33 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-16T00:28:33Z</dc:date>
    <item>
      <title>SD Wave Player</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/SD-Wave-Player/m-p/542461#M7856</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by bobi-one on Fri Nov 29 01:46:55 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi All,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to design a wave player that can play 2 wave files simultaneously ( the end project will be&amp;nbsp; on LPC1769).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;But in the mean time I am trying to make simple wave player with LPC1343&amp;nbsp; to play one file continiosly. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I Connected SDcard to the MMC&amp;nbsp; and used the code for it from adafruits microtouch.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I made software SPI for the DAC&amp;nbsp;&amp;nbsp; because&amp;nbsp; LPC1343 have only one. So the thing I am stuck is:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have timer32B0 interrupting&amp;nbsp; with 22050 sample rate to set the DAC value.&amp;nbsp; But when&amp;nbsp; all the vallues from the&amp;nbsp; sd buffer[512] are sent,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;another sequence to read 512 more&amp;nbsp; from the card is called. And that causes delay. I am open for ideas how to read&amp;nbsp; bytes from the buffer. and make DAC feeding consistent &lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;void FileWriteByte(byte b)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (_mark == 512)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FileLoad(_sector + 1); //read 512 more
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (b != _buffer[_mark])
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _dirty = 1;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _buffer[_mark] = b;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; _mark++;
}
///////////////////////////////////////////////////////////////////
void TIMER32_0_IRQHandler(void)
{
&amp;nbsp; LPC_TMR32B0-&amp;gt;IR = 1;
&amp;nbsp;&amp;nbsp; u8 a0 =&amp;nbsp; FileReadByte();
&amp;nbsp;&amp;nbsp; u8 a1=&amp;nbsp; FileReadByte();
&amp;nbsp;&amp;nbsp; data_sptr=(a0&amp;lt;&amp;lt;8)|a1;
dac_out(data_sptr);
&amp;nbsp; return;
}
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 00:28:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/SD-Wave-Player/m-p/542461#M7856</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T00:28:32Z</dc:date>
    </item>
    <item>
      <title>Re: SD Wave Player</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/SD-Wave-Player/m-p/542462#M7857</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by Pacman on Fri Nov 29 07:30:35 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;In your case, it might be the easiest to read one buffer ahead.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Eg. start by reading one buffer. Don't start playing.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Read another buffer, now start playing the first buffer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You could perhaps use two pointers, a pointer to the next buffer to play, and a pointer to the next buffer to read into.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;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.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;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.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 00:28:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/SD-Wave-Player/m-p/542462#M7857</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T00:28:33Z</dc:date>
    </item>
    <item>
      <title>Re: SD Wave Player</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/SD-Wave-Player/m-p/542463#M7858</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by bobi-one on Fri Nov 29 07:43:57 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi the screen attached is the continuous&amp;nbsp; dac write, and the time&amp;nbsp; when fileLoad is called to read 512bytes( causing the dac to delay).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I dont have dma at the moment so i am trying&amp;nbsp; to improvise. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The DAC routine is optimized as much it could be done for software SPI&lt;/SPAN&gt;&lt;BR /&gt;&lt;DIV class="j-rte-table"&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca" style="border:1px solid black;background-color:#cacaca;"&gt; &lt;PRE&gt;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;

}&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;SPAN&gt; it takes&amp;nbsp; around 10uS to send&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The SD transfer takes around 2,4mS ( the gaps in the DAC routine).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;btw: i pasted FileWrite, FileRead is on the same principle using the&amp;nbsp; buffer marker and FileLoad.&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 00:28:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/SD-Wave-Player/m-p/542463#M7858</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T00:28:33Z</dc:date>
    </item>
  </channel>
</rss>

