简体   繁体   English

TI MSP430上的低功耗模式

[英]Low Power Mode on the TI MSP430

I am using the MSP430F2274 and trying to understand better the uses of Low Power mode. 我正在使用MSP430F2274,并试图更好地了解低功耗模式的使用。

In my program I am also using the SimplicTi API in order for two devices (one is the AP which is being connected by the other , ED ) to communicate. 在我的程序中,我还使用SimplicTi API来使两个设备(一个是AP ,另一个正在连接ED )进行通信。

AP - Access Point , which is also connected to a PC via the UART in order to recive a string from the user. AP-接入点, 通过UART连接到PC,以便从用户那里获取字符串。

ED - End Device , simply connetes to the AP (with the SimplicTi protocol) and waits for messages form it. ED-终端设备,只需连接到AP(使用SimplicTi协议),然后等待它发出的消息即可。

I want to be sure I understand the low power mode uses , and to see how it "comes along" with the SimplicTi API. 我想确保我了解低功耗模式的使用,并了解它如何与SimplicTi API一起使用。

The "flow" of the AP is as follows (after it is "linked" to the ED , see the code bellow): AP的“流”如下(将其“链接”到ED之后,请参见下面的代码):

#pragma vector = USCIAB0RX_VECTOR
__interrupt void USCI0RX_ISR(void)
{
   // **A)** extract the "RXed" character (8 bits received from user) , use the while 
   // in order to be sure all the 8 bits are "desirialized" into a byte  
   while (!(IFG2 & UCA0RXIFG));   
   input_char = UCA0RXBUF;     // input_char is global variable.

   // **B)** if we received the "Enter" character , which indicates the 
   //    end of the string 
   if(input_char == '\r' && input_count > 0)      
   {

      TACCR0 = 10;   // **F)**
      TACTL = TASSEL_1 + MC_1; // ACLK, up mode
      // **E)** Enter LPM3, interrupts enabled !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
      __bis_SR_register(LPM3_bits + GIE); 

    }//end if Enter


    // **C)** Any other char of the user's string when we 
   //    have not got more than the maximum amount of bytes(chars)
    else if (((FIRST_CHAR <= input_char && input_char <= LAST_CHAR) || ('a' <=  input_char && input_char <= 'z')) && (input_count < INPUT_MAX_LENGTH)) 
    {
        input[input_count++] = input_char;
    }


}  //end of UART RX INTERRUPT

The TIMERA0 Interrupt Handler is the following code: TIMERA0中断处理程序为以下代码:

#pragma vector=TIMERA0_VECTOR
__interrupt void Timer_A(void)
{
    if (i == strlen(morse))      // **D)** morse is a global array of chars  who holds the string that we wish to send 
    {
        SMPL_Send(sLID[0], (uint8_t*)EOT, 1);             // EOT is the last char to send 
        TACTL = MC_0;                         //disable  TimerA0 
    }


    else if (!letterSpace)
    {
       char ch = morse[i++];  
       SMPL_Send(sLID[0], (char*)ch, 1); 

       switch(ch)
       {
         case '.':
           {
             TACCR0 = INTERVAL * 3;
             letterSpace = 1;
             break;
           }

          case '-':
           {
              TACCR0 = INTERVAL * 3 * 3;
              letterSpace = 1;
               break;
            }
       } // switch 

   }  // else if 

}  //end TIMERA0 interrupt handler 

The thing is like that: 事情是这样的:

I use the TIMERA0 handler in order to send each byte after a different amount of type , whether the char was transformed into a "-" or a "." 我使用TIMERA0处理程序,以便在将不同的char类型转换为“-”或“。”之后发送每个字节。

To do so I set the timer accordingly to a different value ( 3 times larger for "-"). 为此,我将计时器设置为不同的值(“-”的值是其三倍)。

Finnaly when I am done transmitting the whole string ( D ) , I disable the timer. 最后,当我完成传输整个字符串( D )时,我禁用了计时器。

NOTE : The following method is performed at the begining of the AP code in order to configure the UART: 注意:为了配置UART,在AP代码的开头执行以下方法:

void UARTinit()
{
    P3SEL = 0x30;           // P3.4 and P3.5 as the UART  TX/RX pins: P3SEL |= BIT4 + BIT5;                
    UCA0CTL1 |= UCSSEL_2;  // SMCLK    

    // pre scale  1MHz/9600 =~ 104. 
    UCA0BR0 = 104;         
    UCA0BR1 = 0;     

    // 8-bit character and Modulation UCBRSx = 1
    UCTL0 |= CHAR;  
    UCA0MCTL = UCBRS0;  

    UCA0CTL1 &= ~UCSWRST;                     // **Initialize USCI state machine**
    IE2 |= UCA0RXIE;                          // Enable UART INPUT interrupt

}  // end of UARTinit

