This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How to get the circular buffer pointer to go outside of the prescribed range.

I'm pretty sure on this I have a certain sequence and a circular buffer pointer will go outside of the range limit. I looked at some errat sheets but I didn't see this listed.

A "C" program will call an ASM routine. The C program passes a structure of the form

struct {

long ArrayPtr;

long Arrary[256];

};

Here is the problem ASM code and the above structure is passed in AR1.

1: OR #0002h,mmap(ST2_55)    ; enable AR1 for circular

2: MOV dbl(*AR1+),AC0                 ; This reads the index from the above struture and now AR1 points to Array[0]. For me AR1=0x146DA

3: mov mmap(AR1),BSA01           ; set the cirular base address

4: Mov #512,BK03                          ; length of the circular addressing

5: MOV dbl(*AR1+),AC1                ; Now look at AR1 and it's 0x144DC so it subtracted 512 and added 2 and it's out of range of 0x146DA + 512.

 

It looks like at line 2 it sets a trigger to tell it to do the 512 subtraction. Then at line 5 when it increment AR1+ it's subtracting 512 and adding 2. AR1 should be 0x146DC but it's 0x144DC.

My expectaion was that it only does the check with a *AR1+.

Also when this happens BSA01=0 and BK03=0 before they are changed at lines 3 and 4 but I'm not sure that makes a difference.

 

  • I think I have figured out that in the above I was using the circular buffer incorrectly and the following is correct:

    MOV AR1,BSA01

    MOV #0,AR1          ; Now the address is formed as the SUM of BSA01 and LOW AR1

    MOV #512,BK03  ; Now AR1 will set back to 0 when it hits 0x200.

    I have looked all over for a document that clearly says that address is BSA01 + AR1. Document SPRU374g Section 3.5 talks about circular addressing but it never really says that the address is the SUM. So an example in section 3.5 would be nice.

    Can you point me to a document that really describes circular addressing so I can be sure I'm doing it correctly now? I've looked at a bunch of documents but only SPRU374g says something about the address being the sum of BSA01 and the active ARx register but its sort of buried in specific instructions.

    I also tried BSA01=0 and ARx being the address but that would not wrap around.

  • The CPU Reference Guide (http://www-s.ti.com/sc/techlit/spru371) has details on the HW implementation in section 6.11.

    Regards.