赞
踩
1 Pinout
BOOT0: PA9, VBUS
PA9: bootROM USART0_TX
PA10: bootROM USART0_RX
PA11: USB_FS_DM
PA12: USB_FS_DP
PB8: CAN0_RX
PB9: CAN0_TX
PB12: CAN1_RX
PB13: CAN1_TX
APB1: 60 MHz
Refer to 8.4.9 of GD32C10x_User_Manual_Rev1.3.pdf for CAN pinout remap.
2 Flash and SRAM Base Address
On-chip Flash base address: 0x0800_0000, 1 Kbyte page
On-chip RAM base address: 0x2000_0000
3 CAN bus transceiver
PHY: SIT1050T
CAN FD协议数据长度1~8,12,16,20,24,32,48,64,最大长度是64,但并不能是1~64之间的任意长度。
4 Keil5
4.1 Keil download
https://cloud.tencent.com/developer/article/1605195
4.2 Keil5 License Management
Keil5 File - License Management - Computer ID
Keil Generic Keygen - Fillin CID and Target - Generate
4.3 Lib
Longan-Labs / GD32_I2C_CAN_FIRMWARE
5 USB
5.1 gitee GD32C103_GCC
下载代码后,重命名Core/FreeRTOS到Core/freeRTOS,在根目录下新建文件夹build,进入build,执行cmake ..,然后执行make,会在根目录下生成out文件夹。
5.2 字符串描述符
USB字符串描述符使用的是小端UCS2码,因此是2个字节表示一个英文、数字或符号,在MCU代码中,一般使用uint16_t双字节类型定义一个数组,然后使用大括号{}赋值。例如'C'=0x43和'M'=0x4D这样的ASCII码,转换到2字节的uint16_t时高位自动填0。
5.3 Porting
GD32C103 USB SRAM配置的地址和端点实际访问的地址是不一样的。
https://www.gd32mcu.com/cn/download
usb_core_driver cdc_acm;
usbd_init(&cdc_acm, USB_CORE_ENUM_FS, &cdc_desc, &cdc_class);
usbd_isr(&cdc_acm);
USB FS needs 48 MHz, which comes from SYS clock.
TIM2 input frequency is 12 MHz, which comes from SYS clock. If we need 1ms delay, then set period to (12000 - 1), set period to (12 - 1) for 1us delay.
CANx input frequency is 60 MHz, which comes from APB1.
6 Abbreviations
ESP32-S2: IDF TinyUSB
Tq: CAN Time Quantum
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。