56800E modulo addressing

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

56800E modulo addressing

867 Views
miroslavmartise
Contributor I

Hello guys,

have somebody got experiences with 56800E core modulo addressing? Namely, I

cannot read correct value of last sample in circular buffer (its length is

7 samples). If I want to obtain other samples, it works very well.

Simple code is here:

-----------------------------------------------------------------

Frac16 test;

Frac16 TestBuffer[7] = {4587, 4578, 1258, 6688, 1024, 1122, 874};

asm Frac16 ModuloTest(Frac16 *buffer)

{

  adda #1,SP 

  move.w N,X:(SP) // save N

  

  

  adda #0,R2,R0 // R0 = R2

  moveu.w #6,M01 // modulo addressing 

TestGo:

  move.w #6,N

  adda N,R0

  move.w X:(R0),A

  move.w A,Y0 // result to Y0

  move.w X:(SP)-,X0

  move.w X0,N

  

  rts

}

And calling:

test = ModuloTest(TestBuffer);

-------------------------------------------------------------------------

If I want to call this function, it returns value of 32 instead 874. Also,

I tried to modify this code million times, but without success. At the

moment I don´t know how improve it.

Could somebody give me an advice to solve it?

Thanks a lot!

Miroslav from Bohemia (Czech Republic)

Labels (1)
Tags (2)
0 Kudos
Reply
2 Replies

518 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

This is a FIR filter based on modulo addressing mode.
 
;  GLOBAL INIT_Coefficent_Data,INI_Sam_Data,NPTSS
 
NPTSS EQU 32

  Section xramdata
   org x:
INI_Sam_Buff    dsm NPTSS 

   org x:
INIT_Coefficent_Buff     dc \
0.9,0.1,0.2,0.2,0.5,0.5,-0.2,-0.1,0.9,0.1,\
0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,\
0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,\
0.1,0.1

Fir_Result ds 1
sample_Flag dc $01
new_Sample  dc 0.1
sample_PTR  ds 1
temporary   ds 1
ENDSEC

; sample code

section rtlib
org p:

global Fmain

SUBROUTINE "Fmain",Fmain,FmainEND-Fmain

; assembly level entry point
Fmain:
;Begin to initialize both sample and coefficents buffer
    move.l #INI_Sam_Buff,r0
    nop
    moveu.w #NPTSS-1,m01
   
    do   #NPTSS,labelsample ;fill sample buffer with data
    move.w #0.3,y0
    move.w y0,x:(r0)+
    move.w r0,x:sample_PTR
labelsample: 
;initialization end




label1: nop
;update sample buffer with  new ADC sample
moveu.w x:sample_PTR,r0
brclr #$01,x:sample_Flag,* ;the sample_Flag should be set by ISR of ADC
move.w X:(r0)+,y0 ;only for increment r0
move.w  x:new_Sample,y0
move.w  y0,x:(r0)+
  move.l #INIT_Coefficent_Buff+31,r3

    clr a
    move.w x:(r3)-,x0
   
   
   
  ;Begint to count the cycle from here  
    do #NPTSS-1,label
    mac x0,y0,a x:(r0)+,y0 x:(r3)-,x0
label:
macr x0,y0,a
;stop counting and compute the cycle  number





move.w a,x:Fir_Result 
move.w r0,x:sample_PTR ;save the address new sample should be saved

nop   ;Does nothing
bra label1
nop    ; do nothing
rts
FmainEND:

endsec

end

0 Kudos
Reply

518 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Regarding your question, in the modulo addressing mode, if the data number is 7 or less, the Last three address of the array TestBuffer must be zero, in other words, the address of the array TestBuffer must be xxxxxx000.

If the data number is 16 or less, the Last four address of the array TestBuffer must be zero, in other words, the address of the array TestBuffer must be xxxxx0000 in word address format.

secondly, I suggest you insert a nop between:

move.w #6,N 

  adda N,R0

nop

  move.w X:(R0),A

If you use a C compiler to allocate the address with last three address are zero, it is  a bit complicated, you have to use the following code to allocate a absolute address for the array:

/* MODULE CS_select_8357_PE */
//Description:
//Firstly,define two array variable so that the two array variable are located at the specified address
//which match with Chip Select Base Address register,in the example,a and b arraies are defined in
//0x3000 adress and the length is 0xBFFF,pls refer to sdm_pROM_xRAM.cmd file for detail inf.
//  .x_Data1 (RW): ORIGIN =0xxxx0,LENGTH = 0x10 #external data memory space 
//       .ApplDat:
//        {
//        * (.mysection.data)
//        }> .x_Data1

//In the main() function,there is a forever loop so that DSP can access external memory from the specified
//address the a and b array are located so that EMI generating timing signal
//  for(;;)
//  {

   //a[0]=0x1234;
    //a[0]=0x1234;
   //a[0]=0x1234;
// }


/* Including used modules for compilling procedure */
#include "Cpu.h"
/* Include shared modules, which are used for whole project */
#include "PE_Types.h"
#include "PE_Error.h"
#include "PE_Const.h"
#include "IO_Map.h"

#pragma define_section mysection ".mysection.data" RW
/* 2. Specify the data to be put into the section. */
#pragma section mysection begin
int a[10] = {'00','10','12','13','14','15','16','17','18','19'};
int b[10];
#pragma section mysection end

void main(void)
{
  // register unsigned i;
  /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
  PE_low_level_init();
  /*** End of Processor Expert internal initialization.                    ***/

  /* Write your code here */

  for(;;)
  {

   a[0]=0x1234;
    a[0]=0x1234;
   a[0]=0x1234; 
   a[0]=0x1234; 
   a[0]=0x1234; 
    a[0]=0x1234;
    a[0]=0x1234;
   a[0]=0x1234; 
   a[0]=0x1234; 
   a[0]=0x1234;
    a[0]=0x1234;
    a[0]=0x1234;
   a[0]=0x1234; 
   a[0]=0x1234; 
   a[0]=0x1234; 
    a[0]=0x1234;
    a[0]=0x1234;
   a[0]=0x1234; 
   a[0]=0x1234; 
   a[0]=0x1234;  
    
//  b[0]=
  }
}

/* END CS_select_8357_PE */
/*
** ###################################################################
**
**     This file was created by UNIS Processor Expert 03.47 for
**     the Motorola 56800 series of microcontrollers.
**
** ###################################################################
*/

Hope it can help you.

0 Kudos
Reply