So my questions are: 所以我的问题是:

1) Just to be sure, in A) where I am "polling" the Rx buffer of the UART , is it necceary or is it just good practise for "any case" , cause AFAIK the UART handler gets called once the UART module recived the whole BYTE (as I configured it)? 1)可以肯定的是,在A)中 ,我在“轮询” UART的Rx缓冲区,这是必要的还是“任何情况”的好习惯,导致AFAIK,一旦UART模块恢复,UART 处理程序就会被调用整个BYTE (按我的配置)?

2) In the main program of the AP , the last instruction is the one that "puts" it into LPM0 with interrupts enables : __bis_SR_register(LPM0_bits + GIE); 2)在AP的主程序中,最后一条指令是通过中断启用将其“放入” LPM0的指令:__bis_SR_register(LPM0_bits + GIE);

When for LPM0: 何时使用LPM0:

  • CPU is disable CPU已禁用
  • ACLK and SMCLK remain active ACLK和SMCLK保持活动状态
  • MCLK is disabled MCLK被禁用

And for LPM3: 对于LPM3:

  • CPU is disable CPU已禁用
  • MCLK and SMCLK are disabled MCLK和SMCLK被禁用
  • ACLK remains active ACLK保持有效

As I see it ,I can not enter LPM3 cause the AP needs the SMCLK clock not to be disable? 当我看到它,我不能进入LPM3导致AP需要SMCLK时钟不被禁止? (cause the UART uses it) Is that correct? (因为UART使用它)那是正确的吗?

3) In F) , is it a proper way to call the TIMERA0 handler ? 3)在F)中 ,调用TIMERA0处理程序是否合适? I perfrom TACRR0 = 10 , cause it is a small value which the timer will reach "in no time" just so it will enter the TIMERA0 handler to perform the task of sending the bytes of the string. 我从TACRR0 = 10开始,因为它是一个很小的值,定时器将立即“达到”,因此它将进入TIMERA0处理程序以执行发送字符串字节的任务。

4) For the "roll back" in the AP: As I see it , the "flow" is like that: 4)对于AP中的“回滚”:正如我所看到的,“流程”是这样的:

enters LPM0 (main) --> UART gets interrputed --> exit LPM0 and goes to the UART handler --> when it is done reciving the bytes (usually 5) it enters LPM3 --> the timer finishes counting to TACRR0 value (which is 10) --> the TIMERA0 handler gets called --> when the TIMERA0 handler done sending the last byte it disables the timer (TACTL0 = MC_0;) --> we "roll back" to the instruction which got us to LPM3 within the UART handler --> ?? 进入LPM0(主要)-> UART插入->退出LPM0并进入UART处理程序->接收完字节(通常为5)后进入LPM3->计时器完成对TACRR0值的计数(这是10)-> TIMERA0处理程序被调用->当TIMERA0处理程序完成发送最后一个字节时,它将禁用计时器(TACTL0 = MC_0;)->我们“回滚”到将我们转到LPM3的指令在UART处理程序中-> ??

Now , does ?? 现在,是吗? is "rolling back" to the instrcution which took us to LPM0 within the main program , OR do we "stay here" (in the instruction that entered us to LPM3 within the UART handler E) ? 是“回退”到将我们带到主程序中的LPM0的指令,还是“留在这里”(在UART处理程序E中将我们输入到LPM3的指令中 If we do stay on E) , do I need to change it to LPM0 cause , again, the UART uses the SMCLK which is NOT active in LPM3 but indeed active in LPM0 ? 如果我们确实停留在E)上 ,我是否需要将其更改为LPM0原因,同样,UART使用SMCLK,该时钟在LPM3中无效,但实际上在LPM0中有效?

5) Any other comments will be super !! 5)任何其他评论将是超级!

Thanks allot, Guy. 谢谢分配,盖。

1) This will work 1)这将起作用

2) When you config this: 2)配置时:

UCA0CTL1 |= UCSSEL_2;  // SMCLK

This mean that UART used SMCLK, SMCLK will stop when you make MCU turn to LPM3;so that UART will not work, you should config UART use ACLK, this will make UART work in LPM3 mode. 这意味着UART使用SMCLK,当您将MCU转到LPM3时,SMCLK将停止;因此要使UART不起作用,应将UART配置为使用ACLK,这将使UART在LPM3模式下工作。

3) ... 3)...

4) ... 4)...

5) See 2 5)见2

I hope this will help you 我希望这能帮到您

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM