In an ongoing project, I need to write code to process incoming audio data at a sampling frequency of 8 kHz by adding a delayed element for some simple audio effects using a circular buffer.
As suggested in a previous thread, I was able to configure the ADC on my processor (LPC2148 - Datasheet) to trigger at the sampling interval of 125 us using a timer match bit built into the ADC. As I was just testing out all the peripheral functions first I used a simple polling routine for the purpose. I also configured and used the Timer interrupts for a toggle LED program. Now I need to put all the parts together and get it to work. For this purpose, what is the best way I could structure my code?
My current code design is somewhat like this:
The buffer is 1024 element long, that gives a maximum delay of 128 ms. Is there any alternative/better way to write the same code?
Thanks.
As suggested in a previous thread, I was able to configure the ADC on my processor (LPC2148 - Datasheet) to trigger at the sampling interval of 125 us using a timer match bit built into the ADC. As I was just testing out all the peripheral functions first I used a simple polling routine for the purpose. I also configured and used the Timer interrupts for a toggle LED program. Now I need to put all the parts together and get it to work. For this purpose, what is the best way I could structure my code?
My current code design is somewhat like this:
Rich (BB code):
Main:
Configure ADC, DAC and Timer interrupt at sampling interval = 125 us
Configure circular buffer
ISR:
Read the ADC value
Write it into a buffer
Generate the DAC value (ADC_val + previous Buffer_val)
Thanks.