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.

bluetooth-shutdown in bluetopia SPPDemo

Other Parts Discussed in Thread: MSP430F5438A

Hi,

i am building an application with MSP430F5438A + PAN1326.
i would like to have the controller as well as the BT-Module in sleep-mode, when inactive.

in the hrdwcfg.h the BT_DEVICE_RESET_PORT_PIN is defined an connected to the nShutD-Pin on the PAN. this Line should be low for sleep, but it is always high!!

question1: is this feature considered in the SPPDemo?
question2: how and on which position shall i implement the sleep and wake?

thanks

  • Hi Daniel,

    Sleep is already implemented as part of  MSP430F5438A + PAN1326.

    The nSHUTDOWN initializes a boot-up of the CC256x device, please see http://processors.wiki.ti.com/index.php/CC256x_Testing_Guide#nSHUTDOWN_and_HCI_RTS

    Also see http://processors.wiki.ti.com/index.php/CC256x_eHCILL_Low_Power_Protocol

  • Hi,

    thanks for your reply.

    if i understood this correct, the nSHUTDOWN - line has nothing to do with shutdown or sleep-mode. it is just the reset-line!?

    i found some HCILL-code in the Main.c

    Result = HCI_Reconfigure_Driver(BluetoothStackID, FALSE, &DriverReconfigureData);
    if(Result > 0)
    {
    /* Flag that sleep mode is enabled. */
    SleepEnabled = TRUE;
    }

    i tried to set a breakpoint there, but it is never reached?!

    how can i check, that the module is in sleep?
    can or should i force the module to sleep?

    i have an application, which is usually in standby, and so the MSP430 and also the PAN shall consume as low energy as possible.

    edit:
    the BT-Module seems to be always on, because i can always find it with my phone.
    so the question is, how can i make it sleep? is there any command? or even better - any sample?

  • Hi Daniel,

    The nSHUTDOWN initializes a boot-up of the CC256x device and used as reset.

     

    You don’t have to force the module to sleep. If there inactivity over UART for 100ms (defined by the init script), the chip will go to sleep.

    And you are placing the break point when you are Registering the sleep mode callback? This is done during the boot up, so the break point has to be there during boot up.

    In any case, sleep mode will be enabled if the necessary command is present in the init script.

    The HCILL mechanism is handled in the stack (which is not exposed).Otherwise, you can check for GO_TO_SLEEP_IND(0x30) coming from the chip.

     

    the BT-Module seems to be always on, because i can always find it with my phone.?

    For this you have to disable the discoverable mode of the chip. Sleep does not mean that the chip is turned off.

  • Sundeep Mandava said:
    For this you have to disable the discoverable mode of the chip. Sleep does not mean that the chip is turned off.

    ok, maybe i asked the wrong question..

    i would like to turn it off!
    see the attachment, i would like to reach the 1uA, not the 40uA...

    this is why i asked for the shutdown-line...

  • Hi Daniel,

    You need to toggle the GPIO to see the Current consumption in shutdown mode.

  • ok, but i think this GPIO is also used for reset/boot/initialisition of the PAN on other positions in the code!?

    i do not want to disturb any of the existing parts..

    this was my original question, on which position of the SPPDemo do you recommend to switch off the PAN?

    is there any initialisation necessary after the PAN comes back from shutdown?

    or is there no problem at all? can i just switch off and on the PAN in my application without regarding anything else?

  • Hi Daniel,

    If you want to test the current consumption in shutdown mode, you need to toggle the GPIO(down).

    Yes the PAN will be switched off if you toggle the GPIO(down). and Yes you need to download the service pack once again after coming back from shutdown.

  • Sundeep Mandava said:
    Yes you need to download the service pack once again after coming back from shutdown.

    ok, 
    is this the initialisation-stuff of MainThread() from the main.c?
    ..to get a new bluetoothStackID?

    do you have a sample of this "download service-pack" ? (i love samples :o) )

    in the code i cannot find any parts with a comment "download service-pack"!?

    thanks!

    edit:
    i found this comment in another thread from miguel:
    "The SP is no more than HCI VS cmds that need to be executed for device initialization. The SPs are provided in a BTS file but it can be converted to C array (pure HCI commands) by using the CC256x BHET."
    but i do not know how to do that? BTS? BHET?

    is it possible to create a method ReInitializeBT()?
    if yes, how should it look like?

  • Hi Daniel,

    Please have a look at the function "Download_Patch()" in file BTPVEND.c

  • thanks for the advice, but it does not work...

    i implemented (quick&dirty):
    HCI_VS_InitializeAfterHCIReset(1, 1);
    in my code. this function calls the Download_Patch() and gives the necessary parameters with it...

    but when i debug the result of Download_Patch it is 0 instead of 1 - any error occured!?

    how i tested:
    - boot up as usual - everything works fine.
    - pull btSHUTDOWN to GND manually for a while
    - connect btSHUTDOWN back to the GPIO
    - run the HCI_VS_InitializeAfterHCIReset(1,1)
    - check for the result in the return of Download_Patch (shoud be 1, but isnt..)

    Edit:
    i found out, that the HCI_Send_Raw_Command() fails with Result = -14

    the Download_Patch() Method looks good, but i am not able to run it successfully!?
    no matter what i do, on boot-up it works fine, and when i try to run it manually after the reset, it throws the error -14.
    is there anything else to do before Download_Patch() can be started?

  • do i have to take care of the HCI_RTS, or is this handeled automatically by the stack / SPPDemo-Sample?

    my Download_Patch() after Reset is still not working ...

  • Hi,

    If you are planning to completely shutdown the chip then BSC_Shutdown() needs to be called when your are not using Bluetooth and and then call BSC_Initialize() when you want to use Bluetooth again.

    Thanks,

    Stonestreet One.  

  • Hi SS1,
    thanks for your reply,
    i think this is the right way ...

    the BSC_Shutdown() works fine, and i can measure, that the SHUTDOWN-Line goes to low,
    but the BSC_Initialize() does not work correct until now. I can measure, that the SHUTDOWN-Line goes back to high, but the Returnvalue is 0, but it should indicate the BluetoothStackID!?

    what i did:

    - i create a copy of the HCI_DriverInfo in my SPPDemo in InitializeApplication() (which is called from Main):
    static HCI_DriverInformation_t       *HCI_DriverInformationCopy;
    HCI_DriverInformationCopy = HCI_DriverInformation;
    - then i use this to shutdown:
    BSC_Shutdown(BluetoothStackID);
    - and this to wake the BT:
    result = BSC_Initialize(HCI_DriverInformationCopy, 0);

    here the result is 0, but it should not be 0!? the initialisation on boot-up gives a 1 as result...

  • Daniel,

    We tried shutting down and initialize the stack again and didn't find any issues. It always returned an integer for us. Can you may be try setting BluetoothStackID=0 after you do a BSC_Shutdown(BluetoothStackID); and see if that makes a difference. 

    Thanks,

    Stonestreet One.

  • Stonestreet One Support said:
    Can you may be try setting BluetoothStackID=0 after you do a BSC_Shutdown(BluetoothStackID); and see if that makes a difference.

    no difference ... the result is 0.

    how do you generate the parameters for the BSC-Methods? they are given from the mail.c, and i copy the hci-driverinformation when the application is initialized. maybe those parameters are not correct for the re-initialisation?

  • Hi,

    We used the same HCI_DriverInformationCopy that you used. Here is our code snippet for shutdown

    if(BluetoothStackID)
    {
    /* Simply close the Stack */
    BSC_Shutdown(BluetoothStackID);

    Display(("Stack Shutdown.\r\n"));

    /* Flag that the Stack is no longer initialized. */
    BluetoothStackID = 0;

    /* Flag success to the caller. */
    ret_val = 0;
    }
    else
    {
    /* A valid Stack ID does not exist, inform to user. */
    ret_val = UNABLE_TO_INITIALIZE_STACK;
    }

    And here is our code snippet for Initialize

    if((HCI_DriverInformationCopy))
    {
    Display(("\r\n"));
    Result = BSC_Initialize(HCI_DriverInformationCopy, 0);
    Display(("Result: %d\r\n", Result));
    if(Result > 0)
    {
    /* The Stack was initialized successfully, inform the user */
    /* and set the return value of the initialization function */
    /* to the Bluetooth Stack ID. */
    BluetoothStackID = Result;
    Display(("Bluetooth Stack ID: %d\r\n", BluetoothStackID));

    }
    else
    {
    /* The Stack was NOT initialized successfully, inform the */
    /* user and set the return value of the initialization */
    /* function to an error. */
    DisplayFunctionError("Stack Init", Result);

    BluetoothStackID = 0;

    ret_val = UNABLE_TO_INITIALIZE_STACK;
    }
    }

  • thanks for the snipets!
    very funny... i thought i had exactly the same code!? but i copy/paste your snipets and now it works fine! i dont know where the difference is, but doesnt matter ...

    but now i am facing another problem:
    when i reinitialize the stack i get BluetoothStackID=2 instead of 1.
    and when i try to connect to my already paired phone it asks for pairing, instead of accepting the connection.

    i stored the linkkeys and BDADDR in the flash and use it hardcoded to connected to my phone. this worked fine until i got the Stack-ID=2

    is it possible to force Stack-ID=1? this might solve the problem!?

    or any other ideas?

    thanks.

  • Hi,

    those two BSC-Methods work fine, but i still have the problem, that the Bluetooth-Stack-ID is incremented, and then i cannot connect to my phone due to an error with the linkkeys!?

    is there any possibility to get StackID = 1 after reinitialization? i suppose, this could solve the issue with the linkkey!?
    i use the data stored in LinkKeyInfo[0] to open the remote server (hardcoded infos of the connection), but this should not regard to any BluetoothStackID!?

    i also tried to use the Methods CloseStack() and OpenStack(), but both hang up.
    the BTPS_DeInit() makes troubles. it hangs up here.

  • Daniel,

    The BluetoothStackID will increment each time you shutdown and initialize but The stackID shouldn't matter with the link key. You might have to look at your code for saving the link key for the issue.

    Thanks,

    Stonestreet One.