This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

在学习msp430g2553,Timer的中关于TASSEL_0 TASSEL0的区别等

请问在定时器A中有TASSEL_0和TASSEL_1和TASSEL1 和TASSEL0 有什么区别

再就是MC0和MC_0的区别

  • 你好:

    我翻了一下宏定义

    #define TASSEL1 (0x0200) /* Timer A clock source select 1 */
    #define TASSEL0 (0x0100) /* Timer A clock source select 0 */
    #define ID1 (0x0080) /* Timer A clock input divider 1 */
    #define ID0 (0x0040) /* Timer A clock input divider 0 */
    #define MC1 (0x0020) /* Timer A mode control 1 */
    #define MC0 (0x0010) /* Timer A mode control 0 */
    #define TACLR (0x0004) /* Timer A counter clear */
    #define TAIE (0x0002) /* Timer A counter interrupt enable */
    #define TAIFG (0x0001) /* Timer A counter interrupt flag */

    #define MC_0 (0*0x10u) /* Timer A mode control: 0 - Stop */
    #define MC_1 (1*0x10u) /* Timer A mode control: 1 - Up to CCR0 */
    #define MC_2 (2*0x10u) /* Timer A mode control: 2 - Continous up */
    #define MC_3 (3*0x10u) /* Timer A mode control: 3 - Up/Down */
    #define ID_0 (0*0x40u) /* Timer A input divider: 0 - /1 */
    #define ID_1 (1*0x40u) /* Timer A input divider: 1 - /2 */
    #define ID_2 (2*0x40u) /* Timer A input divider: 2 - /4 */
    #define ID_3 (3*0x40u) /* Timer A input divider: 3 - /8 */
    #define TASSEL_0 (0*0x100u) /* Timer A clock source select: 0 - TACLK */
    #define TASSEL_1 (1*0x100u) /* Timer A clock source select: 1 - ACLK */
    #define TASSEL_2 (2*0x100u) /* Timer A clock source select: 2 - SMCLK */
    #define TASSEL_3 (3*0x100u) /* Timer A clock source select: 3 - INCLK */

    有_的是直接为你提供的快捷宏定义,没有_的猜想是寄存器中的两个控制位

    本人同样新手,答错请勿怪

  • 没有什么区别,宏定义的对象都是一样的

  • 嗯,我也看了头文件,但是发现并没有理解他们的不同。我编程发现MC0的MC1的频率低,但是具体怎么回事我不知道。

  •  你怎么回事呀?怎么说没区别?楼主是起的英文名字,应该不是一般的小混混吧?很可能是外企公司的?


    例如,MC0对应两个控制位中的第0位,MC1对应第1位。而MC_0~MC_3对应两个控制位组成的二位二进制值,但是实际值还要看这两个控制位在整个控制寄存器中的位置,这可以从二楼贴出的看出来。注意有的是乘零

    所以,使用MC0和使用MC_1是一样,使用MC1和使用MC_2是一样。

  • Jack John,  TI为了方便用户编程而在头文件中定义了不同的宏,

    MC0和MC_0为例,

    #define MC1 (0x0020) /* Timer A mode control 1 */
    #define MC0 (0x0010) /* Timer A mode control 0 */

    #define MC_0 (0*0x10u) /* Timer A mode control: 0 - Stop */
    #define MC_1 (1*0x10u) /* Timer A mode control: 1 - Up to CCR0 */
    #define MC_2 (2*0x10u) /* Timer A mode control: 2 - Continous up */
    #define MC_3 (3*0x10u) /* Timer A mode control: 3 - Up/Down */

    MC0是用于直接指示MCx的低位在TACTL register的 bit4, MC0则指示MCx的第二位在TACTL register的 bit5.

    而增加下划线后的MC_0,MC_1,MC_2,MC_3则是直接说明MCx Mode control几种不同的选择时,MCx对应在TACTL register该设置的值。

    用法举例:例如你想设置 MCx Mode control为Up/down mode,

    1.如果用MC0,MC1来控制,则为 TACTL |= MC0+MC1;      ---此种用法,是直接置MCx对应位,当然也方便客户直接清对应位。但是不方便别人看程序。

    2.如果用MC_x来控制,则为 TACTL |= MC_3;  -----此种用法,更方便读者看程序。

    关于 TASSEL_0和TASSEL_1和TASSEL1 和TASSEL0的区别,以此类推。