欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標題:
c8051f320單片機15個例程源碼(都是一些常用功能)
[打印本頁]
作者:
無敵游
時間:
2018-7-24 19:27
標題:
c8051f320單片機15個例程源碼(都是一些常用功能)
c8051單片機例程源碼
0.png
(8.54 KB, 下載次數: 73)
下載附件
2018-7-25 00:26 上傳
單片機源程序如下:
//-----------------------------------------------------------------------------
// F32x_External_Interrupts.c
//-----------------------------------------------------------------------------
// Copyright 2007 Silicon Laboratories, Inc.
// Program Description:
//
// This software shows the necessary configuration to use External Interrupt 0
// (/INT0) or External Interrupt 1 (/INT1) as an interrupt source. The code
// executes the initialization routines and then spins in an infinite while()
// loop. If the button on P1.6 (on the target board) is pressed, then the
// edge-triggered /INT0 input on P0.0 will cause an interrupt and toggle the
// LED.
//
// Pinout:
//
// P0.0 - /INT0
// P0.1 - /INT1
//
// P2.0 - SW1 (Switch 1)
// P2.1 - SW2 (Switch 2)
// P2.2 - LED1
// P2.3 - LED2
//
// How To Test:
//
// 1) Compile and download code to a 'F32x target board.
// 2) On the target board, connect P2.0_SW and P2.1_SW signals on J3 to P0.0
// for /INT0 and P0.1 for /INT1.
// 3) Press the switches. Every time a switch is pressed, the P2.2 or P2.3
// LED should toggle.
//
// Target: C8051F32x
// Tool chain: Keil C51 7.50 / Keil EVAL C51
// Command Line: None
//
//
// Release 1.0
// -Initial Revision (TP)
// -14 JUN 2007
//
//-----------------------------------------------------------------------------
// Include Files
//-----------------------------------------------------------------------------
#include <C8051F320.h>
//-----------------------------------------------------------------------------
// Global Constants
//-----------------------------------------------------------------------------
#define SYSCLK 12000000 // Clock speed in Hz
sbit SW1 = P2^0; // Push-button switch on board
sbit SW2 = P2^1; // Push-button switch on board
sbit LED1 = P2^2; // Green LED
sbit LED2 = P2^3; // Green LED
//-----------------------------------------------------------------------------
// Function Prototypes
//-----------------------------------------------------------------------------
void Oscillator_Init (void); // Configure the system clock
void Port_Init (void); // Configure the Crossbar and GPIO
void Ext_Interrupt_Init (void); // Configure External Interrupts (/INT0
// and /INT1)
//-----------------------------------------------------------------------------
// MAIN Routine
//-----------------------------------------------------------------------------
void main (void)
{
PCA0MD &= ~0x40; // Disable Watchdog timer
Oscillator_Init(); // Initialize the system clock
Port_Init (); // Initialize crossbar and GPIO
Ext_Interrupt_Init(); // Initialize External Interrupts
EA = 1;
while(1); // Infinite while loop waiting for
// an interrupt from /INT0 or /INT1
}
//-----------------------------------------------------------------------------
// Initialization Subroutines
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Oscillator_Init
//-----------------------------------------------------------------------------
//
// Return Value : None
// Parameters : None
//
// This routine initializes the system clock to use the precision internal
// oscillator as its clock source.
//-----------------------------------------------------------------------------
void Oscillator_Init (void)
{
OSCICN = 0x83; // Set internal oscillator to run
// at its maximum frequency
}
//-----------------------------------------------------------------------------
// Port_Init
//-----------------------------------------------------------------------------
//
// Return Value : None
// Parameters : None
//
// This function configures the crossbar and GPIO ports.
//
// Pinout:
//
// P0.0 - digital open-drain /INT0
// P0.1 - digital open-drain /INT1
//
// P2.0 - digital open-drain SW1 (Switch 1)
// P2.1 - digital open-drain SW2 (Switch 2)
// P2.2 - digital push-pull LED1
// P2.3 - digital push-pull LED2
//
//-----------------------------------------------------------------------------
void Port_Init (void)
{
XBR1 = 0x40; // Enable crossbar and weak pullups
P2MDOUT = 0x0C; // LED1 and LED2 are push-pull outputs
}
//-----------------------------------------------------------------------------
// Ext_Interrupt_Init
//-----------------------------------------------------------------------------
//
// Return Value : None
// Parameters : None
//
// This function configures and enables /INT0 and /INT1 (External Interrupts)
// as negative edge-triggered.
//
//-----------------------------------------------------------------------------
void Ext_Interrupt_Init (void)
{
TCON = 0x05; // /INT 0 and /INT 1 are edge triggered
IT01CF = 0x10; // /INT0 active low; /INT0 on P0.0;
// /INT1 active low; /INT1 on P0.1
EX0 = 1; // Enable /INT0 interrupts
EX1 = 1; // Enable /INT1 interrupts
}
//-----------------------------------------------------------------------------
// Interrupt Service Routines
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// /INT0 ISR
//-----------------------------------------------------------------------------
//
// Whenever a negative edge appears on P0.0, LED1 is toggled.
// The interrupt pending flag is automatically cleared by vectoring to the ISR
//
//-----------------------------------------------------------------------------
……………………
…………限于本文篇幅 余下代碼請從51黑下載附件…………
復制代碼
所有資料51hei提供下載:
320-15個例程.zip
(743.48 KB, 下載次數: 135)
2018-7-24 19:26 上傳
點擊文件名下載附件
c8051程序源碼(15個例程)
下載積分: 黑幣 -5
作者:
lyl_420819
時間:
2019-9-16 15:27
關于C8051F系列單片機的例程代碼可到
https://github.com下載---C8051F-master.zip
歡迎光臨 (http://www.raoushi.com/bbs/)
Powered by Discuz! X3.1