亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專(zhuān)輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? f500_pca0_high_speed_output.c

?? C8051F500開(kāi)發(fā)編程:MCU全部資源應(yīng)用實(shí)例
?? C
字號(hào):
//-----------------------------------------------------------------------------
// F500_PCA0_High_Speed_Output.c
//-----------------------------------------------------------------------------
// Copyright 2008 Silicon Laboratories, Inc.
// http://www.silabs.com
//
// Program Description:
//
// This program sends a square wave out on an I/O pin, using the PCA's
// High-Speed Output Mode.
//
// In this example, PCA Module 0 is used to generate the waveform, and the
// crossbar is configured to send the CEX0 pin out on P0.0.
//
// How To Test:
//
// 1) Download code to a 'F500 device which has an oscilloscope monitoring P0.0
// 2) Make sure there is no jumper on J22.
// 3) Run the program - the waveform should be visible on the oscilloscope.
//
// Target:         C8051F500 (Side A of a C8051F500-TB)
// Tool chain:     Keil C51 8.0 / Keil EVAL C51
// Command Line:   None
//
// Release 1.1 / 11 JUN 2008 (ADT)
//    -Edited formatting
//
// Release 1.0 / 04 MAR 2008 (GP)
//    -Initial Revision
//

//-----------------------------------------------------------------------------
// Includes
//-----------------------------------------------------------------------------

#include <compiler_defs.h>
#include <C8051F500_defs.h>            // SFR declarations

//-----------------------------------------------------------------------------
// Global Constants
//-----------------------------------------------------------------------------

#define SYSCLK       24000000          // Internal oscillator frequency in Hz

#define CEX0_FREQUENCY  10000          // Frequency to output in Hz

#define DIVIDE_RATIO (SYSCLK/CEX0_FREQUENCY/2) // SYSCLK cycles per interrupt

//-----------------------------------------------------------------------------
// Function Prototypes
//-----------------------------------------------------------------------------

void OSCILLATOR_Init (void);
void PORT_Init (void);
void PCA0_Init (void);

INTERRUPT_PROTO (PCA0_ISR, INTERRUPT_PCA0);

//-----------------------------------------------------------------------------
// Global Variables
//-----------------------------------------------------------------------------

U16 Next_Compare_Value;                // Next edge to be sent out in HSO mode

//-----------------------------------------------------------------------------
// main() Routine
//-----------------------------------------------------------------------------

void main (void)
{
   SFRPAGE = ACTIVE_PAGE;              // Set SFR Page for PCA0 registers

   PCA0MD = 0x00;                      // Disable watchdog timer

   PORT_Init ();                       // Initialize crossbar and GPIO
   OSCILLATOR_Init ();                 // Initialize oscillator
   PCA0_Init ();                       // Initialize PCA0

   EA = 1;                             // Globally enable interrupts

   while (1);                          // Spin here to wait for ISR
}


//-----------------------------------------------------------------------------
// Initialization Subroutines
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
// OSCILLATOR_Init
//-----------------------------------------------------------------------------
//
// Return Value : None
// Parameters   : None
//
// This function initializes the system clock to use the internal oscillator
// at 24 MHz.
//
//-----------------------------------------------------------------------------
void OSCILLATOR_Init (void)
{
   U8 SFRPAGE_save = SFRPAGE;
   SFRPAGE = CONFIG_PAGE;

   OSCICN = 0x87;                      // Set internal oscillator to run
                                       // at its maximum frequency

   CLKSEL = 0x00;                      // Select the internal osc. as
                                       // the SYSCLK source

   SFRPAGE = SFRPAGE_save;
}

//-----------------------------------------------------------------------------
// PORT_Init
//-----------------------------------------------------------------------------
//
// Return Value : None
// Parameters   : None
//
// This function configures the crossbar and GPIO ports.
//
// P0.0   digital   push-pull     PCA0 CEX0
//
//-----------------------------------------------------------------------------
void PORT_Init (void)
{
   U8 SFRPAGE_save = SFRPAGE;
   SFRPAGE = CONFIG_PAGE;

   P0MDOUT |= 0x01;                    // Set CEX0 (P0.0) to push-pull

   XBR1    = 0x04;                     // Enable CEX0 on crossbar
   XBR2    = 0x40;                     // Enable crossbar and weak pull-ups

   SFRPAGE = SFRPAGE_save;
}

//-----------------------------------------------------------------------------
// PCA0_Init
//-----------------------------------------------------------------------------
//
// Return Value : None
// Parameters   : None
//
// This function configures the PCA time base, and sets up High-Speed output
// mode for Module 0 (CEX0 pin).
//
// The frequency of the square wave generated at the CEX0 pin is defined by
// the parameter CEX0_FREQUENCY.
//
// The maximum square wave frequency output for this example is about 230 kHz.
// The minimum square wave frequency output for this example is about 190 Hz
//
// The PCA time base in this example is configured to use SYSCLK, and SYSCLK
// is set up to use the internal oscillator running at 24 MHz.
// Using different PCA clock sources or a different processor clock will
// result in a different frequency for the square wave, and different
// maximum and minimum options.
//
//    -------------------------------------------------------------------------
//    How "High Speed Output Mode" Works:
//
//       The PCA's High Speed Output Mode works by toggling the output pin
//    associated with the module every time the PCA0 register increments and
//    the new 16-bit PCA0 counter value matches the module's capture/compare
//    register (PCA0CPn). When initially enabled in high-speed output mode, the
//    CEXn pin associated with the module will be at a logic high state.  The
//    first match will cause a falling edge on the pin.  The next match will
//    cause a rising edge on the pin, and so on.
//
//    By loading the PCA0CPn register with the next match value every time a
//    match happens, arbitrary waveforms can be generated on the pin with high
//    levels of precision.
//    -------------------------------------------------------------------------
//
// When setting the capture/compare register for the next edge value, the low
//  byte of the PCA0CPn register (PCA0CPLn) should be written first, followed
//  by the high byte (PCA0CPHn).  Writing the low byte clears the ECOMn bit,
//  and writing the high byte will restore it.  This ensures that a match does
//  not occur until the full 16-bit value has been written to the compare
//  register.  Writing the high byte first will result in the ECOMn bit being
//  set to '0' after the 16-bit write, and the next match will not occur at
// the correct time.
//
// It is best to update the capture/compare register as soon after a match
//  occurs as possible so that the PCA counter will not have incremented past
//  the next desired edge value. This code implements the compare register
//  update in the PCA ISR upon a match interrupt.
//
//-----------------------------------------------------------------------------
void PCA0_Init (void)
{
   U8 SFRPAGE_save = SFRPAGE;
   SFRPAGE = ACTIVE_PAGE;

   // Configure PCA time base; overflow interrupt disabled
   PCA0CN = 0x00;                      // Stop counter; clear all flags
   PCA0MD = 0x08;                      // Use SYSCLK as time base

   PCA0CPM0 = 0x4D;                    // Module 0 = High Speed Output mode,
                                       // Enable Module 0 Interrupt flag,
                                       // Enable ECOM bit

   PCA0L = 0x00;                       // Reset PCA Counter Value to 0x0000
   PCA0H = 0x00;

   PCA0CPL0 = DIVIDE_RATIO & 0x00FF;   // Set up first edge
   PCA0CPH0 = (DIVIDE_RATIO & 0xFF00) >> 8;

   // Set up the variable for the following edge
   Next_Compare_Value = PCA0CP0 + DIVIDE_RATIO;

   EIE1 |= 0x08;                       // Enable PCA interrupts

   CR = 1;                             // Start PCA

   SFRPAGE = SFRPAGE_save;
}

