使用arm微控制器真的很容易上手。您需要做的就是阅读微控制器的数据表和用户手册。您可以在用户手册中找到有关外围设备和寄存器的所有文档
https://www.nxp.com/docs/en/user-guide/UM10362.pdf
例如,此代码用于 lpc2148():
#include <lpc214x.h> // this header file is provided by nxp and contains all register addresses
/* delay function is using only for loop to generate delay.
For accurate timing, use a hardware timer/counter (systick timer is recommended (because it is so easy and configurable via cmsis functions that are provided by ARM)) */
void delay_ms(unsigned int count)
{
unsigned int j=0,i=0;
for(j=0;j<count;j++)
{
for(i=0;i<3000;i++)
asm("nop");
}
}
/* main function */
int main()
{
PINSEL2 = 0x000000; //Configure the P1 Pins for GPIO;
IODIR1 = 0xffffffff; //Configure the P1 pins as OUTPUT;
while(1)
{
IOSET1 = 0xffffffff; // Make all the Port pins as high
delay_ms(1000);
IOCLR1 = 0xffffffff; // Make all the Port pins as low
delay_ms(1000);
}
return 0;
}