element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Raspberry Pi Projects
  • Products
  • Raspberry Pi
  • Raspberry Pi Projects
  • More
  • Cancel
Raspberry Pi Projects
Blog help: how do I use the Pico USB as COM port, with support for RX interrupt?
  • Blog
  • Documents
  • Events
  • Polls
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Raspberry Pi Projects to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Jan Cumps
  • Date Created: 19 Oct 2022 11:56 AM Date Created
  • Views 9499 views
  • Likes 11 likes
  • Comments 10 comments
  • pico
Related
Recommended

help: how do I use the Pico USB as COM port, with support for RX interrupt?

Jan Cumps
Jan Cumps
19 Oct 2022

I know how to use plain UART on the Pico, with receive interrupt. See advanced_uart.c.

I also know how to make the UART show and work as a COM device. See hello_usb makefile.

I'm looking for help on the following: use the USB as a COM, and have support for incoming traffic (RX) interrupts.
Have you done that, or do you know how to do that? Please share.

I've made a test bed. It's the uart_advanced pico-example. I just copied it, and made changes to the build file.
This will allow that it's compiled, wherever the SDK sits. As long as you set this environment variable: PICO_SDK_PATH to your SDK location. For me: C:\Users\jancu\Documents\Pico\pico-sdk
Also contains a pico-probe config.

uart_advanced.zip

To switch to USB, uncomment the two last lines in the CMake file.

# enable usb output, disable uart output
# pico_enable_stdio_usb(uart_advanced_usb 1)
# pico_enable_stdio_uart(uart_advanced_usb 0)
  • Sign in to reply

Top Comments

  • Jan Cumps
    Jan Cumps over 3 years ago +1
    Oki: It registers an exclusive service handler. If I try to and add a shared interrupt handler, I get an assert.
  • Jan Cumps
    Jan Cumps over 3 years ago

    current status: a compromise:

    • If the UART library is linked (#if LIB_PICO_STDIO_UART), I make my code use the interrupt version.
    • If the USB library is linked (#if LIB_PICO_STDIO_USB), I make my code use a polling task (check character, no wait if none available), and then a 50 ms yield for other processes.

    It's not what I'm looking for. I may be able to make an interrupt driven USB serial device project. But what I learned today, is that there's no short path for that. I need to learn the low level USB APIs.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • baldengineer
    baldengineer over 3 years ago in reply to Jan Cumps

    Good find.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 3 years ago

    Oki:

    image

    It registers an exclusive service handler. If I try to and add a shared interrupt handler, I get an assert.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 3 years ago in reply to shabaz

    It was a long shot :). 

    It is bound to not work, because the USB data lines aren't connected to UART0. They are connected to the USB data pins of the RP2040. The physical uart0 peripheral is connected to pins 0 and 1.


    The stdio usb wrapper just simulates it is uart0, so that programs using stdio read/write API don't see difference. For lower level use, with interrupts, the stdio mapping doesn't work.

    You can enable both in the makefile though. But the trigger only fires if I simulate traffic on pin 1. Not on the USB port.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 3 years ago in reply to shabaz

    I will try it. Meanwhile I've created a test bed, bare metal.

    It's the uart_advanced project from the pico-examples, that I stripped down to just do the receive.
    And the make file adapted to make switching between uart and usb easy.

    Only requires that the environment variable PICO_SDK_PATH is set to the SDK (in my case: C:\Users\jancu\Documents\Pico\pico-sdk), no other dependencies.
    You can set that in the OS, in your startup scripts, or in VSCode, in the User setting CMake:environment

    I'll zip it to the main post

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2026 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube