{"action":"created","issue":{"url":"https://api.github.com/repos/RIOT-OS/RIOT/issues/5237","repository_url":"https://api.github.com/repos/RIOT-OS/RIOT","labels_url":"https://api.github.com/repos/RIOT-OS/RIOT/issues/5237/labels{/name}","comments_url":"https://api.github.com/repos/RIOT-OS/RIOT/issues/5237/comments","events_url":"https://api.github.com/repos/RIOT-OS/RIOT/issues/5237/events","html_url":"https://github.com/RIOT-OS/RIOT/issues/5237","id":145527063,"number":5237,"title":"xtimer with any value clock frequency","user":{"login":"attdona","id":943963,"avatar_url":"https://avatars.githubusercontent.com/u/943963?v=3","gravatar_id":"","url":"https://api.github.com/users/attdona","html_url":"https://github.com/attdona","followers_url":"https://api.github.com/users/attdona/followers","following_url":"https://api.github.com/users/attdona/following{/other_user}","gists_url":"https://api.github.com/users/attdona/gists{/gist_id}","starred_url":"https://api.github.com/users/attdona/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/attdona/subscriptions","organizations_url":"https://api.github.com/users/attdona/orgs","repos_url":"https://api.github.com/users/attdona/repos","events_url":"https://api.github.com/users/attdona/events{/privacy}","received_events_url":"https://api.github.com/users/attdona/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/RIOT-OS/RIOT/labels/timer","name":"timer","color":"a00070"},{"url":"https://api.github.com/repos/RIOT-OS/RIOT/labels/TimerTaskForce","name":"TimerTaskForce","color":"f0c0ff"}],"state":"open","locked":false,"assignee":{"login":"kaspar030","id":4679640,"avatar_url":"https://avatars.githubusercontent.com/u/4679640?v=3","gravatar_id":"","url":"https://api.github.com/users/kaspar030","html_url":"https://github.com/kaspar030","followers_url":"https://api.github.com/users/kaspar030/followers","following_url":"https://api.github.com/users/kaspar030/following{/other_user}","gists_url":"https://api.github.com/users/kaspar030/gists{/gist_id}","starred_url":"https://api.github.com/users/kaspar030/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kaspar030/subscriptions","organizations_url":"https://api.github.com/users/kaspar030/orgs","repos_url":"https://api.github.com/users/kaspar030/repos","events_url":"https://api.github.com/users/kaspar030/events{/privacy}","received_events_url":"https://api.github.com/users/kaspar030/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/RIOT-OS/RIOT/milestones/14","html_url":"https://github.com/RIOT-OS/RIOT/milestones/Release%202016.07","labels_url":"https://api.github.com/repos/RIOT-OS/RIOT/milestones/14/labels","id":1657251,"number":14,"title":"Release 2016.07","description":"","creator":{"login":"authmillenon","id":675644,"avatar_url":"https://avatars.githubusercontent.com/u/675644?v=3","gravatar_id":"","url":"https://api.github.com/users/authmillenon","html_url":"https://github.com/authmillenon","followers_url":"https://api.github.com/users/authmillenon/followers","following_url":"https://api.github.com/users/authmillenon/following{/other_user}","gists_url":"https://api.github.com/users/authmillenon/gists{/gist_id}","starred_url":"https://api.github.com/users/authmillenon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/authmillenon/subscriptions","organizations_url":"https://api.github.com/users/authmillenon/orgs","repos_url":"https://api.github.com/users/authmillenon/repos","events_url":"https://api.github.com/users/authmillenon/events{/privacy}","received_events_url":"https://api.github.com/users/authmillenon/received_events","type":"User","site_admin":false},"open_issues":159,"closed_issues":2,"state":"open","created_at":"2016-03-21T13:28:08Z","updated_at":"2016-04-03T19:31:52Z","due_on":"2016-07-14T22:00:00Z","closed_at":null},"comments":2,"created_at":"2016-04-03T18:41:33Z","updated_at":"2016-04-04T07:05:09Z","closed_at":null,"body":"The xtimer module needs some patching for the (rare) case where frequency of the timer peripheral are not a natural one (1 usec) or a power of two of this frequency.\r\n\r\nThe real case is for example the fixed 80 Mhz frequency of cc3200 [1] timer module.\r\n\r\nBelow what works for this chip, at least with my preliminary tests, hoping this may help to find a rigorous patch that works for every system.\r\n\r\n## MACRO for scaling ##\r\nRedefined and moved the macros XTIMER_USEC_TO_TICKS and XTIMER_TICKS_TO_USEC \r\ninto a specific header (boards/cc3200-launchxl/include/periph_conf.h:\r\n\r\n    #define XTIMER_SHIFT 1\r\n    #define XTIMER_USEC_TO_TICKS_FACTOR 80\r\n\r\n    #define XTIMER_USEC_TO_TICKS(value) ( value*XTIMER_USEC_TO_TICKS_FACTOR )\r\n    #define XTIMER_TICKS_TO_USEC(value) ( value/XTIMER_USEC_TO_TICKS_FACTOR )\r\n\r\n## Syncronize wrapping of natural and hw counter ##\r\nAligned the wrap of natural counter (1 usec based) with the wrapping of the system timer (1/80 usec based)\r\n\r\n    #ifdef XTIMER_SHIFT\r\n      timer->target = (target - XTIMER_OVERHEAD)%(0xffffffff/XTIMER_USEC_TO_TICKS_FACTOR);\r\n    #else\r\n      timer->target = target - XTIMER_OVERHEAD;  //!!! to improve timer precision\r\n     //timer->target = target;  //!!! this is RIOT original\r\n    #endif\r\n\r\nThe only place where I did this is into xtimer_core.c/_xtimer_set_absolute function. I think some reviewing by the timer task force has to be done to confirm that this is correct.\r\n\r\nAs another minor consideration, not related to this issue, please see the //!!! comments for a suggested patch to improve the precision of timers as it comes out for my measures.\r\n\r\n[1] http://www.ti.com/product/CC3200\r\n"},"comment":{"url":"https://api.github.com/repos/RIOT-OS/RIOT/issues/comments/205166282","html_url":"https://github.com/RIOT-OS/RIOT/issues/5237#issuecomment-205166282","issue_url":"https://api.github.com/repos/RIOT-OS/RIOT/issues/5237","id":205166282,"user":{"login":"attdona","id":943963,"avatar_url":"https://avatars.githubusercontent.com/u/943963?v=3","gravatar_id":"","url":"https://api.github.com/users/attdona","html_url":"https://github.com/attdona","followers_url":"https://api.github.com/users/attdona/followers","following_url":"https://api.github.com/users/attdona/following{/other_user}","gists_url":"https://api.github.com/users/attdona/gists{/gist_id}","starred_url":"https://api.github.com/users/attdona/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/attdona/subscriptions","organizations_url":"https://api.github.com/users/attdona/orgs","repos_url":"https://api.github.com/users/attdona/repos","events_url":"https://api.github.com/users/attdona/events{/privacy}","received_events_url":"https://api.github.com/users/attdona/received_events","type":"User","site_admin":false},"created_at":"2016-04-04T07:05:09Z","updated_at":"2016-04-04T07:05:09Z","body":"Just checked #3990 and it fits.\r\n\r\nI don't know the maturity status of this PR, it is a major \"rewriting\": when ready I can test it against cc3200 board."}}