MSP430--Timer B

Publisher:cwk2003Latest update time:2015-09-29 Source: eefocusKeywords:MSP430 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
The MSP430 16-bit timer B module is an important resource of the microcontroller. The MSP430F13/14/15x series all have timer module B, but the comparison/capture module functions of different microcontroller series are different.

1. Timer B module:

TimerB is mostly the same as TimerA, except that a latch is added to the capture/compare unit of Timer B.

The difference between the two:

(1) The count length of Timer B is programmable to 8, 10, 12, or 16 bits, which is configured by the two bits CNTLx in the TBCTL register, while the count length of Timer A is fixed at 16 bits;

(2) Timer B does not implement the SCCI function bit in Timer A;

(3) The capture/compare register function of TimerB in compare mode is different from that of TimerA, and a capture compare latch is added;

(4) In some chip models, TimerB output realizes high impedance output;

(5) The principle of the comparison mode is different: the CCRx register in TimerA stores the data to be compared with TAR, while the CCRx register in TimerB stores the data to be compared, but it is not directly compared with the timer TBR. Instead, the data in CCRx is latched into the corresponding latch, and then compared with TBR by the latch. The time of transmitting data from the capture/compare register to the comparison latch is also programmable. It can be transmitted immediately after writing to the comparison capture register, or a timer can be used to trigger the transmission.

(6) TimerB supports multiple synchronous timing functions, multiple comparison capture functions and multiple waveform output functions (PWM waves). Moreover, through two-level buffering of comparison data, multiple PWM waves can be updated synchronously.

2. Logical structure diagram of TimerB: The logical structure of Timer B is basically the same as that of Timer A.
[Reprint] MSP430--Timer B
[Reprint] MSP430--Timer B

3. Registers of timer B:

For the configuration process of the relevant bits of the register, refer to Timer A and the data manual.

[Reprint] MSP430--Timer B
4. Comparison function of timer B

When timer B operates in compare mode, the data is written into the capture compare latch TBCCRx. When the load event determined by the CLLDx bit in TBCCTLx occurs, the data in TBCCRx is automatically transferred to the compare register.

5. Routine provided by TI:

//
//   // 
//
//                MSP430F149
//             -----------------
//         /||               XIN|-
//          | |                  | HF XTAL (455k - 8MHz)
//          --|RST           XOUT|-
//            |                  |
//            |          P4.1/TB1|--> CCR1 - 75% PWM
//            |          P4.2/TB2|--> CCR2 - 25% PWM
//
/ /   M. Buccini
//   Texas Instruments Inc.
//   Feb 2005
//   Built with IAR Embedded Workbench Version: 3.21A
//**************************** *************************************************** *****

#include   

void main(void)
{
  volatile unsigned int i;
  WDTCTL = WDTPW +WDTHOLD;                   // Stop WDT

//System clock initialization
  BCSCTL1 |= XTS;                            // ACLK= LFXT1 = HF XTAL

  do
  {
  IFG1 &= ~OFIFG;                            // Clear OSCFault flag
  for (i = 0xFF; i > 0; i--);                // Time for flag to set
  }
  while ((IFG1 & OFIFG));                    // OSCFault flag still set?

  BCSCTL2 |= SELM_3;                         // MCLK= LFXT1 (safe)

//io port initialization
  P4DIR |= 0x06;                             // P4.1 and P4.2 output
  P4SEL |= 0x06;                             // P4.2 and P4.2 TB1/2 otions

//Configuration of timer B
  TBCCR0 = 128;                              // PWM Period/2
  TBCCTL1 = OUTMOD_6;                        // CCR1 toggle/set
  TBCCR1 = 32;                               // CCR1 PWM duty cycle
  TBCCTL2 = OUTMOD_6;                        // CCR2 toggle/set
  TBCCR2 = 96 ;                               // CCR2 PWM duty cycle
  TBCTL = TBSSEL_1 + MC_3;                   // ACLK, up-down mode

  _BIS_SR(CPUOFF);                           // Enter LPM0
}

Keywords:MSP430 Reference address:MSP430--Timer B

Previous article:Use of pull-up and pull-down resistors
Next article:MSP430--General IO Port

Recommended ReadingLatest update time:2024-11-16 14:29

Study STM32 summary of single chip microcomputer (msp430, c8051, etc.) general learning method
1. A board has the necessary power supply lines and the necessary simulation download and debug lines (such as J-link for STM32)   2. Install the development environment: keil4 (c51 or ARM series registration), it seems that there is also msp430 series. First, make sure what series the board is. IAR EWARM is (ARM
[Microcontroller]
Design of high-speed temperature acquisition system based on MSP430 and uPD720200
0 Preface The USB3.0 high-speed data acquisition system, with its 5Gbps bandwidth and plug-and-play performance, is gaining more and more attention. Currently, the commonly used USB3.0 communication chips are mainly the EZ USB FX3 series chips developed by Cypress (CYPRESS) in the United States and the uPD720200 serie
[Microcontroller]
Design of high-speed temperature acquisition system based on MSP430 and uPD720200
MSP430 Clock Settings (I)
1. There are three clock sources in the MSP430 microcontroller: One LFXT1CLK is a low-speed/high-speed crystal oscillator source, usually connected to 32.768khz, and can also be connected to (400khz~8Mhz); One is XT2CLK, which is connected to a standard high-speed crystal oscillator, usually 8Mhz, but can also be co
[Microcontroller]
MSP430 Timer Introduction
1. Timer parameters 1.1 Basic Timer typedef enum {   TIMER_A0 ,   TIMER_A1 ,   TIMER_A2 ,   TIMER_B0 ,   TIMER_NUM , }TIMERn; //Timer module 1.2 Timer channel pins and clock selection const GPIO_PIN TIMER_CHANEL_PIN = {// CH0 CH1 CH2 CH3 CH4 CH5 CH6   {{P1,1},{P1,2},{P1,3},{P1,4},{P1,5}}, //TIMER_A0   {{P1,7},{P2,0}
[Microcontroller]
MSP430 Timer Introduction
Display the light intensity value on LCD1602 based on MSP430F149 and BH1750FVI
BH1750FVI is a digital light intensity sensor integrated circuit based on IIC bus protocol. The following is its program: #include "io430x14x.h" typedef unsigned int uint; typedef unsigned char uchar; #define SCL_H P3OUT |= BIT6 //This IO needs to be changed on the hardware #define SCL_L P3OUT &= ~BIT6 #define
[Microcontroller]
Understanding the MSP430 SPI bus in one article
The SPI bus system is a synchronous serial peripheral interface; it is a high-speed, full-duplex, synchronous communication bus, and it only occupies four wires on the chip pins, saving the chip pins, while saving space on the PCB layout and providing convenience. It is precisely because of this simple and easy-to-use
[Microcontroller]
Understanding the MSP430 SPI bus in one article
Note on issues when using parallel port JTAG to simulate downloading of MSP430
Today, I spent a long time solving the MSP430 JTAG download problem. Finally, it turned out to be a port mode problem. The default parallel port mode in my BIOS is SSP mode, but if you use JTAG, you need to change it to ECP or EPP mode. Finally, after entering the BIOS and correcting it, there is no problem, and I c
[Microcontroller]
Note on issues when using parallel port JTAG to simulate downloading of MSP430
Design of intelligent car based on MSP430
Smart cars involve many disciplines such as advanced computer control, electronic machinery, and automation. With the continuous advancement of science and technology, the development of smart electronic products is accelerating, and robots of various application levels are appearing in large numbers. The microcontroll
[Microcontroller]
Design of intelligent car based on MSP430
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号