Skip to main content

How to Run Simple Code on the Cortex M4 (Windows Embedded Compact)

This article explains how to run code on the Cortex-M4 core on targets running Windows Embedded Compact.

info

For information about running code on a Cortex-M4 of other modules and Operating Systems, see the FreeRTOS article

Walk-Through

Let's first start with the actual work. Use the Reg Access Tool to access the following physical memory locations.

#AddressValueOperationComment
10x3f04'00000x3001'a101Write
20x3f04'00040xe7fc'6008Write
30x4006'e0280x3f04'0001Write
40x4006'b08c0x0001'5a5aWrite
50x3f04'0008ReadRepeat this step. You will see incrementing values.

That's it. You are already done.

Explanations

Let's look at the details:

M4 Application

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 |

Steps to Run the Code

  • In steps #1 to #2 we write the assembly code to the SRAM.
  • In step #3, we write the M4 starting address into the SRC_GPR2 register. Bit 0 is set to start in THUMB mode.
  • In step #4, we start the M4 by setting the AUX_CORE_WAKEUP bit in the CCM_CCOWR register. Reading back this register will show 0x00010000.
  • Step #5 is only to verify that the application is running.
Send Feedback!