This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nrf52820 power control not working from samples

We use nrf connect sdk under linux.

I need to control tx power to be able to adjust working range.

I take example from zephyr/samples/bluetooth/hci_pwr_ctrl

Add segger_rtt 

CONFIG_LOG_MINIMAL=n
CONFIG_CONSOLE=y
CONFIG_RTT_CONSOLE=y
CONFIG_UART_CONSOLE=n
CONFIG_LOG=y
CONFIG_LOG_DEFAULT_LEVEL=3
CONFIG_USE_SEGGER_RTT=y
CONFIG_LOG_BACKEND_RTT=y
CONFIG_LOG_BACKEND_UART=n
CONFIG_SEGGER_RTT_BUFFER_SIZE_UP=512
CONFIG_LOG_BUFFER_SIZE=512
CONFIG_LOG_PROCESS_THREAD=y
CONFIG_DEBUG_OPTIMIZATIONS=n
CONFIG_LOG_PRINTK=y
CONFIG_PRINTK=y
CONFIG_LOG_PRINTK_MAX_STRING_LENGTH=512

Slightly increase stack size to prevent stack overflow errors

Run it on the board and get errors

00> Set Tx power level to 4
00> 
00> Actual Tx Power: 4
00> 
00> Get Tx power level -> [00:00:15.010,467] <wrn> bt_hci_core: opcode 0xfc0f status 0x01
00> Read Tx power err: -5 reason 0x00
00> 
00> TXP = -1
00> 
00> Set Tx power level to 0
00> 
00> Actual Tx Power: 0
00> 
00> Get Tx power level -> [00:00:20.011,260] <wrn> bt_hci_core: opcode 0xfc0f status 0x01
00> Read Tx power err: -5 reason 0x00
00> 
00> TXP = -1
00> 
00> Set Tx power level to -3
00> 
00> [00:00:20.011,657] <wrn> bt_hci_core: opcode 0xfc0e status 0x12
00> Set Tx power err: -5 reason 0x00
00> 
00> Get Tx power level -> [00:00:25.012,084] <wrn> bt_hci_core: opcode 0xfc0f status 0x01
00> Read Tx power err: -5 reason 0x00
00> 
00> TXP = -1
00> 
00> Set Tx power level to -8
00> 
00> Actual Tx Power: -8
00> 
00> Get Tx power level -> [00:00:30.013,000] <wrn> bt_hci_core: opcode 0xfc0f status 0x01
00> Read Tx power err: -5 reason 0x00
00> 
00> TXP = -1
00> 
00> Set Tx power level to -15
00> 
00> [00:00:30.013,427] <wrn> bt_hci_core: opcode 0xfc0e status 0x12
00> Set Tx power err: -5 reason 0x00
00> 

Where is my mistake? May be there are other ways to control tx power? 

Parents
  • I tested this with the nRF52840 and encountered the same errors. I had to set CONFIG_MAIN_STACK_SIZE=2048 first, to get around the stack overflow issues.

    However, I was able to make it work using the Zephyr BLE Controller. Enable it by adding these to zephyr\samples\bluetooth\hci_pwr_ctrl\prj.conf

    CONFIG_BT_LL_SOFTDEVICE=n
    CONFIG_BT_LL_SW_SPLIT=y

    It's working without any errors:

    Set Tx power level to 4
    Actual Tx Power: 4
    Get Tx power level -> TXP = 4
    Set Tx power level to 0
    Actual Tx Power: 0
    Get Tx power level -> TXP = 0
    Set Tx power level to -3
    Actual Tx Power: -4
    Get Tx power level -> TXP = -4
    Set Tx power level to -8
    Actual Tx Power: -8
    Get Tx power level -> TXP = -8
    Set Tx power level to -15
    Actual Tx Power: -16
    Get Tx power level -> TXP = -16
    Set Tx power level to -18
    Actual Tx Power: -20
    Get Tx power level -> TXP = -20
    Set Tx power level to -23
    Actual Tx Power: -40
    Get Tx power level -> TXP = -40
    Set Tx power level to -30
    Actual Tx Power: -40
    Get Tx power level -> TXP = -40
    Set Tx power level to 4
    Actual Tx Power: 4
    Get Tx power level -> TXP = 4
    Set Tx power level to 0
    Actual Tx Power: 0
    Get Tx power level -> TXP = 0
    Set Tx power level to -3
    Actual Tx Power: -4

    Best regards,

    Simon

  • Thanks you for fast replay

    I cnage BLE stack as you said and it start working. It will be enough to finish project.

    But i wonder, why with official softdevice it don't work, but Nordic says that it's sometimes better than open source stack?

  • I've asked internally about this, regarding the SoftDevice Controller. I'll keep you updated

Reply Children
Related