Reply by Keith E. Larson April 18, 20022002-04-18
Hello Husnain

Linker Command Files
--------------------
When it comes to linker command files I find that many people (as we say
here) make mountains out of ant hills. A simple linker file looks like the
one below. The one thing to look out for though is that you should always
have a look at your map file to see if all the named sections are given some
place to load to. You need only add those that have size, but I would add
them all just the same. I say this because the linker does NOT inform you
when a section has not been allocated! When this happens I believe the
default is to link the section to address zero, which I doubt is going to be
very usefull. (Interestingly this has never been fixed on any TI DSP
linker!) As you can see, unless you are trying to do some fancy relocation
of section XYZ of ABC.OBJ, you dont have much to figure out. (IOW make life
and the linker easy!)

tlog.obj tlogx.obj tfloat3x.obj tmpy.obj texp.obj
-cr
-o tfloat3x.out
-l rts30.lib
MEMORY
{
ROM : org=0x00000000, len=0x1000 /* Boot rom or external */
RAM2 : org=0x00800000, len=0x4000 /* 16K internal */
RAM3 : org=0x00804000, len=0x4000 /* 16K internal */
RAM0 : org=0x00809800, len=0x0400 /* INTERNAL BLK 0 */
RAM1 : org=0x00809C00, len=0x0400 /* INTERNAL BLK 1 */
}
SECTIONS
{
vectors: {} > ROM
.text : {} > RAM01 /* All .text sections from all OBJ's */
.data : {} > RAM01 /* All .data sections from all OBJ's */
.bss : {} > RAM01
.stack : {} > RAM01
.cinit : {} > RAM01
}

Slow DMA Time
-------------
The #1 thing people miss with the external bus is that on reset it defaults
to 7 wait states. Multiplying out # words, cycle time, cycles/readwrite and
# wait states gives:

Tdx10^3*40ns*4*(7+1) = 81ms, still far below 8 seconds

If on the other hand I use the 3us time of the host bus I get 6 seconds
which is very close to your time. I suspect that you are hanging the bus
(IE stalled in a not ready condition) with the PC host code. Remember that
there is only one bus on this device!

Measuring Time (short times that is!)
-
A method is described in the DSK where you can get 1 cycle accuracy from the
timers even though the timers count once every 2 cycles. The principle
behind this is that if the CPU can read the timer count on two consecutive
counts, it can capture the timer increment. When you use this routine,
resist the temptation to immediately divide by two as this will destroy the
timer carry if present. Do all your time calculations in 2x time and only
divide by 2 after. You also need to have the timer period set greater than
the expected time you want to measure. One last hint. If the timer rolls
through zero, the count will be negative. You can detect the negative cound
and add back the timer period to correct even this!

GET_TIME:
ldi @T0_COUNT,R0 ; Present count
addi @T0_COUNT,R0 ; Present or next count
rets ; return time accurate to 1 cycle

main
call GET_TIME
ldi R0,R1
;;
;; Your code
;;
call GET_TIME
subi R1,R0
lsh -1,R0 ; R0= T2-T1+OFFSET accurate to 1 cycle
b main ;

Best regards
Keith Larson
------------
At 02:56 AM 4/18/02 +0000, you wrote:
Hello Sir,

I am running the DMA is SYNC0 mode,so I dont think I have to enable DMA
interrupt.I have been able to figure out the problem which I mentioned in my
last mail.Actually I was running my timer with maximum frequency.Therefore
Timer's ISR was contantly being serviced.When I lowered that frequency,DMA
came into action.

As I mentioned in my previous mail that what I was aiming at was to
calculate the TIME spent while DMA transfers data.I have run the program in
Code Composer and transfered 900 words.Timer generated four interrupts with
a time period of 20.48 microseconds.That makes it approximately 82
microseconds.In C3x's User Guide its mentioned that DMA tarnsfers data from
onchip memory to onchip memory in two cycles.For 900 words it makes 72
microseconds.So I think so far so good.My result is fairly accurate. Data
Transfer rate comes out to be approximately 11Mwords/sec.

Next I tried to calculate the time spent while data is transfered from PC to
DSP.As you might be knowing(I mailed you about it)that I am using TIGER31/PC
from DSP Research.This board uses a data transfer register for Host-DSP
communications.Register is memory mapped in both PC's and DSP's memory.
This board fits in ISA slot of PC.The rate I calculated for this transfer is
0.295Mwords/sec.Infact I wrote into that register in a loop(In my host
program),TIGER31/PC hardware generates an interrupt when this register gets
full (interestingly this interrupt works even without enabling GIE bit in
ST).This interrupts makes DMA read this register,as DMA is run in SYNC1
mode.In this way using these interrupts DMA reads and writes that data in
its memory.So in this scheme of things what do you think how accurate my
result is????

Lastly in the linker command file I am using,the length of external memory
is defined as 32k(TIGER31/PC has 256K of SRAM onboard),so will I have to
increase this length to be able to use more then 32k of memory.I am asking
this 'coz I have been posting DSPR tech support to inform me of any
changes,I need to make in linker command file to be able to use more than
32k of memory.If I use big memory model,what will be the changes I will have
to make in linker command file.I am asking this 'coz after transfering data
from onchip memory to onchip memory,I tried transferring data from Onboard
SRAM to OnBoard SRAM in Code Composer.I tried different things,first I
increase the length of SRAM in linker command file,it doesnt work.Then I use
big memory model,in that case code worked but DMA transfered NOT more then
62433 words!!!!!!! Time spent was also enormous,I mean 60,000 words transfer
took some good eight seconds!!!Then I found out that I have to build all
library modules with big memory model,as I did that,code didnt run at all!!
So I dont know in all this where exactly I need to make amends to be able to
transfer data from external onboard RAM to external onboard RAM.

I will be thankful,if you get some time to answer these questions.

Best Regards.

Husnain Alam
DSP Engineer,
Research Department,
NUST, Rawalpindi.
Pakistan.
Ph.+92-51-2251541(Res)
_________________________________________________________________
MSN Photos is the easiest way to share and print your photos:
http://photos.msn.com/support/worldwide.aspx
+-----------+
|Keith Larson |
|Member Group Technical Staff |
|Texas Instruments Incorporated |
| |
| 281-274-3288 |
| |
| www.micro.ti.com/~klarson |
|-----------+
| TMS320C3x/C4x/VC33 Applications |
| |
| TMS320VC33 |
| The lowest cost and lowest power 500 uw/mflop |
| floating point DSP on the planet! |
+-----------+