⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 suiyan.txt

📁 用C8051F023单片机串口通信C语言可编程
💻 TXT
字号:
void Serial0_Init(void)
{
   TR1 = 0;              // timer 1: stop
   SCON0 = 0x10;    //REN0 = 1;// enable UART0
   CKCON |= 0x04;   // use system clock
   TMOD &= 0x0f;
   TMOD |= 0x20;    // mode 2
   TH1 = 0xCC;      // SYCLK = 12MHZ,baudrate = 115200
   TR1 = 1;    // timer 1: start
}

OSCILLATOR初始化函数:
void OSCILLATOR_Init(void)
{
#ifdef _USB_LOW_SPEED_

   OSCICN |= 0x03;                  // Configure internal oscillator for
                                    // its maximum frequency and enable
                                    // missing clock detector

   CLKSEL  = SYS_INT_OSC;           // Select System clock
   CLKSEL |= USB_INT_OSC_DIV_2;     // Select USB clock

#else
   OSCICN |= 0x83;                  // Configure internal oscillator for
                                    // its maximum frequency and enable
                                    // missing clock detector

   CLKMUL  = 0x00;                  // Select internal oscillator as
                                    / / input to clock multiplier

   CLKMUL  = 0x80;               // Enable clock multiplier
   Delay();                         // Delay for clock multiplier to begin
   CLKMUL |= 0xC0;                  // Initialize the clock multiplier
   Delay();                         // Delay for clock multiplier to begin

   while(!(CLKMUL & 0x20));         // Wait for multiplier to lock
   CLKSEL  = SYS_INT_OSC;           // Select system clock
   CLKSEL |= USB_4X_CLOCK;          // Select USB clock

#endif // _USB_LOW_SPEED_ 
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -