ghaytweyhtoo

Welding Lights

 
Overview
/************************************************************
P10=1;
P11=1;
P12=1;
P13=1;****/
/**************************************************************************************

*
```
Timer 0 experiment *

```

Implementation phenomenon: After downloading the program, the D1 light turns on for 1 second and turns off for 1 second. Accurate delay can be achieved by using the internal timer of the microcontroller.
Note: None.
******************************************************************************************/

#include "stc15.h" //This file defines some special function registers of the microcontroller

typedef unsigned int u16; //Declare and define the data type
typedef unsigned char u8;

sbit led=P1^0; //Define P20 port as led
/***********************************************************************************

* Function name: Timer0Init
* Function function: Timer 0 initialization
* Input: None
* Output: None
**********************************************************************************/
void Timer0Init(void) //1 millisecond@30.000MHz
{
AUXR |= 0x80; //Timer clock 1T mode
TMOD &= 0xF0; //Set timer mode
TL0 = 0xD0; //Set timing initial value
TH0 = 0x8A; 0; //Set the initial value of the timing
TF0 = 0; //Clear TF0 flag
TR0 = 1; //Timer 0 starts timing
}

/*******************************************************************************

* Function name: main
* Function function: Main function
* Input: None
* Output: None
***************************************************************************/
void main()
{
P10=0;
P11=0;
P12=0;
P13=0;
P1M0=0x0f;
P1M1=0x00;
Timer0Init(); //Timer 0 initialization
ET0=1;//Turn on timer 0 interrupt enable
EA=1;//Turn on the total interruptwhile
(1);
}

/***********************************************************************************

* Function name: void Timer0() interrupt 1
* Function function: Timer 0 interrupt function
* Input: None
* Output: None
******************************************************************************/
void Timer0() interrupt 1
{
static u16 i;
i++;
if(i==1)
{
i=1;
P10=~P10;
P11=~P11;
P12=~P12;
P13=~P13;
}
}
参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2025-06-24 13:15:20

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
community

Robot
development
community

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号