Hi Andrzej,
A correction: the app does work by setting BLE_XTAL_SETTLE_TIME: 0 as you suggested.
The problem I was dealing with has nothing to do with mynewt per se. My bad.
Kind regards

Abderrezak


On 3/15/2018 11:46 AM, Abderrezak Mekkaoui wrote:

Hi Andrzej,

Thank you for your answer. That's what I did first but it did not work. I have an app that runs as expected using the default LF CLOCK,  the XTAL_32768 used. When I switch the LF CLOCK  to  XTAL_32768_SYNTH, the app advertises correctly. When I try to connect, the app disconnects after a few seconds of trying.
I have appended below a typical log.
I am using the nordic nrf52840 preview kit in preparation of testing a board that does not have an LF crystal. Right now I would like to evaluate quickly both the LF RC based CLK and the synthesized CLK. In one of my use cases, power is not important and the device is always ON. My instincts tells me that the synthesized clock is a better choice (as stable as the HF clk) and should have worked out of the box. Any thoughts on what  I could be doing wrong? Playing around with BLE_LL_OUR_SCA, BLE_LL_MASTER_SCA and BLE_XTAL_SETTLE_TIME did not help. On the phone side I am using the nordic app (nRF Connect on android)
Best regards
Abderrezak





============================================================================================
LOG AT START OF THE MYNEWT APP:

000000 [ts=0ssb, mod=64 level=1]  BLE_PHY_MAX_PWR_DBM = 10
000001 [ts=7812ssb, mod=64 level=1]  tx_pwr_lvl =8
000002 [ts=15624ssb, mod=4 level=0] ble_hs_hci_cmd_send: ogf=0x03 ocf=0x0003 len=0
000004 [ts=31248ssb, mod=4 level=0] 0x03 0x0c 0x00
000006 [ts=46872ssb, mod=4 level=0] Command complete: cmd_pkts=1 ogf=0x3 ocf=0x3 status=0 000008 [ts=62496ssb, mod=4 level=0] ble_hs_hci_cmd_send: ogf=0x03 ocf=0x0001 len=8 000010 [ts=78120ssb, mod=4 level=0] 0x01 0x0c 0x08 0x90 0x80 0x00 0x02 0x00 0x00 0x00 0x20 000012 [ts=93744ssb, mod=4 level=0] Command complete: cmd_pkts=1 ogf=0x3 ocf=0x1 status=0 000015 [ts=117180ssb, mod=4 level=0] ble_hs_hci_cmd_send: ogf=0x03 ocf=0x0063 len=8 000017 [ts=132804ssb, mod=4 level=0] 0x63 0x0c 0x08 0x00 0x00 0x80 0x00 0x00 0x00 0x00 0x00 000019 [ts=148428ssb, mod=4 level=0] Command complete: cmd_pkts=1 ogf=0x3 ocf=0x63 status=0 000021 [ts=164052ssb, mod=4 level=0] ble_hs_hci_cmd_send: ogf=0x08 ocf=0x0001 len=8 000023 [ts=179676ssb, mod=4 level=0] 0x01 0x20 0x08 0x7f 0x1a 0x0f 0x00 0x00 0x00 0x00 0x00 000026 [ts=203112ssb, mod=4 level=0] Command complete: cmd_pkts=1 ogf=0x8 ocf=0x1 status=0 000028 [ts=218736ssb, mod=4 level=0] ble_hs_hci_cmd_send: ogf=0x08 ocf=0x0002 len=0
000030 [ts=234360ssb, mod=4 level=0] 0x02 0x20 0x00
000032 [ts=249984ssb, mod=4 level=0] Command complete: cmd_pkts=1 ogf=0x8 ocf=0x2 status=0 000034 [ts=265608ssb, mod=4 level=0] ble_hs_hci_cmd_send: ogf=0x08 ocf=0x0003 len=0
000036 [ts=281232ssb, mod=4 level=0] 0x03 0x20 0x00
000038 [ts=296856ssb, mod=4 level=0] Command complete: cmd_pkts=1 ogf=0x8 ocf=0x3 status=0 000040 [ts=312480ssb, mod=4 level=0] ble_hs_hci_cmd_send: ogf=0x04 ocf=0x0009 len=0
000042 [ts=328104ssb, mod=4 level=0] 0x09 0x10 0x00
000044 [ts=343728ssb, mod=4 level=0] Command complete: cmd_pkts=1 ogf=0x4 ocf=0x9 status=0 bd_addr=ff:22:33:aa:bb:ff 000046 [ts=359352ssb, mod=4 level=0] ble_hs_hci_cmd_send: ogf=0x08 ocf=0x002d len=1
000049 [ts=382788ssb, mod=4 level=0] 0x2d 0x20 0x01 0x00
000050 [ts=390600ssb, mod=4 level=0] Command complete: cmd_pkts=1 ogf=0x8 ocf=0x2d status=0 000052 [ts=406224ssb, mod=4 level=0] ble_hs_hci_cmd_send: ogf=0x08 ocf=0x0029 len=0
000055 [ts=429660ssb, mod=4 level=0] 0x29 0x20 0x00
000056 [ts=437472ssb, mod=4 level=0] Command complete: cmd_pkts=1 ogf=0x8 ocf=0x29 status=0 000058 [ts=453096ssb, mod=4 level=0] ble_hs_hci_cmd_send: ogf=0x08 ocf=0x002d len=1
000061 [ts=476532ssb, mod=4 level=0] 0x2d 0x20 0x01 0x01
000062 [ts=484344ssb, mod=4 level=0] Command complete: cmd_pkts=1 ogf=0x8 ocf=0x2d status=0 000065 [ts=507780ssb, mod=4 level=0] ble_hs_hci_cmd_send: ogf=0x08 ocf=0x0027 len=39 000067 [ts=523404ssb, mod=4 level=0] 0x27 0x20 0x27 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0xef 0x8d 0xe2 0x16 0x4f 0xec 0x43 0x0d 0xbf 0x5b 0xdd 0x34 0xc0 0x53 0x1e 0xb8 0xef 0x8d 0xe2 0x16 0x4f 0xec 0x43 0x0d 0xbf 0x5b 0xdd 0x34 0xc0 0x53 0x1e 0xb8 000073 [ts=570276ssb, mod=4 level=0] Command complete: cmd_pkts=1 ogf=0x8 ocf=0x27 status=0 000075 [ts=585900ssb, mod=4 level=0] ble_hs_hci_cmd_send: ogf=0x08 ocf=0x004e len=8 000078 [ts=609336ssb, mod=4 level=0] 0x4e 0x20 0x08 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x01 000080 [ts=624960ssb, mod=4 level=0] Command complete: cmd_pkts=1 ogf=0x8 ocf=0x4e status=0
000082 [ts=640584ssb, mod=4 level=0] looking up peer sec;
000084 [ts=656208ssb, mod=64 level=1]  BLE_PHY_MAX_PWR_DBM =10
000086 [ts=671832ssb, mod=64 level=1]  tx_pwr_lvl =8
000087 [ts=679644ssb, mod=4 level=0] ble_hs_hci_cmd_send: ogf=0x08 ocf=0x0008 len=32 000089 [ts=695268ssb, mod=4 level=0] 0x08 0x20 0x20 0x19 0x02 0x01 0x06 0x07 0x03 0x1a 0x18 0x0a 0x18 0x0f 0x18 0x06 0x09 0x43 0x4c 0x56 0x52 0x54 0x02 0x0a 0x08 0x03 0x19 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 000094 [ts=734328ssb, mod=4 level=0] Command complete: cmd_pkts=1 ogf=0x8 ocf=0x8 status=0 000097 [ts=757764ssb, mod=4 level=1] GAP procedure initiated: advertise; disc_mode=2 adv_channel_map=0 own_addr_type=0 adv_filter_policy=0 adv_itvl_min=0 adv_itvl_max=0 000101 [ts=789012ssb, mod=4 level=0] ble_hs_hci_cmd_send: ogf=0x08 ocf=0x0006 len=15 000103 [ts=804636ssb, mod=4 level=0] 0x06 0x20 0x0f 0x30 0x00 0x60 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x07 0x00 000106 [ts=828072ssb, mod=4 level=0] Command complete: cmd_pkts=1 ogf=0x8 ocf=0x6 status=0 000109 [ts=851508ssb, mod=4 level=0] ble_hs_hci_cmd_send: ogf=0x08 ocf=0x000a len=1
000111 [ts=867132ssb, mod=4 level=0] 0x0a 0x20 0x01 0x01
000112 [ts=874944ssb, mod=4 level=0] Command complete: cmd_pkts=1 ogf=0x8 ocf=0xa status=0 000115 [ts=898380ssb, mod=4 level=0] Command complete: cmd_pkts=1 ogf=0x0 ocf=0x0

=> SO FAR SO GOOD. ADV data appear on the phone as expected. But when we hit the connect button on the phone the app disconnects. Advertisement resumes successfully
The log below is immediately after the connection is attempted:

