> -----Original Message----- > From: piclist-bounces@mit.edu [mailto:piclist-bounces@mit.edu] On Behalf > Of Richard Seriani, Sr. > Sent: 22 January 2008 11:33 > To: Microcontroller discussion list - Public. > Subject: Re: [PIC] Audio ADC-DAC Problems > > Mike, > > According to the 25LC1024 datasheet, the internal write cycle time (byte > or > page) is 6ms (max). I am doing page writes, so I load 256 bytes of > converted > data into the EEPROM input buffer, bring !CS high to initiate the internal > write, then poll the status register WIP bit to check that the write is > complete. > > Hmm, this means I am losing somewhere around 6ms of input for each 256 > bytes > I am recording. Quick math shows that if I record about 31.25ms of audio > for > each 256 bytes, I have about a 20% hole in the data. Does that sound > right? > > Okay, sounds like I need to look at some sort of double-buffering of the > a-d > data? I think I may be able to load the 25LC1024 input buffer while the > array write is taking place, but I need to check that. If so, that may be > one solution that could be implemented simply by shifting a few > instructions > in my code. I would load the buffer, then check the WIP bit to be sure the > write to the array is complete before I initiate the next write. The write > sould be complete since the conversion of 256 bytes will take about 5 > times > as long as the EEPROM write cycle, so I may be able to get away without > checking it, though I am not sure I would want to. > > Thanks for making me think about this. I'd be very surprised if you can write to the buffer during a write operation. Serial EEPROMs with SPI interfaces generally only let you read the status register during a write cycle, but the datasheet will certainly tell you one way or the other. However, all is not lost. 6ms at 8Khz is only 48 samples. Simply implement a circular buffer (a little larger than 48 samples for safety), with the ADC inserting data into the buffer, and the SPI taking data out. Whilst the EEPROM is not writing the buffer will never be more than one byte full assuming you have a reasonable SPI clock rate. Once the page write commences the ADC will start filling up the buffer, but once full the SPI will be able to empty it very quickly. If available, use the CCP modules special event trigger to take ADC conversions at a regular rate, and use the ADC interrupt to put data into the buffer, and the SPI interrupt to take data out. The whole recording process then runs totally under interrupt control, so you can carry on doing stuff in your main loop. Regards Mike ======================================================================= This e-mail is intended for the person it is addressed to only. The information contained in it may be confidential and/or protected by law. If you are not the intended recipient of this message, you must not make any use of this information, or copy or show it to any person. Please contact us immediately to tell us that you have received this e-mail, and return the original to us. Any use, forwarding, printing or copying of this message is strictly prohibited. No part of this message can be considered a request for goods or services. ======================================================================= -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist