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.

C6415T: Minimum time for register accesses

Hello,

I am using a C6415T running at 1GHz with Code Composer 5. I have a function that makes 3 PCR register accesses on McBSP1, 1 write and 2 reads. The code currently takes about 440 nsec to run. I believe I have optimized this as far as possible. I'm using -O3 optimization level in code composer and have as few lines of code as possible. I was wondering what the minimum time a peripheral register access should take (from what I'm seeing I'd assume 100-125 nsec) and if the 440 nsec I'm seeing is reasonable as a minimum amount of time assuming I have a few other lines of code clearing and setting bits.

Thanks,

Chris

Signalogic

  • Chris,

    100-125 ns does seem like a long time, but without your datapoint my guess would have been that 40-50 DSP cycles is realistic. So 100-125 is not out of the question.

    This interface is referred to as the Config Bus, and it is not speed-optimized like the memory interface. It is a slow interface and it is shared with accesses to other peripherals.

    There is a write buffer in the interface, and my recollection is that it holds about 7 words. Any subsequent reads will flush that write buffer and will incur the delay by stalling the DSP until all writes are completed and then further until the read completes.

    Is it possible that your "other lines of code clearing and setting bits" left writes in the write buffer and your measurement method is not starting from a completely static state? You could test this by inserting a long delay loop just before starting the measurement for your 1 write + 2 reads.

    Can you rearrange those to be 2 reads + 1 write? If so, you will leave an in-flight write in the write buffer but the DSP can continue its work. This is usually not feasible, but it was worth asking.

    How are you measuring your delays?

    Regards,
    RandyP

  • Randy,

    I am measuring my delays by reading the value of the timer0 count register before and after the function call. I'm thinking that these register reads probably added some extra time to my initial measurements which may have caused them to be off.

    Unfortunately, I cannot rearrange the order to anything other than 1 read - 1 write - 1 read. I'm calling two functions (write and read). The write function reads the register, sets or clears a bit on the read value, and writes that value back to the register. The read function only reads the register and masks out a specific bit. The order of these two function calls (write then read) cannot be changed because the call to read is to check to make sure that what was written to an output pin shows up on an input pin through a loop-back connection.

    Comparing one call to the read function that only reads and masks out a bit once to another call to the read function that reads and masks out a bit twice I see a difference of about 25 ns so I think my initial measurements were off; however, this is about half of what you said you would've guessed so I'm not sure if this is correct either.

    So a new question, does 25 ns sound reasonable or even possible with -O3 (optimization level) and -mf 5 (optimize for speed) for 1 peripheral register read (specifically the PCR register of McBSP1)?

    Thanks,

    Chris

    Signalogic

  • Chris,

    Reading the timer0 TIM register will take about as much time as reading the PCR register of McBSP1. You can get the measurement overhead by reading timer0 twice and subtracting the two times, then adjust your benchmarks by subtracting that difference.

    The read function with masking of some bits should be predictable in duration. A couple of ways to know how well-optimized the code is would be to measure the time with the read being from memory, or by looking at the assembly code to see if it has any wasteful instructions.

    My numbers are guesses from a 6-7 year-old memory of working with the C6416. Your explicit measurements are what I would trust after ensuring that nothing else is going on during the measurement period. Include a delay loop before the test to make sure everything is out of the system, for example.

    I am very confused about what your measurements are or what they represent. This is a big change from 400ns to 25ns or 75ns. 25ns for one Config Bus read does not sound too high.

    This is not a very clear reply to you, but it is because I am not sure what the numbers are telling you, and me.

    Regards,
    RandyP

  • Randy,

    The original 400 ns measurement included the function calls to write and read as well as the timer0 register reads. I used the same method of measurement (using the timer0 count register) and got the time for a call to read for only 1 pin and the time for a call to read for 2 pins. The 25 ns is the difference between these two times which comes down to one extra read of the PCR register and masking of a bit.

    My read function can take one or multiple pins as a parameter and the difference is extra iterations through a loop that reads the register and masks the desired bit. I probably should've mentioned this to make it more clear.

    Thanks for the help,

    -Chris

  • Chris,

    It is good that you consider your question answered. I do not feel that I have been much help here.

    Is there a way that your read routine can use a single read of the PCR register into a temporary register, then use that local copy for masking for the one or more pins? The time to read PCR is the big time user of this routine, so minimizing the number of times you have to access the Config Bus will help your system performance.

    Best of luck to you.

    Regards,
    RandyP