AnsweredAssumed Answered

Speeding C Interrupt handler by partly rewriting it by assembler

Question asked by BFProgrammer on Aug 17, 2011
Latest reply on Sep 25, 2011 by BFProgrammer

   Environment:
    -----------------
    Custom BF547M board, that functions OK with VisualDSP++5.0 Upd.9.


        I use Memory DMA handler written in C that works OK
    tranferring data from DDR Mobile to L1 fast memory and
    then through GPIO to custom FPGA card.


    In order to speed the handler I had written the loop part of it
    in BF548 assembler. But after several times that the assembler
    function is called from interrupt handler, the program is stucked and the 

   JTAG debugger gets disconnected. You have to reset the target in order to 

   bring the system into normal.

   I do know about Call-Preserved registers and Dadicated registers.

  So, I use Scratch Registers and preserve the only used P3 register.

Here is the assembler function that stucks eventually:

 

_asm_function:

CLI R3;

//Save Call-Preserved Registers

R2 = P3;

 

//Set DCLK PORT B8

P2.H = hi(PORTB_CLEAR);

P2.L = lo(PORTB_CLEAR);

P3.H = hi(PORTB_SET);

P3.L = lo(PORTB_SET);

R1 = PB8;

 

//Set loop counter LC0

P0=DMA_DEST_BUFF_SIZE;

LOOP loop1 LC0 = P0;

 

//Set P0 to point on first array element

P1.L = LO(_g_my_dest_buf);

P1.H = HI(_g_my_dest_buf);

P0 = [P1];

 

//Set P1 to PORTF

P1.H = hi(PORTF);

P1.L = lo(PORTF);

 

LOOP_BEGIN loop1;

     R0 = B [P0++] (Z);//Get data

     W [P1] = R0.L;//Out data to port F

     w[P2] = R1;//DCLK 0

     w[P3] = R1;//DCLK 1

LOOP_END loop1;

 

//Return Call-Preserved Registers

P3 = R2;

STI R3;

 

_asm_function.end:

 

Peter.

 

Outcomes