SWD_GET_RESPONSE_COUNTERS

The SWD_GET_RESPONSE_COUNTERS function provides ways to get information about all previous SWD_READ or SWD_WRITE scans when SWD_EXIT_ON_ERROR is disabled. SWD_GET_RESPONSE_COUNTERS can be used after doing a series of SWD scans in a row to check at the end if any had problems. This allows code to be run faster than having to check for an error after every scan. This is especially true of SWD_WRITE calls as they can be run asynchronously to the XJEase execution thread but if XJEase was checking after every scan they would become synchronous and run much slower.

The counters can be reset using SWD_RESET_RESPONSE_COUNTERS.

Syntax

SWD_GET_RESPONSE_COUNTERS( INT okCounter, INT timeoutOnWaitCounter, INT faultCounter, INT otherAcksCounter )
SWD_GET_RESPONSE_COUNTERS( INT okCounter, INT timeoutOnWaitCounter, INT faultCounter, INT otherAcksCounter, INT parityErrorCounter )

Parameters

okCounter
The number of OK acknowledgements (0b001) received.
timeoutOnWaitCounter
The number of scans failed due to repeat WAIT acknowledgements (0b010) received. The hardware will automatically retry any scan that returns WAIT a number of times with increasing delays before finally skipping the scan and increasing this counter by one.
faultCounter
The number of FAULT acknowledgements (0b100) received.
otherAcksCounter
The number of other unrecognised acknowledgements received.
parityErrorCounter
The number of times a parity error was observed in the read data received from SWD_READ calls.

It is a runtime error to call SWD_GET_RESPONSE_COUNTERS when SWD_EXIT_ON_ERROR is enabled.

The counters are not reset when exiting SWD blocks or between tests, it is up to the user when to reset them using SWD_RESET_RESPONSE_COUNTERS.

When SWD_GET_RESPONSE_COUNTERS is called all outstanding requests are completed before it will return. If SWD_GET_RESPONSE_COUNTERS is called within a HOLDOFF the HOLDOFF is temporarily disabled to allow all requests to complete before SWD_GET_RESPONSE_COUNTERS returns.

Example

CONST INT DPIDR := 0x0;
CONST INT STAT := 0x4;
INT data, id;
INT okCounter, timeoutOnWaitCounter, faultCounter, otherAcksCounter, parityErrorCounter;

SWD_EXIT_ON_ERROR(FALSE);
SWD_RESET_RESPONSE_COUNTERS();
SWD
  SWD_READ(0, DPIDR[3..2])(id);
  SWD_READ(0, STAT[3..2])(data);
  SWD_GET_RESPONSE_COUNTERS()(okCounter, timeoutOnWaitCounter, faultCounter, otherAcksCounter, parityErrorCounter);
  PRINT("okCounter = ", okCounter, ", timeoutOnWaitCounter = ", timeoutOnWaitCounter, ", faultCounter = ", 
    faultCounter, ", otherAcksCounter = ", otherAcksCounter, ", parityErrorCounter = ", parityErrorCounter, "\n");
END;

SWD_RESET_RESPONSE_COUNTERS();
SWD_READ(0, DPIDR[3..2])(id); //read in error
SWD_WRITE(0, 0, 0x5);         //write in error
SWD_GET_RESPONSE_COUNTERS()(okCounter, timeoutOnWaitCounter, faultCounter, otherAcksCounter, parityErrorCounter);
PRINT("okCounter = ", okCounter, ", timeoutOnWaitCounter = ", timeoutOnWaitCounter, ", faultCounter = ", 
  faultCounter, ", otherAcksCounter = ", otherAcksCounter, ", parityErrorCounter = ", parityErrorCounter, "\n");
okCounter = 2, timeoutOnWaitCounter = 0, faultCounter = 0, otherAcksCounter = 0, parityErrorCounter = 0
okCounter = 0, timeoutOnWaitCounter = 0, faultCounter = 0, otherAcksCounter = 2, parityErrorCounter = 0