微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 嵌入式设计讨论 > MCU和单片机设计讨论 > 有使用过的C8051f981的么

有使用过的C8051f981的么

时间:10-02 整理:3721RD 点击:
我写的程序运行很短一段时间,不知道为什么就被reset了
#include<REG51F990.H>
#include "F981_LNIT.H"
#include<stdio.h>
sbit LED1=P1^0;
sbit LED2=P1^1;
void delay_ms( int delay);
void main(void)
{
        OSCILLATOR_Init ();
        PORT_Init ();
        TIMER0_Init ();
       
        EA = 1;
        LED1 = 0;
        while(1)
        {
//                LED1=0;//
////                LED2=0;
////                delay_ms(500);
//                delay_ms_1();
//                LED1=0x01;
////                delay_ms(500);
//                delay_ms_1();
        }
}
//-----------------------------------------------------------------------------
// delay_ms
//-----------------------------------------------------------------------------
//
// ?ó3ùxxxxoá??£¨ò?°?ó?óú3ìDò3?ê??ˉ?D£?
//
//-----------------------------------------------------------------------------
void delay_ms( int delay)
{
      int i;
      int j;
    for(i=0;i<delay;i++)
//    for(j=0;j<6000;j++); //delay 1ms
    for(j=0;j<1220;j++); //delay 1ms
}

void OSCILLATOR_Init (void)
{
   REG0CN |= 0x10;                     // Enable the precision osc. bias
   OSCICN |= 0x80;                     // Enable the precision internal osc.
//   RSTSRC = 0x06;                      // Enable missing clock detector and
                                       // leave VDD Monitor enabled.
         RSTSRC = 0x00;
   CLKSEL = 0x30;                      // Select precision internal osc.
                                       // divided by 8 as the system clock
       
        PCA0MD &= 0xDF;                      //disable watchdog timer
}

void PORT_Init (void)
{
   // Configure TouchSense switch
   P0MDIN &= ~0x08;                    // P0.3 is analog
   P0MDOUT &= ~0x08;                   // P0.3 is open-drain
   P0      |=  0x08;                   // P0.3 latch -> '1'
   // Configure Hardware Switch
   P0MDIN |= 0x04;                     // P0.2 is digital
   P0MDOUT &= ~0x04;                   // P0.2 is open-drain
   P0     |= 0x04;                     // Set P0.2 latch -> '1'
//   // Configure LEDs
//   P0MDIN |= 0x03;                     // P0.0, P0.1 are digital
//   P0MDOUT |= 0x03;                    // P0.0, P0.1 are push-pull
       
  // Configure LEDs
   P1MDIN |= 0x03;                     // P0.0, P0.1 are digital
   P1MDOUT |= 0x03;                    // P0.0, P0.1 are push-pull
   // Configure UART   
   P0MDOUT |= 0x10;                    // Enable UTX as push-pull output
   // Configure Crossbar
   P0SKIP |= 0x01;                     // Skip P0.0, Enable PCA output on P0.1
   XBR0    = 0x01;                     // Enable UART on P0.4(TX) and P0.5(RX)
   XBR2    = 0x40;                     // Enable crossbar and weak pull-ups
}

51单片机一样,只是地址定义会有点不同。请参考51单片机。51单片机一样,只是地址定义会有点不同。请参考51单片机。51单片机一样,只是地址定义会有点不同。请参考51单片机。

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top