C8051f312 microcontroller [closed]

ⅰ亾dé卋堺 提交于 2019-12-04 07:27:17

问题


I'm not very good at C language, but I have write a very simple code to a C8051F312 microcontroller. My code doesn't working. Please help me what did I wrong.

#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:


1.First of all you should use one of 2 following options for #include directive

#include  "path-spec"
#include  <path-spec>

, not #include path-spec, as you did

2.To configuire 7th bit of P1 general I/O port to work in push-pull mode you should set

P1MDOUT = 0x80;

, not

P1MDOUT = 0x40;



来源:https://stackoverflow.com/questions/20653846/c8051f312-microcontroller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!