-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