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.

MSP430F149 如何实现1 min甚至更长时间喂狗一次,希望提供代码

Other Parts Discussed in Thread: MSP430F149

MSP430F149中看门狗最长1S就要喂一次狗,我现在需要更长的时间喂一次狗

  • 想要实现较长时间的复位时间,就要给看门狗配置一个低速的时钟.另外建议您看一下WDTCTL, Watchdog Timer Register

    WDTISx
    Watchdog timer interval select. These bits select the watchdog timer interval to set the WDTIFG flag and/or generate a PUC.

    00 Watchdog clock source /32768
    01 Watchdog clock source /8192
    10 Watchdog clock source /512
    11 Watchdog clock source /64
  • 这个恐怕不能实现长时间的喂狗,希望能提供一个利用定时器定时,到时间了喂狗的程序,迫切需要,谢谢
  • 大家都很忙,估计没人免费帮你写代码的,另外,代码也要配合合适的硬件才可以实现预想的功能

    如果需要项目外包,可以去21ic的外包频道发布项目试试。

  • 我用串行助手以hex的形式向MSP430单片机发送数据,每次只发送一组数据,比如十六进制的40,然后用一个数组中的一位来保存,那么这个时候数组中保存的是什么?怎样才能把它读出来实现16进制转换10进制?
    这是我的代码

    #pragma vector = UART0RX_VECTOR
    __interrupt void UART0_RXISR(void)
    {



    Data1[count1]=RXBUF0; //数据存入Data数组中

    // TXBUF0 =RXBUF0;

    if(Data1[count1++]==0) //是否到达末尾
    {

    for(j1=0;j1<count1;j1++)
    { Buffer1[j1]=Data1[j1]; }//复制字符串

    }


    Data32[0]=Data1[0];
    long v=hexToDec(Data32);

    if(v==64)
    {

    P2OUT = 0x7f;
    send_string("led is on");
    flag=1;

    }
    if(v==72)
    {

    P2OUT = 0xff;
    send_string("led is off");
    flag=1;

    }
    }

    /* 十六进制数转换为十进制数 */
    long hexToDec(char *source)
    {
    long sum = 0;
    long t = 1;
    int i, len;
    len = strlen(source);
    for(i=len-1; i>=0; i--)
    {
    sum += t * getIndexOfSigns(*(source + i));
    t *= 16;
    }

    return sum;
    }
    /* 返回ch字符在sign数组中的序号 */
    int getIndexOfSigns(char ch)
    {
    if(ch >= '0' && ch <= '9')
    {
    return ch - '0';
    }
    if(ch >= 'A' && ch <='F')
    {
    return ch - 'A' + 10;
    }
    if(ch >= 'a' && ch <= 'f')
    {
    return ch - 'a' + 10;
    }
    return -1;
    }
  • 串口调试助手发出的字符串会在UART的RX buffer里,你可以用中断或者查询的方式把数据读到一个和FIFO等长的Buffer里,这个buffer里就是你要的16进制数,比如0x40,你用16×4+0就是对应十进制了,没有你做的那么复杂。