ble_lp_clock.rst 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. Configure clock for controller
  2. ------------------------------
  3. The NimBLE stack uses OS cputime for scheduling various events inside
  4. controller. Since the code of controller is optimized to work with 32768
  5. Hz clock, the OS cputime has to be configured accordingly.
  6. To make things easier, controller package (``net/nimble/controller``)
  7. defines new system configuration setting ``BLE_LP_CLOCK`` as sets it to
  8. ``1`` so other packages can be configured if necessary. The next section
  9. describes configuration required for controller to work properly.
  10. System configuration
  11. ~~~~~~~~~~~~~~~~~~~~
  12. **Note:** All BSPs based on nRF5x have below settings automatically
  13. applied when ``BLE_LP_CLOCK`` is set, there is no need to configure this
  14. in application.
  15. The following things need to be configured for NimBLE controller to work
  16. properly:
  17. - OS cputime frequency shall be set to ``32768``
  18. - OS cputime timer source shall be set to 32768 Hz clock source
  19. - Default 1 MHz clock source can be disabled if not used by application
  20. - 32768 Hz clock source shall be enabled
  21. - Crystal settling time shall be set to non-zero value (see below)
  22. For example, on nRF52 platform timer 5 can be used as source for 32768
  23. Hz clock. Also, timer 0 can be disabled since this is the default source
  24. for OS cputime clock and is no longer used. The configuration will look
  25. as below:
  26. ::
  27. syscfg.vals:
  28. OS_CPUTIME_FREQ: 32768
  29. OS_CPUTIME_TIMER_NUM: 5
  30. TIMER_0: 0
  31. TIMER_5: 1
  32. BLE_XTAL_SETTLE_TIME: 1500
  33. On nRF51 platform the only difference is to use timer 3 instead of timer
  34. 5.
  35. On platforms without 32768 Hz crystal available it usually can be
  36. synthesized by setting ``XTAL_32768_SYNTH`` to ``1`` - this is also
  37. already configured in existing BSPs.
  38. Crystal settle time configuration
  39. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  40. The configuration variable ``BLE_XTAL_SETTLE_TIME`` is used by the
  41. controller to turn on the necessary clock source(s) for the radio and
  42. associated peripherals prior to Bluetooth events (advertising, scanning,
  43. connections, etc). For the nRF5x platforms, the HFXO needs to be turned
  44. on prior to using the radio and the ``BLE_XTAL_SETTLE_TIME`` must be set
  45. to accommodate this time. The amount of time required is board
  46. dependent, so users must characterize their hardware and set
  47. ``BLE_XTAL_SETTLE_TIME`` accordingly. The current value of 1500
  48. microseconds is a fairly long time and was intended to work for most, if
  49. not all, platforms.
  50. Note that changing this time will impact battery life with the amount
  51. depending on the application. The HFXO draws a fairly large amount of
  52. current when running so keeping this time as small as possible will
  53. reduce overall current drain.