{"action":"created","issue":{"url":"https://api.github.com/repos/SuperHouse/esp-open-rtos/issues/72","labels_url":"https://api.github.com/repos/SuperHouse/esp-open-rtos/issues/72/labels{/name}","comments_url":"https://api.github.com/repos/SuperHouse/esp-open-rtos/issues/72/comments","events_url":"https://api.github.com/repos/SuperHouse/esp-open-rtos/issues/72/events","html_url":"https://github.com/SuperHouse/esp-open-rtos/pull/72","id":119205281,"number":72,"title":"[WIP] Basic PWM implementation","user":{"login":"gpascualg","id":1239061,"avatar_url":"https://avatars.githubusercontent.com/u/1239061?v=3","gravatar_id":"","url":"https://api.github.com/users/gpascualg","html_url":"https://github.com/gpascualg","followers_url":"https://api.github.com/users/gpascualg/followers","following_url":"https://api.github.com/users/gpascualg/following{/other_user}","gists_url":"https://api.github.com/users/gpascualg/gists{/gist_id}","starred_url":"https://api.github.com/users/gpascualg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gpascualg/subscriptions","organizations_url":"https://api.github.com/users/gpascualg/orgs","repos_url":"https://api.github.com/users/gpascualg/repos","events_url":"https://api.github.com/users/gpascualg/events{/privacy}","received_events_url":"https://api.github.com/users/gpascualg/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-11-27T14:33:35Z","updated_at":"2015-11-29T05:32:07Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/SuperHouse/esp-open-rtos/pulls/72","html_url":"https://github.com/SuperHouse/esp-open-rtos/pull/72","diff_url":"https://github.com/SuperHouse/esp-open-rtos/pull/72.diff","patch_url":"https://github.com/SuperHouse/esp-open-rtos/pull/72.patch"},"body":"*Please see https://github.com/SuperHouse/esp-open-rtos/pull/40 for previous talk.*\r\n\r\nAs per #37 I've tried a basic implementation of PWM.\r\n\r\nMight be wrong and might not be optimized, so please feel free to comment!\r\n\r\nExplanation:\r\n\r\nTimer FRC1 is used as the duty timer. An interruption is fired when the GPIO pin should be toggled.\r\nAlthought more than one GPIO might be specified, all of them will follow the same period and duty cicle, that's why I'm implementing (not done yet) the \"divider\".\r\n\r\nThat would allow a single pin to act slower, for instance, if period is 50us, having a divider of 2 for a specific pin would make it behave as if it was of 100us."},"comment":{"url":"https://api.github.com/repos/SuperHouse/esp-open-rtos/issues/comments/160373123","html_url":"https://github.com/SuperHouse/esp-open-rtos/pull/72#issuecomment-160373123","issue_url":"https://api.github.com/repos/SuperHouse/esp-open-rtos/issues/72","id":160373123,"user":{"login":"jcard0na","id":676181,"avatar_url":"https://avatars.githubusercontent.com/u/676181?v=3","gravatar_id":"","url":"https://api.github.com/users/jcard0na","html_url":"https://github.com/jcard0na","followers_url":"https://api.github.com/users/jcard0na/followers","following_url":"https://api.github.com/users/jcard0na/following{/other_user}","gists_url":"https://api.github.com/users/jcard0na/gists{/gist_id}","starred_url":"https://api.github.com/users/jcard0na/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jcard0na/subscriptions","organizations_url":"https://api.github.com/users/jcard0na/orgs","repos_url":"https://api.github.com/users/jcard0na/repos","events_url":"https://api.github.com/users/jcard0na/events{/privacy}","received_events_url":"https://api.github.com/users/jcard0na/received_events","type":"User","site_admin":false},"created_at":"2015-11-29T05:32:07Z","updated_at":"2015-11-29T05:32:07Z","body":"Testing looks good.\r\n\r\nYou can see here my test report: http://jcard0na.github.io/Testing-PWM-implementation-for-esp8266/\r\nFor convenience I copy here the list of issues:\r\n\r\n1. The library crashes when the duty cycle is set to 0 (pwm_set_duty(0)). It is probably a problem with the underlying timers, but I would suggest detecting that in the pwm_set_duty() function and just call pwm_stop().\r\n\r\n2. When setting the duty cycle to 100%, the output is not truly 100% (i.e. constant high) but rather 99.65% I would also suggest to detect that scenario in pwm_set_duty() and set the output to constant high.\r\n\r\n3. The library/target does not work at high frequencies. When setting the frequency to 50kHz the observed output is 40kHz.\r\n\r\n4. Every change of duty cycle resets the output to HIGH. This might introduce glitches in applications where the duty cycle changes frequently (e.g. audio)\r\n\r\nI also made a pull request with my example/test code.\r\n\r\nCheers,\r\n"}}