Technical discussions about the TI C54x DSPs (including the c5401, c5402, c5402a, c5404, c5407, c5409, c5409a, c5410, c5410a, c5416, c5420, c5421, c5441, c549, c5470 and c5471).
|
Hi all, I've read lots of topics regarding circular addressing and all of them made me enthusiastic about it. The bad thing is that they all give just the principle behind it but they don't actually give any hint as to how to implement it (especially in C language). I don't know much assembly so circular addressing seems to be "can-see-it-but-can't-have-it" thing for me. So far i just "fake' circular addressing in C. Is it just not possible to realize it in C? leonor |
|
|
|
On Tue, 21 May 2002 04:33:55 +0100 (BST), you wrote: >Hi all, > >I've read lots of topics regarding circular addressing and all of them made me enthusiastic about it. The bad thing is that they all give just the principle behind it but they don't actually give any hint as to how to implement it (especially in C language). I don't know much assembly so circular addressing seems to be "can-see-it-but-can't-have-it" thing for me. So far i just "fake' circular addressing in C. Is it just not possible to realize it in C? With CCS 1.21 I have never seen a way to do it in C. Doing it in assembly isn't too hard. Here's a simple FIR filter example: BK = #41 ; 41 tap low pass filter AR2 = data(*(lptxin_ptr)) nop *AR2+% = A ; Overwrite oldest data data(*(lptxin_ptr)) = AR2 ; Save the pointer for next time A = #0 repeat(#40) ; 41 tap lowpass filter macp(*AR2+%,LP4500,A) A = A << #-16 ; Make it 16 bits again lptxin_ptr points to a block of memory that is aligned on a 64 word boundary. LP4500 is a label referencing the constants for the FIR filter. Make sure these constants are in a different DARAM page from the RAM storage and code (if running this code from RAM as I do for speed). The circular magic is the *AR2+% instruction, it tells it to increment the AR2 value, but use the BK circular buffer size to wrap the address around when it hits the end. I use algebraic assembly because I came to the TI parts from Analog Devices parts, and it is easier to read than mnemonic instructions. You can change the behavior of the compiler using the per-file properties or the compiler options to select algebraic assembly by default. Hope this helps some, Brian ----------------------------------------------------- Brian C. Lane (KC7TYU) Programmer www.shinemicro.com RF, DSP & Microcontroller Design |
|
Indeed i have 'faked' circular buffers in C. Having done some optimizations, like data declarations, invoking the -o3 option, i found that the "circular buffers" took the bulk of the cycles. the code met its real-time dead line but it is also good to take advantage of the feature especially when those cycles can be used in other tasks that can be added. Since I could not have the real circular buffer in pure C, I may have to in-line assembly code. I already know how to in-line assembly code but dont know yet the logic of setting-up the circular buffer. Can anyone give the steps of setting up the circular buffer? (detailed steps, if possible). I have seen a sample FIR assembly code but it looks horrible. Thanks, leonor |