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