-1
我不是很擅长C语言,但我写了一个非常简单的代码给C8051F312微控制器。 我的代码无法使用。请帮助我,我错了什么。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
}
}
*如何*不代码工作?预期的结果是什么?什么是实际结果?您确定要在'LED_16'的初始化中使用XOR操作吗? –
请发布*实际*代码,而不是近似值 - 上面的代码甚至没有编译。 –
p1^7不是XOR操作,它声明了P1端口(它是一个led)的7.位,我想打开led。和它的实际代码... – user3114492