To write assembly on the MCU: Writing Assembly Code for ARM Cortex M0
Example assembly and C code for LPC1114/301: Example Assembly and C Code for ARM Cortex M0 (NXP LPC1114/301)
Step 1. Create a Project with uVision 4 (Free evaluation of Keil MDK ARM v4: https://www.keil.com/download/product/)
Figure 1 |
Step 2. Select NXP LPC1114/310 as the target device.
Figure 2 |
Step 3. Copy “startup_LPC111x.s” into the project directory.
Figure 3 |
Step 4. Copy the following files into the project directory.
File Name
|
Source (Assuming Keil uVision4 is installed in D:\Keil)
|
LPC11xx.h
|
D:\Keil\ARM\INC\NXP\LPC11xx
|
system_LPC11xx.h
|
D:\Keil\ARM\INC\NXP\LPC11xx
|
system_LPC11xx.c
|
D:\Keil\ARM\Startup\NXP\LPC11xx
|
Step 5. Right click on the “Source Group 1” and add “system_LPC11xx.c” to the current project.
Figure 4 |
Figure 5 |
Step 5. Again right click on the “Source Group 1” and add a new .c file to the project. This file will contain the “__main()” function and interrupt service routines.
Figure 6 |
Figure 7 |
Step 6. Write the application code in the .c file recently created.
Figure 8 |
Code:
#include "LPC11xx.h"
void __main(void)
{
// Write user code here
unsigned int tempData1 = 0;
__NOP();
__NOP();
__NOP();
__NOP();
// Infinite while loop
while(1)
{
tempData1++;
} // end of while(1)
}
|
Compilation, Simulation, HEX file generation, and programming the MCU with the generated HEX file steps are same as in Writing Assembly Code for ARM Cortex M0.
No comments:
Post a Comment