ΣSigmaStudio Ask AI Русский Log in

Accessing TigerSHARC registers in C

Processors & DSP Joel.K Nov 5, 2013 00:00 1 replies Original on forum ↗
Subscribe
Joel.K Question
Nov 5, 2013 00:00

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.

Thanks,

Joel

c

ts201

registers

ADIApproved Reply
Dec 17, 2013 00:00

Hi Joel ,

Apologies for the delay in answering your query .

I have attached a screenshot of the program which uses both these methods to set a value to a register . When you see in the disassembly ,the second method uses one extra J-ALU access and one cycle extra than the first method . I feel that first method may be better compared to the second method. But it will not use the SOC Bus . SOC Bus will be used if you are accessing External Port ,External DMA or the Link Ports .

Regards,

Mahesh