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.

Trying to lengthen cc2540 sleep times

Other Parts Discussed in Thread: CC2540

I am trying to make the device power down for longer times. I understand that it goes into sleep mode until there is an osal event, but there seems to be some event being called every 100 ms ( HalKeyRead maybe? ) which I cannot locate. I am using SimpleBLEPeripheral. I appreciate any assistance.

  • Hello Bruce,

    Welcome to the Forum!

    The first order of business is to read through the  BLE CC2540 Mini Development Kit User's Guide SWRU270B.pdf.  This document will provide you with the details on how to accomplish what you are trying to do.

    Then you will be able to use Packet Sniffer to identify this event and any others you will come across in the future. If you set the time scale to ms and you should see an event every +103ms or so.

    Inside the simpleBLEPeripheral.c file, there is a section called CONSTANTS.  This section has many of the timing intervals you will be using in this and future projects.  This is where you make the changes according to the information provided in section 4 of the guide.

    A search of the forum (and internet with keywords TI CC2540 in your question) should bring up the answers you are looking for.

    Thanks,

  • Thanks for the welcome and the advice, greenja. I have read through the User's Guide.

    The packet sniffer is not useful for this, I don't think, because the event only happens when the device is paired with the dongle. I only have one dongle so I don't know how I can both sniff and connect. But am I wrong in thinking that if the event were a broadcast, btool would pick it up? Perhaps its just a keep alive packet which btool doesn't show.

    My internet searches so far have not answered my question, but maybe I'm just not looking hard enough.

  • You will have to provide more details of your setup.  

    Is this connection between the dongle and the keyfob or an iOS device?  If is is with an iOS device and you have a keyfob, then you would use the keyfob to connect and the dongle to sniff.

    Thanks,

  • The connection is between the keyfob and dongle. I'll see if I can find someone with a newer iOS device as my iPhone 4 doesn't seem to recognize it.

  • Or you could try looking through what the CONSTANTS do and change some of their values...

  • Sorry I forgot to mention that I have already looked through all the constants within simpleBLEPeripheral.c, and I've tried changing all of them. The only has a noticeable effect on the sleep cycle is DEFAULT_ADVERTISING_INTERVAL (I'm just measuring the current on an oscilloscope), but this effect is only during advertisement of course, so once connected it always does something every ~100ms.

    I've tried to comment out  osal_start_timerEx( simpleBLEPeripheral_TaskID, SBP_PERIODIC_EVT, SBP_PERIODIC_EVT_PERIOD );   but this does not seem to do anything.

    There is a description withing hal_key.c that might give me a clue: "If polling is used, the hal_driver task schedules the KeyRead() to occur every 100ms." But I have not yet been able to find where this 100ms is set.

  • If that is indeed the case, then you can look in the simpleKeys profile and change the event settings.  You can find it in the profile folder.

  • Correction: it is set in the hal_drivers.c.  The reason it is so hard to find is that the HAL_KEY_EVENT is not used to set the timer for polling, it is an overridden value of 100.

    It is on line 221.

    Thanks,

  • I tried changing that value to 1000, but unfortunately it did not solve the problem. I've made some headway but setting some of the pins during simpleBLEPeripheral_ProcessEvent.  It seems that SBP_PERIODIC_EVT_PERIOD gets changed somewhere. When the device starts, an event timer is set to SBP_PERIODIC_EVT_PERIOD, default is 5000ms. Once SBP_PERIODIC_EVT gets called though, SBP_PERIODIC_EVT_PERIOD seems to go to 100ms. I have removed the start timer, and tried a stop timer. I don't know how to stop SBP_PERIODIC_EVT from getting called every 100ms.

  • Are you sure that this is the 100ms you're looking for this time?

    If you want to find where in the files something of interest is, you highlight it, then you can go to Edit -> Find -> Find in files or the Ctrl+Shift+F4(F3?) will do the same thing.

    Thanks,

  • I can't be sure it's the 100ms I'm looking for. I have been using ctrl-shift-F to try to find all instances, but so far no luck.

    My mind is really boggled at the moment. I commented out " if ( events & SBP_PERIODIC_EVT ){...} ". Now "SBP_START_DEVICE_EVT" gets called every 100ms even after connection.

  • O.K., let's review just exactly what you are doing here.

    You are using simplePeripheral and connecting to the dongle.  What is running on the dongle?  You should be able to adjust the connection interval on the dongle if it is the Central device or you can adjust it through BTool if you are running hostTestRelease.  The default is 100ms.

    I'm not sure if you can get adjust the time for executing the event processing routine if there are events pending.  Also, I hope you are not trying to do this when the keyfob is in the advertising state.

    Thanks,

  • Ah, yes, that connection interval was the culprit. Thank you so much, greenja.