{"action":"created","issue":{"url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/issues/1478","repository_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware","labels_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/issues/1478/labels{/name}","comments_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/issues/1478/comments","events_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/issues/1478/events","html_url":"https://github.com/nodemcu/nodemcu-firmware/issues/1478","id":173609894,"number":1478,"title":"gpio.trig interrupt cb slow to start executing, have ~1300us overhead","user":{"login":"danlu01","id":11370993,"avatar_url":"https://avatars.githubusercontent.com/u/11370993?v=3","gravatar_id":"","url":"https://api.github.com/users/danlu01","html_url":"https://github.com/danlu01","followers_url":"https://api.github.com/users/danlu01/followers","following_url":"https://api.github.com/users/danlu01/following{/other_user}","gists_url":"https://api.github.com/users/danlu01/gists{/gist_id}","starred_url":"https://api.github.com/users/danlu01/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danlu01/subscriptions","organizations_url":"https://api.github.com/users/danlu01/orgs","repos_url":"https://api.github.com/users/danlu01/repos","events_url":"https://api.github.com/users/danlu01/events{/privacy}","received_events_url":"https://api.github.com/users/danlu01/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-08-27T18:49:30Z","updated_at":"2016-08-29T11:16:56Z","closed_at":null,"body":"### Expected behavior\r\nFrom interrupt pin edge detection to executing the callback function should not exceed 200us.  Using arduino mega to send a high pulse of 500us follow by a low pulse of 500us, expect to detect pulse width of ~500us.\r\n\r\n### Actual behavior\r\nOnce an interrupt pin edge is detected, gpio.trig interrupt callback takes too long before start executing CB function.  It takes about ~1300us before it start executing the CB function.  Any pulse width less than 1300us is reported as 1300us.  Even with pulse width of 1us, ESP8266 can detect it but takes too long excuting CB function.\r\n\r\n### Test code\r\nBelow code uses pin 1 (GPIO5) to detect raising and falling edge and report the duration of the high and low pulse.\r\n```Lua\r\n  node.setcpufreq(node.CPU160MHZ)\r\n\r\n  pin=1\r\n  pulse1 = tmr.now()\r\n  function pin1cb(level)\r\n    pulse2 = tmr.now()\r\n    print( level, pulse2 - pulse1 )\r\n    pulse1 = pulse2\r\n    gpio.trig(pin, \"both\")\r\n  end\r\n  gpio.trig(pin, \"down\", pin1cb)\r\n```\r\n### NodeMCU version\r\nNodeMCU version 1.5.4.1\r\n\r\n### Hardware\r\nESP8266-ESP12 and use arduino mega to send square waves to ESP8266 GPIO5.\r\n\r\nArduino code:\r\n```\r\nvoid setup() {\r\n  // put your setup code here, to run once:\r\n  pinMode(10, OUTPUT);\r\n  pinMode(11, OUTPUT);\r\n  digitalWrite(10,LOW);\r\n  digitalWrite(11,LOW);\r\n}\r\nvoid loop() {\r\n  // put your main code here, to run repeatedly:\r\n  digitalWrite(10,HIGH);\r\n  digitalWrite(11,HIGH);\r\n  delayMicroseconds(500);\r\n  digitalWrite(10,LOW);\r\n  digitalWrite(11,LOW);\r\n  delayMicroseconds(500);\r\n}\r\n```\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/issues/comments/243097105","html_url":"https://github.com/nodemcu/nodemcu-firmware/issues/1478#issuecomment-243097105","issue_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/issues/1478","id":243097105,"user":{"login":"marcelstoer","id":624195,"avatar_url":"https://avatars.githubusercontent.com/u/624195?v=3","gravatar_id":"","url":"https://api.github.com/users/marcelstoer","html_url":"https://github.com/marcelstoer","followers_url":"https://api.github.com/users/marcelstoer/followers","following_url":"https://api.github.com/users/marcelstoer/following{/other_user}","gists_url":"https://api.github.com/users/marcelstoer/gists{/gist_id}","starred_url":"https://api.github.com/users/marcelstoer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcelstoer/subscriptions","organizations_url":"https://api.github.com/users/marcelstoer/orgs","repos_url":"https://api.github.com/users/marcelstoer/repos","events_url":"https://api.github.com/users/marcelstoer/events{/privacy}","received_events_url":"https://api.github.com/users/marcelstoer/received_events","type":"User","site_admin":false},"created_at":"2016-08-29T11:16:56Z","updated_at":"2016-08-29T11:16:56Z","body":"> At any rate, I think it would be valuable to have a `gpio.pulsein` function.\r\n\r\nConsider what's been discussed and implemented in #1017 before you go ahead."}}
{"actor":{"display_login":"marcelstoer"}}