-
Notifications
You must be signed in to change notification settings - Fork 3k
[STM32F0xx] LowPowerTicker implementation #1796
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
* return the desired timestamp value to configure RTC exactly with the value | ||
* provided by the user and to fulfill the mBed ticker architecture. | ||
*/ | ||
return m_timestamp; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/mbedmicro/mbed/blob/master/hal/hal/lp_ticker_api.h#L56
This should return current counter. how does it work for a use case like:
start = lp_ticker_read();
while (start + 10000 < lp_ticker_read()) {
sleep();
}
Please run lp ticker test and share the results |
I can't find the lp ticker test. Which one is it ? |
Hi, @bcostm, @0xc0170,
Also, I will try to figure out something tomorrow, if we can return the periodic unit counter value, because that unit is doing all the counting by it self and that's why I'm cheating mbed. |
Yes ,it's https://github.com/mbedmicro/mbed/blob/master/libraries/tests/utest/lp_ticker/lp_ticker.cpp, using cpputest . I would say this test should fail for this implementation. If it is not, we should fix the test, and then this implementation. I would expect to be able to read the timer's counter, in this case RTC (might be required some computation to do). |
Any update? There are multiple pull requests with the same issue |
Hi @0xc0170, I will update you late afternoon. Thanks. |
@0xc0170, |
@bcostm I remember reading this a while back : http://stm32f4-discovery.net/2014/07/library-19-use-internal-rtc-on-stm32f4xx-devices/ , you can read time from RTC and convert that at least to milliseconds (subseconds) ? |
@0xc0170 All right but what about microseconds? I can't really agree with your quick proposal because the Wake-Up unit, which is almost in all STM's is designed to wake the device after some time amount. The range is from 122us to even 97days and all the calculation is done inside it, that's why there is no CNT register available in RTC peripheral. As I saw it, in We need to find a compromise, either we want to have the LowPowerTicker functionality or give the user ability to read the counter value from LowPowerTimer modules. From my perspective and what I'd like to have in mBed is the ability to attach my callback and put the device into sleep mode - period. Thanks. |
You can't expect microseconds from the lp ticker, that is not possible in all cases. It was chosen to be microseconds to be compatible with us ticker API.
Why ? You can't read RTC time and convert it to milliseconds? I am not familiar with RTC unit in the STM32 chips, I am just missing details why it is not possible. I find it hard to believe I can't use read the time from RTC unit, when I see there's subseconds in the reference manual. Please provide details. What we did for instance for K64F for another version of lp ticker, we combinted 2 low power timers , RTC to read seconds, and lower units, up to 0xffff milliseconds, from another timer. A hybrid.
Yes, it might be this use case, but API is defined for read() to return current counter. And we can see LowPowerTimer uses this function to return current time. Please state any shortcomings like this in the commit message for future. |
Why not just use the implementation that is used here: https://developer.mbed.org/users/Sissors/code/WakeUp/file/49ca85e8822f/Device/WakeUp_STM_RTC.cpp It works also on the F030 and similar ones. The periodic unit one is not implemented on those. It simply uses instead of the periodic unit, the regular RTC. With the subseconds register you can get (not completely surprising), subsecond resolution. Since there I don't tamper with the mbed RTC settings i get around 3ms resolution. However by changing some settings in the RTC you can get 1/32000 resolution. (At the cost of a bit more current consumption in deepsleep, but I don't think it is that much). By setting the alarm to the correct time you can wake up after a certain amount of time has passed. Only real obstacle I see: If someone changes the RTC time, it also changes the LowPowerTimer time. |
Hi @0xc0170,
Even when we will put the compatibility aside, now with the RTC periodic unit we can reach us.
That we could do but we've wanted to use a dedicated unit to wake up the platform. So I think that we need to focus on actual implementation. Please tell me what's more important for you. Is it the actual read counter value or is it the actual test pass? Because when you will run (or take a look) a
Will do so in future Thanks |
Both are. The tests shall be fixed, Can you please add RTC read functionality into |
@0xc0170 is this implementation ok for you ? |
I've updated this PR and now the min time is 2ms, we can't reach 1ms and due to that it's 100% that we will not pass UT_LPTICKER test. I find that really strange, because with the initial implementation we were able to get the 1ms time using internal hardware wake-up unit but that did not followed your architecture. |
Are there any problems with the lp ticker tests? If with this 2ms min resolution, it passes or ? The implementation looks fine to me, please rebase to resolve conflicts |
Hi @0xc0170, One more thing that I'd like to add. There are two cases that I would like to cover here:
|
What are the limitation of the |
mbed sleep = stm32 sleep mode --> wakeup by any interrupt A solution would be to use stm32 standby mode instead for the deepsleep... this has to be checked because I don't remember why it was not done originally. |
The RTC is connected to an EXTI input internally. See also: https://developer.mbed.org/users/Sissors/code/WakeUp/file/49ca85e8822f/Device/WakeUp_STM_RTC.cpp. There I use the RTC alarm interrupt to wake it up from deepsleep, works fine. |
@@ -0,0 +1,66 @@ | |||
#include "device.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add a copyright header as other files have, thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. Thanks
Looks fine to me, just that one file without the copyright header. |
Change-Id: I3eb37aa7e35df901b7d3cd00069638425fb3fdc6
Change-Id: Id23b9d3a0f9a9a3c8a8501a4ba8de6256bc591dd
ok good news 😄 |
…..ccd30a3 ccd30a3 Merge branch 'release_internal' into release_external a9d7c1b Use BSD3 license for Thread files (ARMmbed#1898) 2b1d298 Link request retransmission delay changed (ARMmbed#1895) 06bd60a Remove ws resources from Nanostack ad8577d Remove new test files 4453f82 Merge branch 'release_internal' into release_external acbf1ac Add missing function macros (ARMmbed#1897) dae82f6 implemented wisun routing cost calculation f919fd1 Fix warning found by PVS-studio (ARMmbed#1891) 399f02f Additional time for distribution of dataset added (ARMmbed#1892) dde9e61 Reverted commit ARMmbed#1888 and fixed thread_bbr_dua_entry_find (ARMmbed#1893) 628fa27 Merge pull request ARMmbed#1885 from ARMmbed/IOTTHD-2752 cfea7b2 BBR route for added with preference. Route info updated. (ARMmbed#1888) dc404c4 Fix issues found by coverity (ARMmbed#1889) c81e59c Fixes for Wi-SUN bbr behaviour c941fe6 Adjust COAP callback return values (ARMmbed#1886) 7ef4775 Fix for multicast ping forwarding before adding MPL header(ARMmbed#1883) 766e305 FHSS: fixed missing us convert ef38363 FHSS: Traces in set parent 296e455 FHSS: Time unit defines added 724696c FHSS: changed traces to use timestamp from MAC 3deb08c FHSS: use divider function in ufsi calculation 74c7f37 FHSS: function to check if remaining slots is negative 654dd44 Merge pull request ARMmbed#1879 from ARMmbed/IOTTHD-2752 1ef5062 Address registration fix (ARMmbed#1882) 4c74f96 FHSS unit tests: Fixed tr51 tests 4cf7fdf FHSS: fixed tr51 channel table size a1d8b3d FHSS unit tests: Fixed tr51 tests 7e622b3 FHSS: Allocate TR51 channel tables when FHSS enabled e7a8d45 link-local multicast group registration (ARMmbed#1880) d4c95f2 Clear COAP retransmissions in partition change (ARMmbed#1872) bf36b91 Added generation of mac address if not set 990f4f1 Merge pull request ARMmbed#1877 from ARMmbed/dhcpv6_server_fix 6cbe7c5 Fix wrong link type to correct one DHCPV6_DUID_HARDWARE_EUI64_TYPE -> DHCPV6_DUID_HARDWARE_EUI48_TYPE fd6c1c8 Merge pull request ARMmbed#1876 from ARMmbed/thread_dhcpv6_server_trace_fix 3f83bd1 Added trace about prefered timeout for fix CI test 4331ea1 added support for multicast forwarding 7327652 bbr start called after seq number updated. (ARMmbed#1875) 98be8b2 Merge pull request ARMmbed#1868 from ARMmbed/IOTTHD-2863 23296c1 Merge pull request ARMmbed#1871 from ARMmbed/ws_config_handler 2188fd2 FHSS: Fixed negative remaining time in ufsi calculation 5b70440 announce reattach fix (ARMmbed#1873) fc11a7a Merge pull request ARMmbed#1869 from ARMmbed/dhcpv6_server_update a156355 WS PAN config message handler update 5e45c40 Thread dhcpv6 server update fe9ba3b Wi-sun border router enable global prefix with DHCP address allocation. 6d2af0b Dhcpv6 server update ab1260a added possibility to set next sequence number on PBBR. (ARMmbed#1867) 6679db4 WS bootstrap: traces to hop calculation 1cc4aff Merge pull request ARMmbed#1865 from ARMmbed/dhcpv6_client_ws_integration c2d0e14 Enable wi-sun dhcp relay service. 70e56b1 Wi-sun DHCP client support and RPL prefix learn Callback 3389b46 Merge pull request ARMmbed#1866 from ARMmbed/dhcp_relay_fix 9aa6a95 Address registration changes for MED and SED (ARMmbed#1863) 16359eb Fix compile problem 1472b02 Removed duplcate line. 67ea075 Wi-SUN node init API change b906861 Fixed DHCP relay bugs bcffa5f FHSS: Fixed setting parent synch e0276f6 FHSS: Configure in critical state d74d5ff Merge pull request ARMmbed#1862 from ARMmbed/dhcp_client_generic_update 999bbc3 Copied memory fix from PR ARMmbed#1858 6500fcf DHCPv6 client Generic API for all stacks. 2ec9b6e Fix memory leak if dhcp renew send fails (ARMmbed#1858) cbf99e7 Merge pull request ARMmbed#1861 from ARMmbed/ws_dhcp_support 08155b1 DHCPv6 service relay support 62812ab Libdhcpv6 Relay support 0eea30d delay Join_ent.ntf sending by 50 ms (ARMmbed#1860) dac1d99 Merge pull request ARMmbed#1857 from ARMmbed/mac_enhanced_ack b819fa8 Fix bbr start 514bb58 Merge pull request ARMmbed#1836 from ARMmbed/IOTTHD-2828 b074d0e Merge pull request ARMmbed#1845 from ARMmbed/IOTTHD-2839 20b5e57 Enhanced ACK tx fix caf53d1 Merge pull request ARMmbed#1846 from ARMmbed/IOTTHD-2824 9b5e1c9 added payload length for Max child timeout tlv (ARMmbed#1856) 3c1864b address registration tlv check only for MTDs (ARMmbed#1855) 942d8e7 Diagnostic TLV added (ARMmbed#1854) f2b38cf Check for mandatory Address registration tlv (ARMmbed#1853) ce8d5b7 Valdations for Child update response added: (ARMmbed#1852) e373545 Added Wi-SUN border router implementation 1f7c040 Merge pull request ARMmbed#1849 from ARMmbed/mac_asynch_fix 33afc9c FHSS: Added force synch boolean in parent set 5ddf5fa FHSS: prevent unicast on broadcast channel in tx handle f17e6cd FHSS: Check TX/RX slot in tx handle 3082407 FHSS: implemented divide function cebdaf4 Update stoip6 prototype to tests (ARMmbed#1851) 279c708 Trig a new back off period for pending TX if ACK tx is active f1e7f06 Fix broken unit test. 1d8e3d7 MAC Asynch Data request update cca9879 Merge pull request ARMmbed#1848 from ARMmbed/iotthd-2788 fe84585 Merge pull request ARMmbed#1847 from ARMmbed/eAck_mac_timer_fix c1c5926 Dynamic parent selection delay based on trickle i_min. 68bad00 MAC: Stop active MAC timer before sending enhanced Ack 4a204bd MAC: set new MAC channel only if RF returns success 9d79ca9 FHSS: Added minimum synch interval a35b702 FHSS: Increased min random of tx poll db6dc6b MAC: Fixed enhanced ack TX time 5836b50 Merge pull request ARMmbed#1844 from ARMmbed/fix_ack_tx_fail_handling d9e2ea6 MAC: Fixed handling of the failed Ack transmission f43e285 Merge pull request ARMmbed#1843 from ARMmbed/address_reg_fix 0b4aa78 Parent Broadcast synch fix and TR51CF slot define fix d6b4111 fix for valgrind reported error. (ARMmbed#1842) 8160d86 Added support for wisun multicast 1f4625e Call ws_secondary_parent_update inside primary set for reduce code size. 35b39f4 Merge pull request ARMmbed#1840 from ARMmbed/address_register cfb2426 bbr memory leak during keep alive fixed. (ARMmbed#1839) a8aafe4 Stub update c244ad8 Enable 6-bit path control for give better compare between parent's. eac63d2 FHSS and address registration update c14343a valgrind and coverity reported errors fixed. (ARMmbed#1838) 9b14b83 additional thread prefixes in network data (ARMmbed#1833) fb07086 Merge pull request ARMmbed#1837 from ARMmbed/llc_parent_synch bf55180 Fixed failing unit test. 5e7a493 Update brodcast synch when here data from primary parent. 9e22831 Merge pull request ARMmbed#1834 from ARMmbed/enable_bt_ie_ulad 02af1a8 Thread extension commission updates (ARMmbed#1835) dd082a0 Fix ws_llc_data_send unit test validation with new bt-ie lement length. ae6554d Revert "Disable wi-sun features temporary". 927c329 Thread extension commissioning updates (ARMmbed#1828) 160ef0a Merge pull request ARMmbed#1829 from ARMmbed/IOTTHD-2821 576f2bf FHSS unit tests: Fixed channel function variable name f33d163 WS: Removed backward compatibility defines 9c88a7f WS: fixed overwriting fixed channel with random efd77f1 Clean thread_routing test stub (ARMmbed#1832) 2b8a011 Remove recursion from MAC layer ARMmbed#2 (ARMmbed#1830) 2f5a2ce Remove recursion from MAC layer (ARMmbed#1826) 06e3243 propagation of reserved bit in network data implemented. (ARMmbed#1827) e7fa605 Merge pull request ARMmbed#1823 from ARMmbed/IOTTHD-2782 89001d1 Merge pull request ARMmbed#1825 from ARMmbed/IOTTHD-2816 9c78a95 MAC: Static CSMA period when using FHSS 3d1c8a0 FHSS: Stop unicast schedule when fixed channel or no dwell interval d6086d0 Merge pull request ARMmbed#1818 from ARMmbed/nud_statemachine a2b8491 Wi-sun Border router and NUD process updates 60e1545 Disable wi-sun features temporary 7e3c16c Wi-sun LLC Data request IE update a27076f Fixed Pan informatio IE read bug bb1aeac Fixed Fragmentation init failure problem. 02fce65 Parent select and pan config handler update a2ef56a wi-sun update: ca9fd4f Disabled Wi-sun border router version number update. 231daf7 Wi-sun NUD State Machine update e7d551c Commissioner fixes (ARMmbed#1824) 62ffba3 keepalive for on mesh commissioner sent to leader aloc. (ARMmbed#1821) f846823 Coverity reported error fixes: (ARMmbed#1822) 708e8d3 Merge pull request ARMmbed#1820 from ARMmbed/IOTTHD-2735 b2e7efc FHSS WS: Get MAC channel from FHSS when starting RF interface fe2b448 Merge pull request ARMmbed#1819 from ARMmbed/fixed_bad_channel 7c13c3c commissioner updates. (ARMmbed#1812) 4c7d4f2 FHSS: Fixed bad channel check with fixed channel configuration 40b2eec Set global address flag to follow address state b46eacc updated channel plan settings 4a1d595 Merge pull request ARMmbed#1815 from ARMmbed/iotthd-2745 5a37354 Primary Parent Update Hook to Wi-sun for synch broadcast schedule. 98b0e23 Fix memory leak when advertising route (ARMmbed#1814) b5d276d refactored trickkle running checks 61ff793 Merge pull request ARMmbed#1807 from ARMmbed/rpl_parent_candidate a7a1ab3 Updated to NUD probability from 10% to 1%. 89b8eeb Merge pull request ARMmbed#1810 from ARMmbed/IOTTHD-2734 b99d497 Modify NUD operation propability. 4bb8b54 Wi-sun Probe update 2183869 FHSS Ack tx done fix fb4309d Mac Asynch and Ack validation update 2695601 FHSS parent synch fix. b50abb0 RPL, FHSS and Wisun Update a40e012 Check MAC status when purging indirect queue (ARMmbed#1811) b68f394 WS bootstrap: Updated channel function set apis 42b2e7c Unit tests: channel function tests updated b6236f9 WS bootstrap: Separated unicast and broadcast channel functions 6fe5ea5 Fix Thread DHCPv6-client memory leak (ARMmbed#1808) bbc0d77 WS bootstrap: renamed channel_function to uc_channel_function 7dbad5e Parent sends full network data in response to data request (ARMmbed#1806) cbe45b4 Merge pull request ARMmbed#1805 from ARMmbed/IOTTHD-2733 8956418 FHSS unit tests: Fixed broadcast handler tests e7aa893 FHSS: Define to make outdated application work 9fd804b FHSS: Separated broadcast schedule channel function 327c310 Merge pull request ARMmbed#1804 from ARMmbed/fhss_ws_cs e7ae8ce FHSS unit tests: Fixed missing platform stub 9cbd2b7 FHSS: added critical states 51f8328 Merge pull request ARMmbed#1803 from ARMmbed/IOTTHD-2736 537b60d FHSS unit tests: Fixed missing stub 43bc93d FHSS: Poll TX queue on every TX slot c6e2457 Merge pull request ARMmbed#1802 from ARMmbed/asynch_channel_plan_filter c851b07 Wi-sun bootstrap verify channel plan component against own configured ones. 1bdc4e6 Merge pull request ARMmbed#1800 from ARMmbed/IOTTHD-2504 6ed53e6 FHSS unit tests: Fixed timestamp stub return value f43b3af FHSS unit tests: Fixed missing timestamp read function f27a29c Merge pull request ARMmbed#1801 from ARMmbed/rf_driver_start_fix c2bc561 Add MAC TX active FLAG to active before write function return value. 08d3e12 Merge pull request ARMmbed#1799 from ARMmbed/several_bug_fixs 65d96c4 FHSS: Fixed calculating UFSI eedd746 FHSS: Compensate delay from platform driver when starting timeout 7d537ea FHSS: Read timestamp from MAC/PHY instead of using FHSS own timestamp 0206fc8 FHSS: Added callbacks for debugging purposes 63d8a41 Added Packet rebuild for extented driver after Driver Busy error. 607da3e Bug fixes: f39312b REED and FED links removed (ARMmbed#1796) b162d7b added support for modifying fhss configuration after initial startup 88e239d Merge pull request ARMmbed#1798 from ARMmbed/enhanced_ack_send 11fb5fa MAC Enhanced ACK TX fix: 08d5584 Merge pull request ARMmbed#1794 from ARMmbed/rpl_address_learn 5bbc86f fed advertisement fix (ARMmbed#1795) a48254c Wi-sun Address registration update: 5db8037 RPL Local Repair, SLAAC prefix update and Dodag Prefix proces update: b3139c8 Adjust Thread BBR neighbor/destination cache size (ARMmbed#1793) 21deb75 Registered neighbour cache entries are not reregistered. (ARMmbed#1792) d93b9e4 Added empty function for ws public api 1a09af7 Updated management api f52289f Merge pull request ARMmbed#1790 from ARMmbed/ws_llc_neigh_update_fix b954e56 WS neighbor refresh update 0b2736f Thread address registration improvements (ARMmbed#1779) 931a17d Merge pull request ARMmbed#1789 from ARMmbed/iotthd-2693 90c6a8a Removed unnecessary Decrypt Fail debug trace. b425f4b Adapatation neighbor validation update: 06255ee Merge pull request ARMmbed#1787 from ARMmbed/iottthd-2692 e98c182 MAC report unknow neighbour COMM status at Packet TX process not detetct destination. be0aa9c Merge pull request ARMmbed#1786 from ARMmbed/iotthd-2695 42122b7 Added support to report Driver if FHSS return unknow neighbor error. eb5ba30 Fixed Driver Tx done callback missing error return values. 1a9acbd Wi-SUN fhss refactor 0ca78d6 Merge pull request ARMmbed#1784 from ARMmbed/iotthd-2533 9b37c24 Fixed Unicast and Broadcast MAC packet request types. 0ddff57 Fix PAN-id read bug when received 2015 frame version's. git-subtree-dir: features/nanostack/sal-stack-nanostack git-subtree-split: ccd30a3
LowPowerTicker for STM32F0xx family is implemented using the RTC periodic unit
functionality. For more informations please follow this document:
Supported platforms: