MSP430 MCU application of timer, PWM, comparator[Copy link]
1. The timer uses two modes: query and interrupt. Most logic chips have the ability to output 0 more than the ability to output 1. (1) Query mode: TMSEL determines the working mode of the watchdog. If set to 1, the watchdog works in timing mode. SSEL selects the clock source of the watchdog timer. SSEL is set to 1. IS0IS1 determines the output frequency of the watchdog timer. (Note: The interrupt flag must be cleared when using query mode) main() { ... while(True) { if(IFG1&0x01) { P1OUT ^= 0x01;//Flip state IFG &=0xfe;//Clear the interrupt flag bit (2) Interrupt mode: The settings of WDTCTL are the same as the query mode. In addition, the interrupt enable bit (WDTIE, located in IE1.0) needs to be set so that the microcontroller can respond to this interrupt. #pragma vector=WDT_VECTOR __interrupt void WDT_ISR() { P1OUT ^=0x01; [size= 4]} main() { ... while(True); } 2.PWM (implemented with timer A) (1) The DA effect can be achieved by increasing the frequency, but in some cases it still cannot meet the requirements. In this case, an integration circuit is needed to obtain the ideal DA effect (2) Setting of TA: Comparison/capture module control register: capture comparison register CCRx. Note: The output PWM period should be much smaller than the integration constant of the integration circuit. To improve DA accuracy, CCR0 should not be too small. 3. Comparator