Function: Use Timer1 to delay the LED light to flash in a cycle
Requirements: MPLAB 8.2 or above, a MEO engineering board, PIC16-MCD2 simulation download,
Chip configuration word, watchdog off, power-on delay on, power-off detection off, low voltage programming off, 4MXT mode oscillation
*/
#include
int main()
{
TRISC = 0x00; //c port is defined as output
PORTC = 0x00; // all off
TMR1CS = 1; //T1CON<1> Set timer1 to configure timer
T1CON = 0xb0; //1011 0000 Configuration bits read and write the Timer1 register 16 bits at a time with 1:8 prescale
TMR1 = 0; //TMR1 is assigned the initial value and the timer value is cleared
TMR1ON = 1; // Enable timer
while (1)
{
for (int i=0; i<8; i++)
{
PORTC = 0x01; //The first light is on
PORTC = PORTC>>1; //Shift right one bit
if (TMR1IF == 1) //Generate interrupt, overflow
{
TMR1IF = 0; // Clear overflow
TMR1 = 0; //TMR1 is assigned the initial value and the timer value is cleared
PORTD = 0x00; //All off
}
}
}
}
Previous article:PIC Timer Interrupt
Next article:Pic18F25K80 Timer 0 configuration in 16-bit mode
Recommended ReadingLatest update time:2024-11-25 11:08
- Popular Resources
- Popular amplifiers
- Naxin Micro and Xinxian jointly launched the NS800RT series of real-time control MCUs
- How to learn embedded systems based on ARM platform
- Summary of jffs2_scan_eraseblock issues
- Application of SPCOMM Control in Serial Communication of Delphi7.0
- Using TComm component to realize serial communication in Delphi environment
- Bar chart code for embedded development practices
- Embedded Development Learning (10)
- Embedded Development Learning (8)
- Embedded Development Learning (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Intel promotes AI with multi-dimensional efforts in technology, application, and ecology
- ChinaJoy Qualcomm Snapdragon Theme Pavilion takes you to experience the new changes in digital entertainment in the 5G era
- Infineon's latest generation IGBT technology platform enables precise control of speed and position
- Two test methods for LED lighting life
- Don't Let Lightning Induced Surges Scare You
- Application of brushless motor controller ML4425/4426
- Easy identification of LED power supply quality
- World's first integrated photovoltaic solar system completed in Israel
- Sliding window mean filter for avr microcontroller AD conversion
- What does call mean in the detailed explanation of ABB robot programming instructions?
- Corporate Culture Sharing: How to cultivate scarce silicon IP professionals? SmartDV's journey of personal growth and teamwork
- Corporate Culture Sharing: How to cultivate scarce silicon IP professionals? SmartDV's journey of personal growth and teamwork
- NXP releases first ultra-wideband wireless battery management system solution
- NXP releases first ultra-wideband wireless battery management system solution
- Beijing Jiaotong University undergraduates explore Tektronix's advanced semiconductor open laboratory and experience the charm of cutting-edge high technology
- Beijing Jiaotong University undergraduates explore Tektronix's advanced semiconductor open laboratory and experience the charm of cutting-edge high technology
- New CEO: Dr. Torsten Derr will take over as CEO of SCHOTT AG on January 1, 2025
- How Edge AI Can Improve Everyday Experiences
- How Edge AI Can Improve Everyday Experiences
- Apple is going to launch first! TSMC announces that 2nm is ready
- C64x+ Memory Organization
- Low voltage MOS tube body diode reverse breakdown voltage
- Prize live broadcast: TI takes you to learn mobile robots. This Friday at 10 am, make an appointment to watch and there will be a surprise~
- Altium Designer AD special-shaped plate layout skills
- Download Win Gift | Artesyn PMBus Interface Non-Isolated Digital DC-DC Converter
- The rated voltage of the common mode filter is 250VAC. Can it be used in DC circuits?
- TO92S enclosed 3-pin direct plug-in components have a pin spacing of only 0.45mm, and occasionally a short circuit will occur between the two pins after soldering
- [Erha Image Recognition Artificial Intelligence Vision Sensor] 3: Erha Image Recognition Vision Sensor and STM32 Communication to Realize Color Recognition Experiment
- The actual circuit does not match the simulation circuit. I don't know why. Please tell me. Thank you. The actual op amp is OP297.
- What is HAu(CN)2?