C8051f312微控制器

我不是很擅长C语言,但我已经为C8051F312微控制器编写了一个非常简单的代码。 我的代码不起作用。 请帮帮我,我错了什么。

#include C8051F310.h #include stdio.h sbit LED_16 = P1^7; // green LED: 1 = ON; 0 = OFF void init(void) { // XBRN registers_init XBR0 = 0x00; XBR1 = 0x00; // Enable the crossbar PCA0MD = 0X00; // port_init P0MDOUT = 0x00; // Output configuration for P0 P1MDOUT = 0x40; // Output configuration for P1 P2MDOUT = 0x00; // Output configuration for P2 P3MDOUT = 0x00; // Output configuration for P3 } void main(void) { init(); while (1) { LED_16 = 1; // LED continuously illuminated } } 

1.首先,您应该使用#include指令的以下两个选项之一

 #include "path-spec" #include  

,而不是#include path-spec ,就像你做的那样

2.要配置P1通用I / O端口的第7位以便在推挽模式下工作,您应该设置

P1MDOUT = 0x80;

不是

P1MDOUT = 0x40;