/* Name: TIMER0 and TIMER1 control the LED strip
Description: Timer T0 controls the previous set of LED strips at a faster scrolling speed
Timer T1 controls the next set of LED strips at a slower scrolling speed
*/
#include
#include
#define uchar unsigned char
#define uint unsigned int
uchar tc0=0,tc1=0;
//Main program
void main()
{
P0=0xfe;
P2=0xfe;
TMOD=0x11; //Timer 0 and Timer 1 both work in mode 1
TH0=(65536-15000)/256; //Timer 0: 15ms
TL0=(65536-15000)%256;
TH1=(65536-50000)/256; //Timer 1: 50ms
TL1=(65536-50000)%256;
IE=0x8a;
TR0=1; //Start the timer
TR1=1;
while(1);
//T0 interrupt function
void Time0() interrupt 1
{
TH0=(65536-15000)/256; //Restore the initial value of timer 0
TL0=(65536-15000)%256;
if(++tc0==10) //150ms conversion status
{
tc0=0;
P0=_crol_(P0,1);
}
}
//T1 interrupt function
void Time1() interrupt 3
{
TH0=(65536-50000)/256; //Restore the initial value of timer 1
TL0=(65536-50000)%256;
if(++tc1==10) //500ms conversion status
{
tc1=0;
P2=_crol_(P2,1);
}
}
Previous article:Summary of MCU delay methods
Next article:Design of contactless IC card industrial water meter and its water selling system
Recommended ReadingLatest update time:2024-11-15 14:40
- Popular Resources
- Popular amplifiers
- Wireless Sensor Network Technology and Applications (Edited by Mou Si, Yin Hong, and Su Xing)
- Modern Electronic Technology Training Course (Edited by Yao Youfeng)
- Modern arc welding power supply and its control
- Small AC Servo Motor Control Circuit Design (by Masaru Ishijima; translated by Xue Liang and Zhu Jianjun, by Masaru Ishijima, Xue Liang, and Zhu Jianjun)
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- DSP28335 Peripheral Clock
- Please explain the role of the window comparator here
- EEWORLD University Hall----Live Replay: TI MSP430 low-power analog peripherals help home portable healthcare products
- [Sipeed LicheeRV 86 Panel Review] I Unboxing and Basic Function Test
- [Atria Development Board AT32F421 Review] 4. Run RTX
- [MM32 eMiniBoard Review] Initial Impressions of Receiving Data Download Environment Setup
- A brief discussion on several application solutions of GPRS
- 【Embedded Qt】Building the Qt runtime environment for embedded Linux
- Project Submission
- About crossover