Nordic nRF5 SDK 学习笔记之十二, nRF52840 Dongle USB CDC ACM 虚拟串口功能测试

本文介绍如何使用 nRF52840 SDK 的 USBCDCACM 模块创建虚拟 COM 端口。通过连接 USB 线缆,设备在 Windows 或 Linux/Unix 主机上将显示为 COMx 或 /dev/ttyACMx 设备。文中详细解释了 LED 和按钮的功能,并提供了 Windows 7 下的驱动安装步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

样例: ~\nRF5_SDK_15.2\examples\peripheral\usbd_cdc_acm\pca10056\blank\arm5_no_packs


1. 更改编译硬件, 从 pca10056 (nRF52840 DK) 改为 pca10059 ( nRF52840 Dongle).


2. 因 pca10059.h 中没有 TX_PIN_NUMBER,RX_PIN_NUMBER 定义,故新添加定义;


NORDIC USB CDC ACM 样例参考原文:

USB CDC ACM Example

This information applies to the nRF52840 SoC only.

This example uses the USB CDC ACM module. See the documentation of this module for links to relevant specification documents.

This example shows how to use the CDC ACM USB class, commonly known as Virtual COM port. After connecting the USB cable, the development kit will enumerate as a COMx port on Windows hosts or as a /dev/ttyACMx device on Linux/Unix hosts. The port can be opened and closed just like a traditional serial port.

Windows 8 (and later) hosts will pick the correct driver (usbser.sys) automatically.

Setup

You can find the source code and the project file of the example in the following folder: <InstallFolder>\examples\peripheral\usbd_cdc_acm

LED assignments:

  • LED 1 shows the USB bus state:
    • ON: State RESUME
    • OFF: State SUSPEND
  • LED 2 shows the CDC ACM port state:
    • ON: Port opened
    • OFF: Port closed
  • LED 3 shows the CDC ACM RX notification:
    • TOGGLE: Data received
  • LED 4 shows the CDC ACM TX notification:
    • TOGGLE: Data transmitted

Button assignments:

  • Button 1 sends a CDC ACM test frame.
  • Button 2 sends a CDC ACM line notification.

Testing

Test the USB CDC ACM Example application by performing the following steps:

  1. Compile and program the application.
  2. Connect the development kit to the host computer.
  3. If you are running Windows 7, on first run CDC ACM driver installation is needed. To install the driver on Windows 7, follow these steps:
    • Open Device Manager
    • Right-click the development kit (look for the name "nRF52 ..." depending on the example)
    • Click "Update Driver Software..."
    • Click "Browse my computer for driver software"
    • Click "Browse..." and choose the folder sdk/nrf5/examples/usb_drivers
    • Click "Ok"
    • Click "Next"
    • Click "Install"
    • Click "Close"
  4. Open the serial port. In your computer's device manager, the development kit will be visible as "nRF52 USB CDC Demo (COMx)".
  5. Using a terminal emulator, for example PuTTY with the following Terminal settings, send test data from the host computer to the development kit. LED 3 will blink.
  6. Press Button 1. A test frame will be sent from the development kit. LED 4 state will change. If you are using a terminal emulator, you can see the transmitted data on it as well.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值