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.

Help with asm - ISR call sig gen lib function

Hi There

Im looking at using the C28x signal generator library with the F2802x with a project that originally  forked from the DC/DC Multi-Led example

Instead of having a dedicated loop or ISR as shown in the examples fo the signal generator library, I would like to have it use the asm ISR  already used in the DC/DC Multi-LED example

I have tried to add the a call to the SGENTI_1_calc defined in sgti1c asm file but it is not recognised.

Im very unsure of what I am doing with this assembly (I have only used 8051 asm before MUCH simpler!)

How can I make the signal generator asm routines available to the DPL_ISR.asm? and should I handle a return value?

Thanks

EDIT: What I have done so far is add the SGEN Lib asm directory to the compiler include search path and used '.include "sgtic.asm"' at the start of the DPL_ISR asm file.

I though this would give access to the routine  _SGENTI_1_calc that is def'd in sgti1c.asm, but if I insert "SGENTI_1_calc" into the DPL_ISR asm code the assembler says that this  is an Invalid mnemonic.... :(

  • Hi Toby,

    If you are including the SGEN.lib in your project, your assembly ISR file must include sgen.h so .include "sgen.h" and you then call the function using the following mnemonic

      LCR    _SGENTI_1_calc

    Now if you were calling this function in a C context the compiler would load the argument, a pointer to the SGENT_1 structure, into the register XAR4. In assembly you need to load the argument yourself.

    The easiest way to do all this is to write a C function that creates an object of the structure SGENT_1, initializes it and then pass it to the function SGENTI_1_calc. Then, in the project properties:

    1. go to C2000 Compiler->Advanced Options->Assembler Options and check the option --keep_asm
    2. In the source interlist drop down menu choose: --c_src_interlist

    This should generate an assembly file with interspersed C code in either Debug/Release folder. You can then copy the assembly code from there into your ISR.

  • Hi Vishal,

    Thanks that helps quite a bit. 

    The converted asm code has an instruction 

        MOVL *+XAR4[0],ACC

    Im not sure what this does. I have been reading SPRU430 and understand that this is a long operand move that moves the value in the accumulator to something pointed to by the fourth auxiliary register, but what does the '+' and '[0]' do?

    Is there any TI document that talks about C28x assembly at a bit more of a basic level than SPRU430 (which seems more of a reference)? or any other recommended resource for C28x assembly for those that dont have much experience with x86 type asm (which seems to be what C28x is derived from)?

    Thanks

  • Hi Toby,

    *+XAR4[0] is the indirect addressing mode, one of several addressing modes that the C28x supports. SPRU430 is pretty exhaustive in its description of the Instruction Set Architecture. Its a pretty long doc but it covers everything.

    In the SGEN case you would create the object in C,

        SGENT_1 sgent1Object;

    In assembly you can access this object as _sgent1Object

    So you would load its address into XAR4,

    MOVL XAR4, #_sgent1Object          

    you can then access most of the structure members by indirect addressing or register addressing

    Indirect:

    MOV AL, *+XAR4[0]                      ; unsigned int freq
    MOV AL, *+XAR4[1]                      ; unsigned int step_max;
    MOV AL, *+XAR4[2]                      ; unsigned int alpha;
    MOV AL, *+XAR4[3]                      ; int gain;
    MOV AL, *+XAR4[4]                      ; int offset;
    MOV AL, *+XAR4[5]                      ; int out;

    Besides SPRU430E I cant think of any other document that covers the assembly in more detail. I generally write the C code, generate the assembly and then work from there. It might help to go into the project properties, C2000 Compiler->Debug Options->Debugging Model: --symdebug:none.

    It gets rid of all the DWARF tags in the generated assembly. In this mode, you wont be able to see all the debug symbols but It definitly becomes easier to see just the assembly in the generated asm files.

  • Just discovered the DWARF options myself, so much clearer!

    Thanks for your help Vishal, while I'll probably have another bunch of questions by the end of the day, it has been a great help! :)