tinyvision-ai-inc / pico-ice

Raspberry Pi PICO board + Lattice iCE40 FPGA's
MIT License
142 stars 26 forks source link

10ms/byte delay when dealing with ACM1 #42

Closed MrJake222 closed 4 months ago

MrJake222 commented 4 months ago

moved from pico-ice-sdk

Hi,

I'm sending/receiving 2-byte frames to/from iCE40 via ACM1 virtual serial port. The serial.read function always stalls for 20ms. I think it's related to the SDK (not Python or kernel) because ACM0 doesn't have this delay.

image

Resolution

Turns out waiting for user input in main loop is not the best strategy. https://github.com/tinyvision-ai-inc/pico-ice/blob/f9bd6e648ee60ef808dcea329a99da570e69a52e/Firmware/pico-ice-default/main.c#L58-L62 That's not how this works. getchar_timeout_us calls stdio_get_until which waits internally!

josuah commented 4 months ago

Thank you, great insight about stdio_get_until busy looping in the "driver"/"hal"/"sdk" code!