AnsweredAssumed Answered

Accessing TigerSHARC registers in C

Question asked by Joel.K on Nov 5, 2013
Latest reply on Dec 18, 2013 by MaheshN

I am programming for the TS201 in C. I need to write to the timer registers (and in the future likely many more).


I have found two methods which I'll illustrate by example. My application is and will always be single-processor (processor 0).


Method 1.


__builtin_sysreg_write (__TIMER0L, 0x12345678);


Method 2.


// 0x10000000 is the processor 0 offset into the universal register space.

// TIMER0L_LOC is defined in ADI's header file.

#define TSREG_TIMER0L (*((volatile TUInt32*)(0x10000000 + TIMER0L_LOC)))


TSREG_TIMER0L = 0x12345678;


I suppose there's a third method likely possible using inline assembly.


I am wondering if there is a significant performance difference between methods 1 and 2. Does method 2 use the SOC bus and access the register as if it's external? Or is the processor smart enough to realize that it's accessing its own universal register, and so it does not bother going external? If it does use the SOC bus, is that a big deal?


I like Method 2 because it looks cleaner. But I don't want to give up significant performance.