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

📄 pllcon.c

📁 8051试验程序 基础教材
💻 C
字号:
//********************************************************************
//
// Author        : ADI - Apps            www.analog.com/MicroConverter
//
// Date          : 17 October 2003
//
// File          : pllcon.c
//
// Hardware      : ADuC845, ADuC847, ADuC848
//
// Description   : Demonstrates that the CPU can run at different
//               speeds determined by the CD bits in the PLLCON SFR.
//               2 to the power of CD (a 3 bit number), is the divider
//               ratio that determines the clock frequency at which
//               the CPU will run. (CD=0 =>fcore=12.58MHz,
//               CD=7 => fcore=98.3kHz)
//
//               Every time the INT0 button is pressed (i.e. every time
//     and external interrupt is received on INT0) the CD bits
//     in the PLLCON SFR are incremented by 1 thereby halving
//     the core frequency. Once the CD bits = 7 the next INT0
//     interrupt resets the CD bits back to 0.
//
//********************************************************************

#include <stdio.h>
#include <ioADuC845.h>  //To use the ADuC847 or ADuC848 parts simply change the header file to
//<ADuC847.h> or <ADuC848.h>

#define LED P3_bit.T0


int i;

#pragma vector=0x3

__interrupt void interrupt_0 ()
{
   LED ^= 1;
   i = 9999;
   PLLCON++;
   PLLCON &= 0x07;
}
void main (void)
{
   PLLCON = 0x0;
   TCON_bit.IT0 = 1;
   IE_bit.EX0 = 1;

   IE_bit.EA = 1;

   while(1)
   {
      LED ^=1;
      for(i = 0; i < 10000; i++)
      {
      }
   }
}

⌨️ 快捷键说明

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