1838 views|0 replies

1669

Posts

0

Resources
The OP
 

Timer, PWM, and comparator used in msp430 microcontroller [Copy link]

1. The timer uses two methods: query and interrupt. Most logic chips have a greater ability to output 0 than to output 1.

(1) Query mode: TMSEL determines the working mode of the watchdog. If it is set to 1, the watchdog works in the 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: When using the query mode, the interrupt flag must be cleared)

main()

{

...

while(True)

{

if(IFG1&0x01)

{

P1OUT ^= 0x01; //Flip status

IFG &=0xfe; // Clear interrupt flag

}

}

}

(2) Interrupt mode: WDTCTL is set in the same way as the query mode. In addition, the interrupt enable bit (WDTIE, located at 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;

}

main()

{

...

while(True);

}

2.PWM (implemented using 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 integrator circuit is needed to obtain the ideal DA effect.

(2) Setting of TA: Compare/capture module control register: capture compare register CCRx.

Note: The output PWM cycle should be much smaller than the integral constant of the integral circuit. To improve DA accuracy, CCR0 should not be too small.

3. Comparator

This post is from Microcontroller MCU
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list