本帖最后由 ddllxxrr 于 2015-2-12 16:00 编辑
上次用ASF库点了LED,这次用寄存器方式哈:
查了下:LED在PC23脚
然后建立工程,则系统自动形成程序框架让你添代码。
由于PC23是PC的第23脚,所以,经过我的周密计算,应是0x0080 0000
所以程序如下:
- /*
- * GccApplication7.c
- *
- * Created: 2015-2-11 14:41:50
- * Author: Administrator
- */
- #include "sam.h"
- /**
- * \brief Application entry point.
- *
- * \return Unused (ANSI-C compatibility).
- */
- void Delay(int num)
- {
- for(volatile int i=0;i<1024*1024 * num; ++i);
- }
- int main(void)
- {
- /* Initialize the SAM system */
- SystemInit();
-
- PIOC ->PIO_PER = 0x00800000;
- PIOC ->PIO_OER = 0x00800000;
- PIOC ->PIO_OWER = 0x00800000;
- while (1)
- {
- //TODO:: Please write your application code
- Delay(2);
- PIOC ->PIO_SODR = 0x00800000;
- Delay(2);
- PIOC ->PIO_CODR = 0x00800000;
-
- }
- }
点绿色三角运行,当然板子得插到USB口上。
以下是运行截图:
上照片:
|