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.

Z-Stack协议栈问题

SampleAPP默认总线时钟是16MHZ 吗?

  • 默认你是说上电后还是初始化后,初始化后是32Mhz.

    上电时,都是关闭的,进入active 16MRC和32M晶振都会打开,然后就根据你的选择。

    #define HAL_BOARD_INIT()                                         \
    {                                                                \
      uint16 i;                                                      \
                                                                     \
      SLEEPCMD &= ~OSC_PD;                       /* turn on 16MHz RC and 32MHz XOSC */                \
      while (!(SLEEPSTA & XOSC_STB));            /* wait for 32MHz XOSC stable */                     \
      asm("NOP");                                /* chip bug workaround */                            \
      for (i=0; i<504; i++) asm("NOP");          /* Require 63us delay for all revs */                \
      CLKCONCMD = (CLKCONCMD_32MHZ | OSC_32KHZ); /* Select 32MHz XOSC and the source for 32K clock */ \
      while (CLKCONSTA != (CLKCONCMD_32MHZ | OSC_32KHZ)); /* Wait for the change to be effective */   \
      SLEEPCMD |= OSC_PD;                        /* turn off 16MHz RC */                              \
                                                                     \
      /* Turn on cache prefetch mode */                              \
      PREFETCH_ENABLE();                                             \
                                                                     \
      HAL_TURN_OFF_LED1();                                           \
      LED1_DDR |= LED1_BV;                                           \
      HAL_TURN_OFF_LED2();                                           \
      LED2_DDR |= LED2_BV;                                           \
      HAL_TURN_OFF_LED3();                                           \
      LED3_DDR |= LED3_BV;                                           \
                                                                     \
      /* configure tristates */                                      \
      P0INP |= PUSH2_BV;                                             \
    }

  • 在我没有做任何更改的情况下,总线频率是32MHZ ?延时程序老是做不好,所以想咨询一下初始化后的总线频率

  • 是啊,初始化程序都贴给你看了。延迟是硬delay还是软delay, us 还是ms?

  • us,输出输入延迟

  • 借鉴下面的思路,32 NOP就是1usecs

    void WaitMs(uint16 ms)
    {
        uint16 us;
    /* 32 NOPs == 1 usecs */
        while (ms--)
        {
            us=1000;
            while (us--)
            {
                /* 32 NOPs == 1 usecs */
                asm("nop"); asm("nop"); asm("nop"); asm("nop"); asm("nop");
                asm("nop"); asm("nop"); asm("nop"); asm("nop"); asm("nop");
                asm("nop"); asm("nop"); asm("nop"); asm("nop"); asm("nop");
                asm("nop"); asm("nop"); asm("nop"); asm("nop"); asm("nop");
                asm("nop"); asm("nop"); asm("nop"); asm("nop"); asm("nop");
                asm("nop"); asm("nop"); asm("nop"); asm("nop"); asm("nop");
                asm("nop"); asm("nop");
            }
        }   
    }

  • 好的,谢谢,太详细了

  • 请确认已结束这个topic。thanks