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.

TMS320F28377D: C2000 ASSEMBLER HELP: Adding an Address in one instruction.

Part Number: TMS320F28377D
Other Parts Discussed in Thread: C2000WARE

Hi Guys, my F28377D is up and running. I'm an assembler programmer and LOVE the C2000 syntax. 

I've connected PORTA to an external SRAMs address lines and want to auto increment the address using one instruction.

What I'm trying to do in assembler is auto increment XAR6 by one and storing it on PORTA data port which is connected to the external SRAMS address lines.

This is how I'm doing it in 2 instructions but I would like to do it in one instruction.

My code: 

MOVL XAR6,#0

MOVW AL,#1

MOVW AH,#0 ; ACC = 1

MOVL XAR2,GPADAT ; ADDRESS OF PORTA DATA PORT 32BIT. GPIOA IS SET TO OUTPUT BTW.

LOOP:

MOVL *XAR2,XAR6 ; PUTS XAR6 ON TO PORTA WHICH SETS THE EXTERNAL SRAM ADDRESS.

ADDL XAR6,ACC     ; INCREMENTS SRAM ADDRESS BY ONE. ACC=1. 32BIT ADD INSTRUCTION.

B LOOP,UNC.          ; BRANCH BACK TO LOOP 

What I'm doing is that I have PORTA 22bits connected to an SRAMS address lines and I want it auto increment the address lines by one but using only one instruction.

I tried to auto increment XAR6 with ++ but the assembler using CC9 said it's not possible to do.

I tried this MOVL*XAR2,XAR6++ ; THIS IS NOT POSSIBLE TO DO. If it would work then it would auto increment XAR6 and store it on PORTA in one instruction,

But it doesn't allow that syntax. Does anyone know how to do it on ONE instruction? It will save a lot of machine cycles doing it in one instruction.

Thanks and I hope to hear from an assembler wizard soon. :)

Pete

  • Pete,

    Unfortunately there's no indirect addressing mode which will do this with a 32-bit move. I can think of a couple of things which may help.

    1) Given that two instructions are required, you can eliminate the looping overhead by using the RPTB with, say, four instruction pairs. Something like:

    RPTB LOOP01, #33
    MOVL *XAR2, XAR6
    ADDL XAR6, ACC
    MOVL *XAR2, XAR6
    ADDL XAR6, ACC
    MOVL *XAR2, XAR6
    ADDL XAR6, ACC
    MOVL *XAR2, XAR6
    ADDL XAR6, ACC

    LOOP01:

    Obviously this would implement a multiple of four moves, but you could follow the loop with 1 - 3 additional move pairs if you have a non-multiple of four to do. This would eliminate the branching overhead.

    2) If you have a long sequence of moves to do, you could set up a DMA channel to do this. You'd just have to initialize and trigger the channel and all the overhead would be gone. I can't point you towards an example which does exactly what you want, but there is a DMA channel example in C2000Ware for this device which may help.

    Regards,

    Richard

  • Hi Richard, thanks for your help. I tried the RPTB instruction and my assembler says its out of block range 8...127 even tho I chose #33 for testing. So that didn't work. I have managed to speed up the code by replacing ADDL XAR6,ACC with ADDB XAR6,#1. Now its one cycle per instruction. This sped the code up dramatically but it's still not fast enough for what I want it to do. Oh, I'm feeding a VGA DAC directly from the output of a SRAM chip, thats why I need to change the SRAM address using the 22bit XAR6 register.

    I'll check out the DMA example you mentioned and see how that goes. If not I'll have to research for faster chip, maybe a RISC V. 

    Thanks mate

    Pete

  • Hi Pete,

    You need either 8 or 9 words, depending on alignment, between the RPTB instruction and the label at the end of the block.  In my code there were 8 instructions and it built fine for me.  If you had a different alignment you might have got this error, in which case you could add another pair of instructions and it should go away.  I still think this is worth a try because RPTB provides zero overhead looping so it should make a big difference.

    Anyway, I'll go ahead and close this thread.  Feel free to open another one if you run into further issues or need anything else.  Thanks.

    Regards,

    Richard

  • Thank you Richard, I'll try it again. Hopefully it'll speed up the process.

    Oh, while I've got you. Does TI have a faster MPU with 32bit IO ports? If the F728377D is not fast enough I'll have to use a faster MPU and I would like to use TI MPU's with our product.

    Thanks again for all your help.

    Pete

  • Hi Pete,

    Regret I'm not very familiar with the other TI platforms.  I see your other post on the subject and hopefully you'll get some good ideas from that.  Thanks.

    Regards,

    Richard