RE02 SWV Reader


Outline

The Serial Wire Viewer from ARM (Cortex-M microcontroller) provides non-intrusive real-time tracing (ITM). This mechanism is usually used for printfs only. The impulse SWV reader enhances SWV use cases as it allows users to log and trace different kinds of data (real, integer, strings or logic), which can then be stored, visualized and analysed with impulse.

Platforms:
32/64bit 32/64bit 32/64bit
Requirements:
  • None
Known limitations:
  • File size limited by virtual memory and temporary storage
Status:
  • Stable
Operations:
  • Load
  • Stream
Parameters:
  • None
Configuration:
  • A SWV reader configuration is required. The configuration comprise timing settings and the content of the SWV file (the data type for each ITM channel).


Video

Screen Cast: Using the SWV Reader



Usage

The reader can be used to open workspace resources and together with ports (direct connection to the target using TCP, Serial, J-Link, ...).



Configuration

You can modify the serializer behavior under Preferences->impuse->Serializer->SWV Reader:

The SWV reader requires a serializer configuration  to work. Get to Preferences>impuse->Serializer->Serial Wire Viewer, press Add and select the SWV configuration:

  • Frequency/Divider: Enter the SWV frequency and divider value of your target.
  • Wait for sync: If checked, the read will wait for a sync packet to continue.
  • ITM0..31: Enter the data type for each ITM channel or "Not used".


Prepare the target

To import the Simple SWV Trace library and demo code, go to Import->impulse->Import Simple SWV Trace, select a root folder and press ok.

Enable SWV

You may use the information of your board provider and the sample in demo.c to enable SWV tracing in your target:
  void initSwv() {

      DBGMCUCR |= 0x00000027;
      DEMCR |= (1 << 24);
      ITM_LSR = 0xC5ACCE55;

      TPIU_SPPR = 0x00000002;     // Select NRZ mode
      TPIU_ACPR = 1;              // Divider 1 means /2

      ITM_TPR = 0x00000000;
      DWT_CTRL = 0x400003FE;
      FFCR = 0x00000100;

      ITM_TCR = 0x1000F;             // Enable ITM
      ITM_ENA = 0xffff;             // Enable ITM stimulus port

  }
  

Use the Simple SWV Trace library

  void itm_write_i8(unsigned char port, signed char b);
  void itm_write_i16(unsigned char port, short b);
  void itm_write_i32(unsigned char port, long b);
  void itm_write_i64(unsigned char port, long long b);
  void itm_write_f32(unsigned char port, float f);
  void itm_write_f64(unsigned char port, double f);
  void itm_write_t0(unsigned char port, const char* text);
  void itm_write_tn(unsigned char port, const char* text, char e);
  void itm_write_log(unsigned char port, unsigned char severity, const char* source, const char* message);
The library convert several data types into a defined byte order. See the demo code in demo.c how to use.
 


Example

  void demo() {

      itm_write_t0(0, "Start Demo");
      wait(100);
      itm_write_t0(0, "Measure");

      int i = 0;
      float f = 0.0;
      double d = 0.0;
      unsigned char uc = 0;
      signed char sc = 0;
      unsigned short us = 0;
      signed short ss = 0;
      unsigned long ul = 0;
      signed long sl = 0;
      unsigned long long ull = 0;
      signed long long sll = 0;
      unsigned char logic = 0;

      while (1) {

          // float
          f = sin(i / 100.0) * 100.;
          d = cos(i / 50.0 + 1.0) * 50. + 20;
          itm_write_f32(1, f);
          itm_write_f64(2, d);

          wait(10);

          // text
          if (i % 500 == 0)
              itm_write_t0(0, "i%50 reached \nmore to come\n");

          // bytes
          if (i % 100 == 0) {
              uc = i / 20;
              sc += 1;
              itm_write_i8(3, uc);
              itm_write_i8(4, sc);
          }

          // short
          if (i % 125 == 0) {
              us = d + i;
              ss = d * 20;
              itm_write_i16(5, us);
              itm_write_i16(6, ss);
          }

          // long
          if (i % 175 == 0) {
              ul = i;
              sl = -i;
              itm_write_i32(7, ul);
              itm_write_i32(8, sl);
          }

          // long long
          if (i % 225 == 0) {
              ull += rand();
              sll = (((long long) d) << 32) + rand();
              itm_write_i64(9, ull);
              itm_write_i64(10, sll);
          }

          // logic
          if (i % 25 == 0) {
              logic = i & 1;
              itm_write_i8(11, logic);
          }

          // log
          if (i > 0 && i % 200 == 0)
              itm_write_log(12, SEVERITY_INFO, "Test", "i % 200 == 0");
          if (i > 0 && i % 350 == 0)
              itm_write_log(12, SEVERITY_ERROR, "Test", ">= 350");

          i++;
      }
  }



Parse errors

The reader will provide a parse error message if the input can not be read. The message usually contains the error position, the reason for the failure and a stack trace.

If you can not resolve the problem (e.g. obvious format error in the input file), please send this message together with the input file to "This email address is being protected from spambots. You need JavaScript enabled to view it.".

	Reader: de.toem.impulse.serializer.xyz 
	Error at position: 4800
	Text at position: "o !.
	Up
	Uq
	Ur"
	Message: Invalid character
	Type: class de.toem.impulse.serializer.ParseException
	Stack trace: 
	
	de.toem.impulse.serializer.xyz.xyzReader.parse(XYZReader.java:459)
	de.toem.impulse.serializer.xyz.xyzReader.parse(xyzReader.java:363)
	de.toem.impulse.serializer.xyz.xyzReader.read(xyzReader.java:269)
	de.toem.impulse.serializer.xyz.xyzReader.read(xyzReader.java:237)
	de.toem.pattern.element.Element$1.execute(Element.java:1063)
	de.toem.eclipse.hooks.actives.EclipseActives$3.run(EclipseActives.java:73)

toem

technical software and tooling

Company

Contact Us

This email address is being protected from spambots. You need JavaScript enabled to view it.