030205 [ts=235976500ssb, mod=4 level=0] LE connection complete. handle=1 role=1 paddrtype=1 addr=4c.f9.c0.15.b3.35 local_rpa=0.0.0.0.0.0 peer_rpa=0.0.0.0.0.0 itvl=39 latency=0 spvn_tmo=2000 mca=1
030209 [ts=236007812ssb, mod=64 level=1] connection established; status=0
030211 [ts=236023436ssb, mod=4 level=0] ble_hs_hci_cmd_send: ogf=0x08 ocf=0x0016 len=2
030214 [ts=236046872ssb, mod=4 level=0] 0x16 0x20 0x02 0x01 0x00
030215 [ts=236054684ssb, mod=4 level=0] Command Status: status=0 cmd_pkts=1 ocf=0x16 ogf=0x8
030218 [ts=236078120ssb, mod=4 level=0]         Unknown LE event
030219 [ts=236085932ssb, mod=4 level=0] Number of Completed Packets: num_handles=1
030221 [ts=236101556ssb, mod=4 level=0] handle:1 pkts:0
030223 [ts=236117180ssb, mod=4 level=0] LE Remote Used Features. handle=1 feat=ef 00 00 00 00 00 00 00

The log below is after the phone "gives up" or gets disconnected. Note that it gives 520 as the reason for disconnection.

032766 [ts=255984312ssb, mod=4 level=0] Disconnection Complete: status=0 handle=1 reason=8
032768 [ts=256000000ssb, mod=64 level=1] disconnect; reason=520
032770 [ts=256015624ssb, mod=64 level=1]  BLE_PHY_MAX_PWR_DBM =10
032772 [ts=256031248ssb, mod=64 level=1]  tx_pwr_lvl =8
032773 [ts=256039060ssb, mod=4 level=0] ble_hs_hci_cmd_send: ogf=0x08 ocf=0x0008 len=32 032775 [ts=256054684ssb, mod=4 level=0] 0x08 0x20 0x20 0x19 0x02 0x01 0x06 0x07 0x03 0x1a 0x18 0x0a 0x18 0x0f 0x18 0x06 0x09 0x43 0x4c 0x56 0x52 0x54 0x02 0x0a 0x08 0x03 0x19 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 032781 [ts=256101556ssb, mod=4 level=0] Command complete: cmd_pkts=1 ogf=0x8 ocf=0x8 status=0 032783 [ts=256117180ssb, mod=4 level=1] GAP procedure initiated: advertise; disc_mode=2 adv_channel_map=0 own_addr_type=0 adv_filter_policy=0 adv_itvl_min=0 adv_itvl_max=0 032788 [ts=256156240ssb, mod=4 level=0] ble_hs_hci_cmd_send: ogf=0x08 ocf=0x0006 len=15 032790 [ts=256171864ssb, mod=4 level=0] 0x06 0x20 0x0f 0x30 0x00 0x60 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x07 0x00 032793 [ts=256195300ssb, mod=4 level=0] Command complete: cmd_pkts=1 ogf=0x8 ocf=0x6 status=0 032795 [ts=256210924ssb, mod=4 level=0] ble_hs_hci_cmd_send: ogf=0x08 ocf=0x000a len=1
032798 [ts=256234360ssb, mod=4 level=0] 0x0a 0x20 0x01 0x01
032799 [ts=256242172ssb, mod=4 level=0] Command complete: cmd_pkts=1 ogf=0x8 ocf=0xa status=0

=====================================================================================================================================

On 3/15/2018 5:46 AM, Andrzej Kaczmarek wrote:
Hi Abderrezak,

On Thu, Mar 15, 2018 at 1:40 AM, Abderrezak Mekkaoui<ab.me...@gmail.com>  wrote:
Hi All,

I would appreciate any hints regarding  the configuration settings that need
to be changed to use a synthesized LF clock (32.768 KHz) instead of the Xtal
Oscillator clock.
This is for a BLE application.
You'll need to set following settings:
XTAL_32768: 0
XTAL_32768_SYNTH: 1
BLE_XTAL_SETTLE_TIME: 0

Depending on accuracy of your XTAL32M, you might also need to adjust
clock accuracy:
BLE_LL_OUR_SCA
BLE_LL_MASTER_SCA
This is just in case you experience unstable connections - just
increase ppm using above settings. Allowed values are described in
net/nimble/controller/syscfg.yml. With crystal mounted on nRF52840 you
won't need to touch it.

Note that using synthesized clock is not really recommended since it
will keep HFXO running all the time and draw more power than with
LFXO.

Thanks

Abderrezak
Best regards,
Andrzej


Reply via email to