STC10F10XE Timer interrupt Output 10KHz Square wave Program

Source: Internet
Author: User

I do the hardware also do some testing procedures, in order to test the new Motor drive board, found a 51 board when the 10K Signal Generator test IGBT switch delay time.

#include <STC_NEW_8051.H>
#include <intrins.h>
#define UCHAR unsigned char
This T0 timer interrupt program on the Internet, changed the definition and counter values, ported to STC10F10XE.
Sbit out=p2^7; Defining out-of-output ports

/*------------------------------------------------
Timer Initialization sub-program
------------------------------------------------*/
void Init_timer0 (void)
{
Tmod |= 0x01; Using the Mode 1, 16-bit timer, use "|" Symbols can be unaffected when using multiple timers
th0=0x00; Given the initial value, the timer maximum is used here to count from 0 to 65535 overflow
tl0=0x00;
Ea=1; Total Interrupt Open
Et0=1; Timer Interrupt Open
Tr0=1; Timer Switch Open
}
/*------------------------------------------------
Main program
------------------------------------------------*/
Main ()
{

clk_div=0x00; No crossover
p2m1=0x00; P2 Port push-pull output
P2m0=0xff; P2 Port push-pull output
Init_timer0 ();
while (1);
}

/*------------------------------------------------
Timer Interrupt Sub-Program
------------------------------------------------*/
void Timer0_isr (void) Interrupt 1 using 1
{
th0=255; Re-assign 11.0592M crystal oscillator, oscilloscope measured 10KHz waveform output.
tl0=211; //
Overflow then output end reverse
Out=~out; The square wave output can be seen with an oscilloscope

}

STC10F10XE Timer interrupt Output 10KHz Square wave Program

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.