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.

CCS/TMS320F28020: How to use interrupt Timer/Counter by assembly instruction set C28x?

Part Number: TMS320F28020

Tool/software: Code Composer Studio

Dear all of supporter,

This is Phu Nguyen. I have problem with C28x instruction set assembly. I want to set timer by assembly but i can't find out instruction for it. I have read carefully material from "TMS320C28x CPU and Instruction Set". But i don't find out instruction for set timer/counter.

Can you give me a way to set up timer/counter by assembly C28x (i only use assembly and don't use C/C++ language)?

Thank you and best regards,

Phu Nguyen

  • Hi Phu Nguyen,

    In CPU start timer we write into a register as
    HWREGH(CPUTIMER0_BASE + CPUTIMER_O_TCR) &= ~CPUTIMER_TCR_TSS; where CPUTIMER_TCR_TSS = 0x10U
    i.e. writing 0 into 4th bit in CPUTIMER_O_TCR register.

    For more infomation look into the cputime code to get to know the register values.
    So, If you can do the same in assembly, it is equivalent to starting the timer.

    Hope this information helps.

    Thanks,
    Katta
  • Dear supporter,

    I need a instruction do this way by assembly, i don't have allow code by C/C++. Please give me instruction to do it and material about timer C28x CPU.

    Thank you so much,

    Phu Nguyen
  • Hi Phu Nguyen,

    Please use this assembly code to start the timer.

    ;//Reload the counter
    MOVB ACC, #4
    ADDL ACC, #0x0C00
    MOVL XAR4, @ACC
    OR *+XAR4[0], #0x0020

    ;//Clear TSS bit of register TCR
    MOVB ACC, #4
    ADDL ACC, #0x0C00
    MOVL XAR4, @ACC
    AND *+XAR4[0], #0xffef

    The above code writes in to CPUTimer0.

    If you want to use CPUTimer 1 use 0x0C08 instead of 0x0C00
    If you want to use CPUTimer 2 use 0x0C10 instead of 0x0C00

    CPUTimer information can be found at section 2.8 and 2.15.2 at www.ti.com/.../spruhm8g.pdf

    Hope this helps.

    Thanks,
    Katta