SAM B11 BLE ULP, AON GPIO with ULP Example

Go To Last Post
10 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

The Atmel Samb11 marketing and user guides discuss the many benefits of ULP and the ability to automatically drop into ULP mode whenever there is no application task work to do, while readily awaking via interrupt from AOGPIO0-2 or AOTimer. It's all very powerful if one could get it to work as advertised...

Unfortunately, the AOTIMER example does not work, and there is no example showing how to configure the AO GPIO pins to wake up the MCU.

Worse yet, all of this is supposed to work well at the same time as BLE is operating as needed at a high priority during waking periods.

While conceptually compelling and valuable, the lack of working examples makes it difficult to impossible to get this all working. And how can it be the Explained Pro with debugger doesn't function correctly with ULP?

Does anyone have a functional example where AON properly wakes up the MCU from ULP mode, interrupting and triggering callbacks as needed?

Thanks in advance.

Rick

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

rbraddy wrote:
Hi, The Atmel Samb11 marketing and user guides discuss the many benefits of ULP and the ability to automatically drop into ULP mode whenever there is no application task work to do, while readily awaking via interrupt from AOGPIO0-2 or AOTimer. It's all very powerful if one could get it to work as advertised... Unfortunately, the AOTIMER example does not work, and there is no example showing how to configure the AO GPIO pins to wake up the MCU. Worse yet, all of this is supposed to work well at the same time as BLE is operating as needed at a high priority during waking periods. While conceptually compelling and valuable, the lack of working examples makes it difficult to impossible to get this all working. And how can it be the Explained Pro with debugger doesn't function correctly with ULP? Does anyone have a functional example where AON properly wakes up the MCU from ULP mode, interrupting and triggering callbacks as needed? Thanks in advance. Rick

 

I'd love to see this information as well.  Examples, anyone?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I never got a reply (as you can see), so I'm publishing my own example for the community to leverage as appropriate.

This is a modified version of the Samb11 Getting Started App, with working AOTIMER and AO_GPIO wakeups, combined with the iBeacon BLE example code, which advertises the node.  When there's nothing to do, it drops into ULP sleep mode.

One of the main things I added is a state machine to track application and sleep states, so when there's application work to do the main loop avoids going to sleep and whenever there's nothing to do, ULP kicks in.  In my testing, I'm seeing ULP sleep mode as low as 10 microamps or less between periodic wakeup cycles to advertise BLE (configurable).

I hope that's helpful. Wish I'd had this type of example to begin with, but learned a lot developing it.

Best,

Rick

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for your code, I'll have a look at it !

 

I know the AO_GPIO does not work with ULP and sending a platform event. I did notice the AO_GPIO platform event did get received once the AO_TIMER fired.

 

With using the iBeacon code as a basis there are a lot of BLE messages which wake up the arm, and thus the AO_GPIO platform event also gets triggered during one of the BLE messages, nice find.

 

10uA is really low. I'll let you know my results.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Finally solved my problems.

 

I could wake the ble_event_task from AO_GPIO using a platform event, but it would work only once and then crash the mcu.

 

My problem was that I was using ble libs without actually registering any ble services. Once I implemented the iBeacon service the ULP and platform events worked without problems

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Any more info you can provide about this would be helpful... which ble libs were you using, and which part of implementing the iBeacon service seemed to fix things?  (I ask for more info because it's really clear that everyone is kind of stumbling around in the dark about samb11, and trying things differently - just trying to get a baseline to understand)

 

Also, does it have any effect on the "ULP crashes after a few days" issues you were seeing?

 

 

Last Edited: Thu. Sep 7, 2017 - 04:50 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I did multiple things (always smart) so I do not know what fixed it in the end. But the basis is actually adding a service..

For iBeacon this is 

status = at_ble_adv_data_set((uint8_t *)adv_data, sizeof(ro_adv_data), (uint8_t *)scan_rsp_data, sizeof(ro_scan_rsp_data));

status = at_ble_adv_start(AT_BLE_ADV_TYPE_UNDIRECTED, AT_BLE_ADV_GEN_DISCOVERABLE, NULL, AT_BLE_ADV_FP_ANY, 16000, 0, 0);

(please see the atmel example for ibeacon for the rsp/adv data)

I also used 

ble_mgr_events_callback_handler(REGISTER_CALL_BACK, BLE_GAP_EVENT_TYPE, beacon_app_gap_cb);

ble_mgr_events_callback_handler(REGISTER_CALL_BACK, BLE_GATT_SERVER_EVENT_TYPE, beacon_app_gatt_server_cb);

to handle the events. Most of the handlers are empty (and return AT_BLE_SUCCESS)

Special one is

 

static at_ble_status_t ble_disconnected_app_event(void *param)

which contains :

at_ble_adv_start(AT_BLE_ADV_TYPE_UNDIRECTED, AT_BLE_ADV_GEN_DISCOVERABLE, NULL, AT_BLE_ADV_FP_ANY, 16000, 0, 0);

To restart the advertisement (note I have used a very long time between advertising)

I've also added

register_ble_user_event_cb(platform_event_cb);

with implementation

static void platform_event_cb(void)

{

platform_event_get(&plf_event_type, plf_event_data, &plf_event_data_len);

}

 

Of all these things the actual adding/start advertisement was the real fix, but the others things make for better code ;)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Добрый вечер.
Часто посещаю этот сайт.
Спасибо создателей сайта за интересный контент.

 

Please use English even if using Google translate

 

Good evening.
I often visit this site.
Thanks to the creators of the site for interesting content.

Last Edited: Thu. Sep 28, 2017 - 09:58 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Добрый день.
Очень нравится этот сайт.
Спасибо создателей сайта за интересный контент.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Пожалуйста, используйте английский, как указано выше, или ваша учетная запись будет заблокирована.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly