Event Recorder and Component Viewer  Version 1.5.1
MDK Debugger Views for Status and Event Information
SCVD Complex Example

Use the example project Complex SCVD Example for more advanced topics.

This example is more complex than SCVD Simple Example and shows:

  • The use of Expressions and conditional computing for various XML elements
  • The use of the built-in variable _count
  • The use of readlist and list for looping through arrays

The example uses the structures TypeA, TypeG, and TypeArray defined in the project and creates a static output showing initial member values and characteristics.

main.c File

#include "RTE_Components.h" // Component selection
#include CMSIS_device_header
// Type 'A'
typedef struct TypeA {
uint32_t Nummer;
uint32_t Status;
uint32_t Size;
} TypeA;
// Type 'G'
typedef struct TypeG {
uint32_t Nummer;
uint32_t Cluster;
uint32_t ClusterSize;
uint32_t Status;
} TypeG;
// Type Array
typedef struct TypeArray {
void *type_ref;
char id[2];
uint16_t attr;
} TypeArray;
static TypeA type_a0 = { 0xA01, 0xA02, 0xA03 };
static TypeA type_a1 = { 0xA11, 0xA12, 0xA13 };
static TypeG type_g0 = { 0xF01, 0xF02, 0xF03, 0xF04 };
static TypeG type_g1 = { 0xF11, 0xF12, 0xF13, 0xF14 };
static TypeG type_g2 = { 0xF21, 0xF22, 0xF23, 0xF24 };
static int32_t x0;
extern TypeArray type_array[];
TypeArray type_array[] = {
{ &x0, "A0", 1 },
{ &type_g0, "G0", 2 },
{ &type_g1, "G1", 2 },
{ &type_a1, "A1", 1 },
{ &type_g2, "G2", 2 },
};
int main (void) {
type_array[0].type_ref = &type_a0;
while (1) {
__NOP();
}
}

Complex_view.scvd File

<component_viewer schemaVersion="0.1" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="Component_Viewer.xsd">
<component name="MyView2" version="0.0.1"/> <!-- name and version of the component -->
<typedefs>
<typedef name="XML_TypeA" size="12">
<member name="Nummer" type="uint32_t" offset="0" />
<member name="Status" type="uint32_t" offset="4" />
<member name="Size" type="uint32_t" offset="8" />
</typedef>
<typedef name="XML_TypeG" size="16">
<member name="Nummer" type="uint32_t" offset="0" />
<member name="Cluster" type="uint32_t" offset="4" />
<member name="ClusterSize" type="uint32_t" offset="8" />
<member name="Status" type="uint32_t" offset="12" />
<var name="TotalSize" type="uint64_t" info="calculated as: Cluster*ClusterSize"/>
</typedef>
<typedef name="XML_TypeArray" size="8">
<member name="type_ref" type="uint32_t" offset="0" info="Pointer to TypeA or TypeG" />
<member name="id0" type="uint8_t" size="2" offset="4" info="Type ID" />
<member name="id1" type="uint8_t" offset="5" info="Type ID" />
<member name="attr" type="uint8_t" offset="6" info="Type Attribute"/>
<var name="idx" type="uint32_t" info="calculated index in TypeX array" />
</typedef>
</typedefs>
<objects>
<object name="ListOfArrayTypes">
<var name="i" type="int32_t" value="0" /> <!-- variable for loops -->
<var name="j" type="int32_t" value="0" /> <!-- variable for loops -->
<readlist name="TypeA" type="XML_TypeA" />
<readlist name="TypeG" type="XML_TypeG" />
<readlist name="TArray" type="XML_TypeArray" symbol="type_array" count="5" />
<list name="i" start="0" limit="TArray._count"> <!-- for(i=0;i<TArray._count;i++) -->
<calc cond="TArray[i].attr==1">
TArray[i].idx=TypeA._count;
</calc>
<readlist cond="TArray[i].attr==1" name="TypeA" type="XML_TypeA" offset="TArray[i].type_ref" />
<calc cond="TArray[i].attr==2">
TArray[i].idx=TypeG._count;
</calc>
<readlist cond="TArray[i].attr==2" name="TypeG" type="XML_TypeG" offset="TArray[i].type_ref" />
</list>
<list name="i" start="0" limit="TypeG._count"> <!-- for(;;) -->
<calc>
TypeG[i].TotalSize = TypeG[i].Cluster * TypeG[i].ClusterSize;
</calc>
<calc>
j=TArray._count;
</calc>
</list>
<out name="Array and Structure Types"> <!-- name of window and menu entry -->
<!-- create output with two hierarchies -->
<item property="Array Identifiers"> <!-- the 'header' with sub entries -->
<list name="i" start="0" limit="TArray._count"> <!-- for(;;) -->
<item property="Data in TArray[%d[i]].id is:" value="%t[TArray[i].id0]" />
</list>
</item>
<item property="" value="" /> <!-- output empty line -->
<!-- create output with two and three hierarchies -->
<list name="i" start="0" limit="TArray._count"> <!-- for(;;) -->
<!-- two hierarchies for TypeA structure -->
<item cond="TArray[i].attr==1" property="Type A%d[TArray[i].id1-0x30]:" value="Memory address (type_ref) = %x[TArray[i].type_ref] idx=%d[TArray[i].idx]" >
<item property="Type A, size=%d[TypeA[TArray[i].idx].Size]" value="Num=%x[TypeA[TArray[i].idx].Nummer] Status=%x[TypeA[TArray[i].idx].Status]" />
</item>
<!-- three hierarchies for TypeG structure -->
<item cond="TArray[i].attr==2" property="Type G%d[TArray[i].id1-0x30]:" value="Memory address (type_ref) = %x[TArray[i].type_ref] idx=%d[TArray[i].idx]" >
<item property="Type G, Total size=%d[TypeG[TArray[i].idx].TotalSize]" value="Num=%x[TypeG[TArray[i].idx].Nummer] Status=%x[TypeG[TArray[i].idx].Status]" >
<item property="Cluster" value="n=%x[TypeG[TArray[i].idx].Cluster] Size=%x[TypeG[TArray[i].idx].ClusterSize]" />
</item>
</item>
</list>
<item property="" value="------ Types ------" /> <!-- output line with empty property but text in 'Value' column -->
<list name="i" start="0" limit="TypeA._count"> <!-- for(i=0;i<_count;i++) -->
<item property="Type A%d[i]" value="Num=%x[TypeA[i].Nummer], Size=%x[TypeA[i].Size]" />
</list>
<list name="i" start="0" limit="TypeG._count">
<item property="Type G%d[i]" value="Num=%x[TypeG[i].Nummer], Total size=%x[TypeG[i].TotalSize]" />
</list>
</out>
</object>
</objects>
</component_viewer>

Build and run

  1. Open the project "Complex SCVD Example" from Pack Installer (search for uVision Simulator in the Boards tab).
  2. Compile and run the application
  3. Open the window View - Watch Windows - Array and Structure Types and verify the output
Array and Structure Types