212 CHAPTER 5 Working with J-Link and J-Trace
J-Link / J-Trace (UM08001) ©
2004-2017 SEGGER Microcontroller GmbH & Co. KG
For JTAG
The SWD -> JTAG switching sequence is output. This also triggers a TAP reset on the
target (TAP controller goes through -> Reset -> Idle state)
The IRPre, DRPre, IRPost, DRPost parameters describe which device inside the JTAG
chain is currently selected for communication.
For SWD
The JTAG -> SWD switching sequence is output.
It is also made sure that the "overrun mode enable" bit in the SW-DP CTRL/STAT reg-
ister is cleared, as in SWD mode J-Link always assumes that overrun detection mode
is disabled.
Make sure that this bit is NOT set by accident when writing the SW-DP CTRL/STAT
register via the _CORESIGHT_ functions.
Prototype
int JLINK_CORESIGHT_Configure(const char* sConfig);
Example
if (MAIN_ActiveTIF == JLINK_TIF_JTAG) {
// Simple setup where we have TDI -> Cortex-M (4-bits IRLen) -> TDO
JLINK_CORESIGHT_Configure("IRPre=0;DRPre=0;IRPost=0;DRPost=0;IRLenDevice=4");
} else {
// For SWD, no special setup is needed, just output the switching sequence
JLINK_CORESIGHT_Configure("");
}
v = JLINK_CORESIGHT_ReadDP(JLINK_CORESIGHT_DP_REG_CTRL_STAT);
Report1("DAP-CtrlStat: " v);
// Complex setup where we have TDI -> ICEPick (6-bits IRLen) -> Cortex-M (4-bits
IRLen) -> TDO
JLINK_CORESIGHT_Configure("IRPre=0;DRPre=0;IRPost=6;DRPost=1;IRLenDevice=4;");
v = JLINK_CORESIGHT_ReadDP(JLINK_CORESIGHT_DP_REG_CTRL_STAT);
Report1("DAP-CtrlStat: " v)
Known setup parameters
5.11.2.20JLINK_CORESIGHT_ReadAP()
Description
Reads a specific AP register.
For JTAG, makes sure that AP is selected automatically.
Makes sure that actual data is returned, meaning for register read-accesses which
usually only return data on the second access, this function performs this automati-
cally, so the user will always see valid data.
Parameter Type Explanation
IRPre DecValue Sum of IRLen of all JTAG devices in the JTAG chain,
closer to TDO than the actual one J-Link shall commu-
nicate with.
DRPre DecValue Number of JTAG devices in the JTAG chain, closer to
TDO than the actual one, J-Link shall communicate
with.
IRPost DecValue Sum of IRLen of all JTAG devices in the JTAG chain, fol-
lowing the actual one, J-Link shall communicate with.
DRPost DecValue Number of JTAG devices in the JTAG chain, following
the actual one, J-Link shall communicate with.
IRLenDevice DecValue IRLen of the actual device, J-Link shall communicate
with.
PerformTIFInit DecValue 0: Do not output switching sequence etc. once
JLINK_CORESIGHT_Configure() completes.