{"action":"created","issue":{"url":"https://api.github.com/repos/micropython/micropython/issues/1555","labels_url":"https://api.github.com/repos/micropython/micropython/issues/1555/labels{/name}","comments_url":"https://api.github.com/repos/micropython/micropython/issues/1555/comments","events_url":"https://api.github.com/repos/micropython/micropython/issues/1555/events","html_url":"https://github.com/micropython/micropython/issues/1555","id":114213316,"number":1555,"title":"stmhal: uart chars are being dropped, even when only at 115200 baud","user":{"login":"dhylands","id":127500,"avatar_url":"https://avatars.githubusercontent.com/u/127500?v=3","gravatar_id":"","url":"https://api.github.com/users/dhylands","html_url":"https://github.com/dhylands","followers_url":"https://api.github.com/users/dhylands/followers","following_url":"https://api.github.com/users/dhylands/following{/other_user}","gists_url":"https://api.github.com/users/dhylands/gists{/gist_id}","starred_url":"https://api.github.com/users/dhylands/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dhylands/subscriptions","organizations_url":"https://api.github.com/users/dhylands/orgs","repos_url":"https://api.github.com/users/dhylands/repos","events_url":"https://api.github.com/users/dhylands/events{/privacy}","received_events_url":"https://api.github.com/users/dhylands/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":26,"created_at":"2015-10-30T06:48:53Z","updated_at":"2015-11-17T00:48:34Z","closed_at":null,"body":"If I try to copy a file to the pyboard over a UART using rshell, then characters get dropped.\r\n\r\nFor this test, boot.py contains:\r\n```\r\nimport pyb\r\npyb.usb_mode(None)\r\nuart = pyb.UART(6, 115200, timeout_char=200, read_buf_len=600)\r\npyb.repl_uart(uart)\r\n```\r\nI brought a GPIO high at the beginning of USART6_IRQHandler and low at the end. Channel 0 is the data arriving on the UART pin, and Channel 1 is the UART IRQ.\r\n\r\nLogic Analyzer Capture: https://www.dropbox.com/s/6mj5kr8sn6ad81j/UART_irq.png?dl=0\r\n\r\nThe UART IRQs are spaced approx 86 usec or so apart (sometimes a bit more) 115200 full tilt would be 86.8 usec per character.\r\n\r\nThe first gap corresponds to the place in the buffer where the first dropped character occurs. The first gap is 847 usec long and the second gap is 694 usec long.\r\n\r\nSo this tells me that either interrupts are being disabled for these periods or a higher priority interrupt is occurring. I'll add some more instrumentation to see if I can figure out what might be happening.\r\n\r\nI also found it interesting that even though there are timeouts set on the uart, the call to sys.stdin.buffer.readinto() never times out."},"comment":{"url":"https://api.github.com/repos/micropython/micropython/issues/comments/157223007","html_url":"https://github.com/micropython/micropython/issues/1555#issuecomment-157223007","issue_url":"https://api.github.com/repos/micropython/micropython/issues/1555","id":157223007,"user":{"login":"dpgeorge","id":6187689,"avatar_url":"https://avatars.githubusercontent.com/u/6187689?v=3","gravatar_id":"","url":"https://api.github.com/users/dpgeorge","html_url":"https://github.com/dpgeorge","followers_url":"https://api.github.com/users/dpgeorge/followers","following_url":"https://api.github.com/users/dpgeorge/following{/other_user}","gists_url":"https://api.github.com/users/dpgeorge/gists{/gist_id}","starred_url":"https://api.github.com/users/dpgeorge/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dpgeorge/subscriptions","organizations_url":"https://api.github.com/users/dpgeorge/orgs","repos_url":"https://api.github.com/users/dpgeorge/repos","events_url":"https://api.github.com/users/dpgeorge/events{/privacy}","received_events_url":"https://api.github.com/users/dpgeorge/received_events","type":"User","site_admin":false},"created_at":"2015-11-17T00:48:34Z","updated_at":"2015-11-17T00:48:34Z","body":"Soft ISRs would be a good (temporary?) solution to the \"I want to allocate on the heap during an interrupt\" problem.  We could add an option to the callback/irq setup function to indicate soft/hard interrupt.  Eg, `Timer(1, freq=10).callback(f, soft=True)` would trigger the soft ISR on the hardware interrupt, and the soft ISR would be serviced at some time later by the VM."}}