This article explains how to run code on the Cortex-M4 core on targets running Windows Embedded Compact.
Note: For information about running code on a Cortex-M4 of other modules and Operating Systems, see the FreeRTOS article
Let's first start with the actual work. Use the Reg Access Tool to access the following physical memory locations.
# | Address | Value | Operation | Comment |
---|---|---|---|---|
1 | 0x3f04'0000 | 0x3001'a101 | Write | |
2 | 0x3f04'0004 | 0xe7fc'6008 | Write | |
3 | 0x4006'e028 | 0x3f04'0001 | Write | |
4 | 0x4006'b08c | 0x0001'5a5a | Write | |
5 | 0x3f04'0008 | Read | Repeat this step. You will see incrementing values. |
That's it. You are already done.
Let's look at the details:
This is the assembly code that we want to run on the Cortex M4:
0x3f040000 a101 ADD R1, PC, #4 ; load counter address [0x3f040008] into R1
.-> 0x3f040002 3001 ADD R0, 1 ; increment counter
| 0x3f040004 6008 STR R0, [R1, 0] ; store new counter value
`=< 0x3f040006 e7fc B 0x3f040002
Code and variable are located in the SRAM. The memory map looks like this:
Address Range | Content |
---|---|
0x3f04'0000 - 0x3f04'0007 | Program code |
0x3f04'0008 - 0x3f04'000b | 32bit counter |