Chương trình sẽ làm nháy led trên KIT VĐK 1.0
Mã nguồn file main.c
#include "ms51.h" #include <stdint.h> void delay(void); void delay(void) { uint32_t i; for (i = 0; i < 20000; ++i) { } } int main(void) { P1M1 &= ~(1 << 5); P1M2 |= (1 << 5); while (1) { P15 = 0; delay(); P15 = 1; delay(); } }
Dịch chương trình bằng cách mở CMD gõ
make
Sẽ thấy chương trình được biên dịch thành công tạo ra file hex
Dùng file hex này để nạp vào chip
![](http://vidieukhien.org/wp-content/uploads/2020/01/fig1-3.png)
![](http://vidieukhien.org/wp-content/uploads/2020/01/fig2.png)
![](http://vidieukhien.org/wp-content/uploads/2020/01/fig3.png)
![](http://vidieukhien.org/wp-content/uploads/2020/01/fig4.png)
Project
https://drive.google.com/open?id=1vIJ41MKxoKRRejmfTccnP0ibvGVskdAx
Hoặc
http://vidieukhien.org/wp-content/uploads/2020/01/blink.zip