1. Use the timer timing function to realize the timer single overflow interrupt and realize P3.0 square wave output
#include "cc430x613x.h"
void main()
{
WDTCTL = WDTPW + WDTHOLD; // Stop the watchdog timer
P3DIR |= 0x04; // Initialize P3 port and set it to output mode
TA0CCR0 = 32768; // Define the interrupt counting period as 1s, the clock frequency is 32.768MHZ, 32768 / 32768 = 1s
TA0CCTL0 = CCIE; //TA0CCR0 capture/compare interrupt register interrupt enable
TA0CTL = TASSEL_1 + MC_1 + TACLR; // TASSEL_1, ACLK clock source MC_1, up counting mode
_BIS_SR(LPM3_bits + GIE); // Enter LPM3 low power mode and enable general interrupt
}
#pragma vector = TIMER0_A0_VECTOR
__interrupt void Timer_A(void) // Timer interrupt trigger, P3 output port XOR, level flip
{
P3OUT ^= 0x04;
}
2. Use the timer timing function to realize multiple timer overflows, generate multiple interrupts accordingly, and realize P3.0 output
#include "cc430x613x.h"
void main()
{
WDTCTL = WDTPW + WDTHOLD; // Stop the watchdog timer
P3DIR |= 0x04; // Initialize P3 port and set it to output mode
TA0CCR0 = 32768; // Define the interrupt counting period as 1s, the clock frequency is 32.768MHZ, 32768 / 32768 = 1s
TA0CCTL0 = CCIE; //TA0CCR0 capture/compare interrupt register interrupt enable
TA0CCR1 = 3276; //Define interrupt overflow period 100ms
TA0CCTL1 = CCIE; //TA0CCR0 capture/compare interrupt register interrupt enable
TA0CTL = TASSEL_1 + MC_1 + TACLR; // TASSEL_1, ACLK clock source MC_1, up counting mode
_BIS_SR(LPM3_bits + GIE); // Enter LPM3 low power mode and enable general interrupt
}
#pragma vector = TIMER0_A0_VECTOR
__interrupt void Timer_A(void) // 1s overflow interrupt
{
P3OUT = ~0x04;
}
#pragma vector = TIMER0_A1_VECTOR
__interrupt void Timer_A1(void) // 100ms overflow interrupt
{
switch(TA0IV)
{
case 2:P3OUT = 0x04;break;
case 4:break;
case 10:break;
}
}
Previous article:Several ways to accurately delay the microcontroller
Next article:GPRS module and microcontroller development matters needing attention
- Popular Resources
- Popular amplifiers
- 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
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- Practical DSP28335 Programming Ideas
- Constant current source, constant voltage source, voltage drop after MOS is turned on
- Award-winning live broadcast: Application of TI millimeter-wave radar in cars is now open for registration~
- Modelsim10.4 installation and adding crack files error solution
- TI - MCU - MSP430 User Guide 1 -> MSP430 Introduction and Selection Guide
- PCB production
- Sharing 10 common formulas for switching power supply design
- Battery Management System BMS Technical Data Transfer
- [Raspberry Pi Pico Review] LCD1602 4-bit mode display driver
- There are 10 digital tubes on a digital tube display board, which uses 1 74HC00D, 2 74HC04D and 10 74HC164D