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.

Compiler/TMS320F28020: How to use DMAC assembly instruction?

Part Number: TMS320F28020

Tool/software: TI C/C++ Compiler

Dear TI,

My name is Phu Nguyen, i writing code for chip TMS320F28020 by assembly language. I have a problem when i read DMAC instruction (page 187 at TMS320C28x CPU and Instruction Set).

As this picture, i understand that VarA_1 =  XT[31:16], VarA_2 = XT[15:0], VarB_1 = Prog[XAR7], but i can't know value of VarB_2 = ? (1)

Can you explain for me this question (1)? 

Thank you and best regards,

Phu Nguyen

  • Dear Phu Nguyen,

    The DMAC instruction uses XAR7 to read a 32-bit memory location in program space. With reference to the diagram in your post, VarB_2 is the lower 16-bits of the 32-bit word addressed by XAR7. The data is accessed in the same way as loc32.

    Regards,

    Richard
  • Dear Richard,

    As TI's document TMS320C28x CPU and Instruction Set page 17. I know that program memory is 16-bit for each 22-bit address. So why you said 32-bit memory location in program space. Can you explain for me this problem?

    Thank you and best regards,

    Phu Nguyen
  • Dear Phu Nguyen,

    The smallest addressable memory unit on C28x is 16-bits wide, however both 16-bit and 32-bit accesses are possible in both program and data space. When the DMAC instruction performs a read using *XAR7, it is making a 32-bit access. On p.18 of that document you'll see this mentioned. Also note that all data busses are 32-bits wide.

    Regards,

    Richard
  • Dear Richard,

    As your answer, i can read data memory via 1 address 32-bit and i will take 1 value 32-bit?
    Example: if i put address to data memory: 0x0000 0000C, i will have data is 0x12345678 (example value)
    I think i only receive 0x5678 (example value)

    Can you explain me this issue?

    Thank you so much,

    Phu Nguyen
  • Dear Phu Nguyen,

    You can read either 32-bits or 16-bits. For example, if you did have the address/data combination above:

    MOVW DP, #0
    MOV AL, @0xC
    MOVL P, @0xC

    This performs consecutive 16-bit and 32-bit reads from the same address, and would leave 0x5678 in AL and 0x12345678 in P.

    Regards,

    Richard
  • Dear Richard,

    I still can't understand width of data memory. If you said 32-bit width then why i put a value to SP, this value is split to 2 phase, and put 16-bit each phase. SP++ when put 16-bit in to data memory.

    Can you explain me?

    Thank you so much,

    Phu Nguyen
  • Dear Phu Nguyen,

    No problem. It's a little different with C28x. Firstly, SP++ is an addressing mode, not an operation. You can write data to the stack using [SP] together with either a 16-bit or 32-bit move operation. For example:

    MOVL *SP++, P

    ...will perform a 32-bit move to the stack, and post-increment SP by 2 (16-bit words). Whereas...

    MOV *SP++, AL

    ...will perform a 16-bit move to the stack, and post-increment SP by 1 (16-bit word).

    Again, the basic memory width is 16-bits, and the instruction set contains operations to perform either 16-bit or 32-bit accesses. A 32-bit access will be single cycle if the data is aligned to an even word boundary. For example, if you have this:

    Addr Data
    0xC 0x1234
    0xD 0x5678
    0xE 0x9ABC

    ...a 32-bit read from @0xC will be single cycle, whereas a 32-bit read from 0xD will take 2 cycles. Both operations will yield 0x56781234.

    Feel free to post back if it's still unclear.

    Regards,

    Richard