//-----------------------------------------------------------------------------
// Interrupt Service Routines
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
// PCA0_ISR
//-----------------------------------------------------------------------------
//
// Return Value : None
// Parameters   : None
//
// This is the ISR for the PCA.  It handles the case when a match occurs on
// channel 0, and updates the PCA0CPn compare register with the value held in
// the global variable "Next_Compare_Value".
//
//-----------------------------------------------------------------------------
INTERRUPT(PCA0_ISR, INTERRUPT_PCA0)
{
   if (CCF0)                           // If Module 0 caused the interrupt
   {
      CCF0 = 0;                        // Clear module 0 interrupt flag.

      PCA0CPL0 = (Next_Compare_Value & 0x00FF);
      PCA0CPH0 = (Next_Compare_Value & 0xFF00) >> 8;

      // Set up the variable for the following edge
      Next_Compare_Value = PCA0CP0 + DIVIDE_RATIO;
   }
   else                                // Interrupt was caused by other bits.
   {
      PCA0CN &= ~0x86;                 // Clear other interrupt flags for PCA
   }
}


//-----------------------------------------------------------------------------
// End Of File
//-----------------------------------------------------------------------------

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91天堂素人约啪| 精品视频一区二区不卡| 亚洲嫩草精品久久| 日韩亚洲欧美成人一区| 色综合一区二区三区| 精品影院一区二区久久久| 亚洲综合色丁香婷婷六月图片| 久久久久久久久免费| 欧美二区在线观看| 日本韩国视频一区二区| 国产99久久精品| 美女免费视频一区| 亚洲国产三级在线| 亚洲欧美一区二区三区孕妇| 久久久久久久久久久黄色| 欧美人妖巨大在线| 91香蕉视频在线| 成人网男人的天堂| 国产一区二区三区不卡在线观看 | 国产欧美日韩激情| 日韩一区二区精品葵司在线 | 久久综合成人精品亚洲另类欧美| 欧美日韩在线播| 91久久国产最好的精华液| 在线成人免费观看| 色综合天天综合在线视频| 国产91精品一区二区麻豆亚洲| 免费欧美在线视频| 日本成人在线不卡视频| 午夜欧美大尺度福利影院在线看| 亚洲精品欧美激情| 亚洲精品国产一区二区精华液| 国产精品污污网站在线观看| 国产三级欧美三级日产三级99| www久久精品| 国产午夜精品在线观看| 久久精品一区蜜桃臀影院| 亚洲精品一区二区三区精华液| 欧美一级片免费看| 日韩欧美成人激情| www国产精品av| 国产日韩亚洲欧美综合| 国产精品色哟哟网站| 综合电影一区二区三区| 一区二区三区资源| 亚洲国产成人va在线观看天堂 | 美日韩一级片在线观看| 看电影不卡的网站| 国产精品香蕉一区二区三区| 国产精品一区在线| 99这里都是精品| 91香蕉视频在线| 欧美色综合网站| 7777精品伊人久久久大香线蕉经典版下载| 欧美另类videos死尸| 日韩一区二区三区视频在线| 26uuu久久天堂性欧美| 中文字幕免费在线观看视频一区| 国产精品黄色在线观看| 亚洲国产aⅴ成人精品无吗| 日日夜夜免费精品| 国产中文字幕精品| 99精品偷自拍| 欧美精品xxxxbbbb| 久久久久国色av免费看影院| 国产精品对白交换视频 | 玉足女爽爽91| 手机精品视频在线观看| 国产一区二区三区av电影| jvid福利写真一区二区三区| 精品视频一区 二区 三区| 日韩一级免费观看| 欧美激情一二三区| 午夜精品一区在线观看| 91在线视频播放| 5566中文字幕一区二区电影| 2欧美一区二区三区在线观看视频 337p粉嫩大胆噜噜噜噜噜91av | 中日韩av电影| 亚洲国产综合色| 国产精品一区久久久久| 色噜噜久久综合| 欧美videos中文字幕| 亚洲欧美一区二区三区孕妇| 蜜臀久久99精品久久久久宅男| www.亚洲国产| 日韩欧美成人激情| 亚洲欧洲av在线| 麻豆成人av在线| 在线精品亚洲一区二区不卡| 精品999在线播放| 亚洲午夜久久久久中文字幕久| 国产很黄免费观看久久| 精品视频在线免费看| 国产精品三级在线观看| 青青草精品视频| 日本久久一区二区三区| 国产亚洲精久久久久久| 三级久久三级久久| 91日韩精品一区| 国产欧美日韩精品在线| 日本成人中文字幕| 欧美中文字幕一区二区三区 | 国产老肥熟一区二区三区| 欧美麻豆精品久久久久久| 中文字幕av不卡| 久国产精品韩国三级视频| 欧美精品在线观看播放| 1024成人网| 成人午夜精品在线| 久久日韩粉嫩一区二区三区| 免费成人在线影院| 国产精品午夜免费| 激情深爱一区二区| 91精品一区二区三区久久久久久| 亚洲欧美激情一区二区| 成人av综合在线| 国产亚洲综合在线| 九九国产精品视频| 日韩一区二区在线观看| 日韩有码一区二区三区| 在线观看视频一区二区欧美日韩| 国产精品毛片无遮挡高清| 国产乱码精品一区二区三| 日韩你懂的电影在线观看| 日韩精品乱码免费| 欧美精品亚洲一区二区在线播放| 一区二区三区欧美视频| 色老汉一区二区三区| 亚洲美女偷拍久久| 色综合久久中文字幕综合网| 亚洲图片欧美激情| 99精品国产99久久久久久白柏| 中文字幕免费在线观看视频一区| 国产精品一二三四区| 久久综合999| 国产精品亚洲视频| 国产视频一区二区三区在线观看| 国产精品亚洲午夜一区二区三区 | 97精品电影院| 中文字幕在线不卡| 91理论电影在线观看| 18成人在线视频| 色综合网站在线| 亚洲一区二区三区中文字幕在线| 欧美亚洲尤物久久| 亚洲gay无套男同| 日韩欧美一区中文| 国产一级精品在线| 日本一区二区三区在线不卡| 成人性生交大片免费| 综合中文字幕亚洲| 欧美午夜精品久久久久久超碰| 亚洲免费成人av| 欧美精品高清视频| 久久国产人妖系列| 亚洲成av人片一区二区梦乃| 7777精品伊人久久久大香线蕉的| 美女网站色91| 中文乱码免费一区二区| 色哟哟一区二区| 日韩高清不卡在线| 久久先锋资源网| 一本大道久久精品懂色aⅴ| 亚洲电影在线播放| 欧美mv日韩mv国产| 成人精品在线视频观看| 一区二区三区欧美在线观看| 91精品午夜视频| 国产精品一区在线观看乱码| 亚洲人精品午夜| 日韩欧美精品三级| 成人av动漫网站| 亚洲大片一区二区三区| 精品国产麻豆免费人成网站| 91一区一区三区| 三级亚洲高清视频| 国产精品三级电影| 91精品国产综合久久精品图片 | 久久国产精品免费| 国产精品视频看| 91麻豆精品国产91久久久更新时间| 国产精品一级二级三级| 亚洲一区二区欧美激情| 26uuu亚洲综合色| 欧美三级三级三级爽爽爽| 国产米奇在线777精品观看| 亚洲综合区在线| 久久精品日韩一区二区三区| 欧美日韩国产在线播放网站| 国产成都精品91一区二区三| 亚洲在线中文字幕| 中文一区二区完整视频在线观看| 欧美日韩大陆一区二区| 成人app网站| 久久精品国产亚洲aⅴ| 亚洲黄色av一区| 中文字幕不卡三区| 欧美成人aa大片| 欧美日韩精品电影| eeuss国产一区二区三区|