ncs1.61 peripheral_uart : enable uart when connected and disable uart when disconnected

Hi,

I work with win10 laptop, Toolchain  nrf Connect SDK 1.6.1 on a nrf5340dk.

On peripheral_uart sample, I would like to enable uart when a device is connected and I want to disable uart when device is disconnected to reduce consumption.

There is the consumption mesure by PPK2:

It's seem that between two advertisings the consumption is due to the enable uart.

I need to have the lowest consumption when the nrf5340dk is advertising.

First step, I tryed to disable uart from prj.conf:

CONFIG_SERIAL=n & CONFIG_LOG=n

but after build and download the 4 led were ON and the was no more advertising.

Second step, I tryed to disable uart from the overlay file:

&uart0 {
    status = "disable";

};

but after build and download there was no led on and no more advertising.

There is my project:

5040.peripheral_uart.zip

Could you give me, please,  an example how to enable uart when a device is connected and disable uart when device is disconnected ?

Best regards,

Rob.

Parents
  • Helo Robert,

    I think you have disable the serial from Application core as well. By disabling CONFIG_SERIAL = n from prj.conf file. You just need to disable SERIAL from Network core ( you have done this in hci_rpmsg.conf). That's why it has lost connection from Application core and you are not getting advertising data. 

    I tested your code with this set up and got the following output from during current measurement. 

     

    Could you please try this and observe what is the output?

    Best Regards

    Kazi Afroza Sultana

  • Good Morning Kazi,

    Thank very much you for your answer and your help.

    I'm not sure to understand your reply, I tryed to coment  "#CONFIG_SERIAL=y" and  "#CONFIG_SERIAL=n" into prj.conf, so I have no config_serial.

    After that advertising restart and I have a wonder consumption during advertising, arround 110uA !

    But I can not use the uart when I'm connected, I tryed to send "azerty" from Rx Characteristic nothing was received by putty, after the third try it make my an error 133 Gatt Error and error 8 Gatt Conn Timeout.

    When I made a reset, the consumtion start to be around 770uA and after connect and disconnect it fall around 117uA.

    It look like the uart do not wake up after connected. I think I forgot something to wake up the uart when I'm connected. And I should maybe put the function uart_0_disable() into uart_init() to start at a low consumption after reset.

    Do you know what I should do to wake up the uart ?

    peripheral_uart_disable_b (2).zip

    Best Regards,

    Rob.

Reply
  • Good Morning Kazi,

    Thank very much you for your answer and your help.

    I'm not sure to understand your reply, I tryed to coment  "#CONFIG_SERIAL=y" and  "#CONFIG_SERIAL=n" into prj.conf, so I have no config_serial.

    After that advertising restart and I have a wonder consumption during advertising, arround 110uA !

    But I can not use the uart when I'm connected, I tryed to send "azerty" from Rx Characteristic nothing was received by putty, after the third try it make my an error 133 Gatt Error and error 8 Gatt Conn Timeout.

    When I made a reset, the consumtion start to be around 770uA and after connect and disconnect it fall around 117uA.

    It look like the uart do not wake up after connected. I think I forgot something to wake up the uart when I'm connected. And I should maybe put the function uart_0_disable() into uart_init() to start at a low consumption after reset.

    Do you know what I should do to wake up the uart ?

    peripheral_uart_disable_b (2).zip

    Best Regards,

    Rob.

Children
No Data
Related