1.4.3. Multiple operation macro example

To demonstrate sending one of the parameters at runtime, a macro line is entered to accept the least significant 32 TDIbits at runtime for three instructions. The purpose of this macro is to send the following instructions to the data register:

To define the macro

The code in Example 1.6 shows you how to define the parameterized macro.

Example 1.6. Defining a parameterized macro

#define MACRO2      2
#define SC_DATBUS    (unsigned8)33
int        ValPtr;
unsigned8  Values[MACRO_ARGUMENT_AREA_SIZE];
/* Send 1 data word out.*/
/* Parameters 2 to 8 are fixed, parameter 1 sent at run-time */
InitParams;                  /* Reset ValPtr */
NREnterParamU8(0);           /* Place param2 (TDIbits2) in Values array */
NREnterParamU8(1);           /* Place param3 (TDIrev) in Values array */
NREnterParamU8(SC_DATABUS);  /* Place param4 (len) in Values array */
NREnterParamU8(0);           /* Place param5 (WRoffset) in Values array */
NREnterParamU32(0xFFFFFFFF); /* Place param6 (WRmask1) in Values array */
NREnterParamU8(0xFF);        /* Place param7 (WRmask2) in Values array */
NREnterParamU8(1);           /* Place param8 (nclks) in Values array */
/* ‘line’ can now be added */
TAPCheck(TAPOp_DefineMacro(connectId, MACRO2, "ARMTAP_AccessDR_W:2345678",
                             3, Values, ValPtr));

To run the macro

The code in Example 1.7 shows you how to run the macro defined in Example 1.6. The macro uses variable parameters and so the TAPOp_RunMacro call requires data in the Values array. You must format the data into the Values array using one of the macro enter functions, for example NREnterParamU32, NREnterParamU16, and NREnterParamU8.

Example 1.7. Running the parameterized macro

#define LDMIA   (unsigned32) 0xE89E3FFF   /* op-code for LDMIA instr */
#define NOP     (unsigned32) 0xE1A00000   /* op-code for NOP instr */
int lnerr,lperr,         /* Variables for error position detecting */
    resultvalues,        /* In this example, no data is returned, but */
    resultsize;          /* variables must be defined */
InitParams;              /* Reset ValPtr */
resultsize = 0;
NREnterParamU32(LDMIA);  /* Place param1 (TDIbits1) for first iteration */
NREnterParamU32(NOP);    /* Place param1 (TDIbits1) for second iteration */
NREnterParamU32(NOP);    /* Place param1 (TDIbits1) for third iteration */
TAPCheck(TAPOp_RunMacro(connectId,MACRO2,Values,ValPtr,&lnerr,&lperr,
                        &resultvalues, &resultsize, 1, 1));
Copyright © 1998-2002 ARM Limited. All rights reserved.ARM DUI 0154B
Non-Confidential