找回密码
 立即注册
查看: 2542|回复: 22

USB to 2 serial ports-STC8H tests, and bugs

[复制链接]
  • 打卡等级:初来乍到
  • 打卡总天数:4
  • 最近打卡:2025-05-01 06:58:22

5

主题

184

回帖

1333

积分

金牌会员

积分
1333
发表于 2023-5-8 14:10:26 | 显示全部楼层 |阅读模式
本帖最后由 jmg 于 2023-5-8 16:10 编辑

I have this board, and

one post here suggests this
assistant /USB-CDC is a serial port, it will add 10M/6M/5M/4M/3M/2.5M/2M/1.5M/1M bps serial port communication speed for everyone to choose

but it seems the actual soue code is doing this (from download uart.c)
  1. case 14400, 19200, 28800, 38400, 57600,115200,230400,460800,921600, SetMCLK(0); //主时钟 22.1184MHz
  2. case 1500000:            SetMCLK(2); //主时钟 30MHz
  3. elseif(baud < 1000000)
  4.    SetMCLK(1); //主时钟 24MHz
  5. else
  6.    SetMCLK(3); //主时钟 40MHz
复制代码



so I can measure 10M,5M,3.3333M,2.5N,2M,1.6667M,1.428571M etc (40M/(4*N) as the source code suggests - so far, as expected.

but when I try bursts of data, it fails above 256 characters ?

I can send files of 64,128 etc bytes ok, but sending 1024 bytes, sees only 256 emerge from the UART Pin, when checked with other hardware.

a) The code appears to be simply polling - is there a fixed version that can send correct data ?

b) There are also many stop bits, at 5Mbd is there a fixed faster version that sends expected 1 or 2 stop bits, without the wasted time ?





回复

使用道具 举报 送花

  • 打卡等级:以坛为家I
  • 打卡总天数:353
  • 最近打卡:2025-04-30 07:50:52

2

主题

31

回帖

1351

积分

金牌会员

积分
1351
发表于 2023-5-8 14:37:01 | 显示全部楼层
本帖最后由 D_Works 于 2023-5-8 15:08 编辑

I don't know your code, but I suggest you check this:
length of RxBuffer and TxBuffer

You can use a variable that is set to 0 every time it is received, with a baud rate time of+1 every other time.
When it is greater than a certain number, the reception is considered complete

回复 支持 反对

使用道具 举报 送花

  • 打卡等级:偶尔看看III
  • 打卡总天数:55
  • 最近打卡:2025-05-02 08:32:59

718

主题

1万

回帖

1万

积分

管理员

积分
15630
发表于 2023-5-8 14:59:14 | 显示全部楼层
STC8H8K64U,  USB-LIB  use xdata VERSION  ?

1.png

回复 支持 反对

使用道具 举报 送花

  • 打卡等级:初来乍到
  • 打卡总天数:1
  • 最近打卡:2024-05-09 11:28:38

5

主题

18

回帖

152

积分

注册会员

积分
152
发表于 2023-5-8 15:08:08 | 显示全部楼层
Hey Buddy, you can change the source code, 1024 bytes apart, send loop
by ninidog
回复 支持 反对

使用道具 举报 送花

  • 打卡等级:以坛为家II
  • 打卡总天数:424
  • 最近打卡:2025-05-02 14:37:11
已绑定手机

77

主题

4849

回帖

8382

积分

超级版主

DebugLab

积分
8382
发表于 2023-5-8 15:13:35 来自手机 | 显示全部楼层
If the MCU can only receive 256 bytes, you need to check that the receive buffer size is not overflowing.
DebugLab
回复 支持 反对

使用道具 举报 送花

  • 打卡等级:以坛为家II
  • 打卡总天数:424
  • 最近打卡:2025-05-02 14:37:11
已绑定手机

77

主题

4849

回帖

8382

积分

超级版主

DebugLab

积分
8382
发表于 2023-5-8 15:16:50 来自手机 | 显示全部楼层
If the buffer is insufficient, you can use XDATA area as the buffer for data receiving.
DebugLab
回复 支持 反对

使用道具 举报 送花

  • 打卡等级:初来乍到
  • 打卡总天数:8
  • 最近打卡:2025-01-17 13:57:41

19

主题

51

回帖

491

积分

中级会员

积分
491
发表于 2023-5-8 15:17:10 来自手机 | 显示全部楼层
Based on the information provided, it seems that the board is not able to handle burst data above 256 characters when sending at higher baud rates like 5Mbd. This could be due to various reasons like inadequate buffer size or the code not optimized for high-speed data transmission.

To address the issue:

a) You may need to optimize the code for high-speed data transmission by implementing interrupt-driven UART communication instead of polling. This will free up the CPU to perform other tasks while transmitting the data.

b) To reduce the wasted time caused by excessive stop bits, you can consider using a more efficient protocol like UART with hardware flow control (CTS/RTS) or even switch to a faster protocol like USB if possible.

It's important to note that achieving high-speed data transmission requires careful consideration and optimization of all components involved, including hardware, software, and protocols.
回复 支持 反对

使用道具 举报 送花

  • 打卡等级:以坛为家II
  • 打卡总天数:424
  • 最近打卡:2025-05-02 14:37:11
已绑定手机

77

主题

4849

回帖

8382

积分

超级版主

DebugLab

积分
8382
发表于 2023-5-8 15:19:36 来自手机 | 显示全部楼层
If you use official routines, you can use the XDATA version of the USB-CDC library.
DebugLab
回复 支持 反对

使用道具 举报 送花

  • 打卡等级:初来乍到
  • 打卡总天数:4
  • 最近打卡:2025-05-01 06:58:22

5

主题

184

回帖

1333

积分

金牌会员

积分
1333
发表于 2023-5-8 15:44:59 | 显示全部楼层
本帖最后由 jmg 于 2023-5-8 16:08 编辑

The Board was ordered from AliExpress and the code on the chip inside the board, is whatever it shipped with. I have downloaded no new code.
ie this 256 byte overflow flaw is in all boards, as-shipped.
If I send small packets, with long enough pauses between (mouse clicks) there is never an issue - I can send thousands of bytes, provided they are in blocks less than 256 bytes.
If I check 384 byte file, it sends just 128 bytes, even at low BAUD of 9600.  ie failure is independant of BAUD speed.
回复 支持 反对

使用道具 举报 送花

  • 打卡等级:初来乍到
  • 打卡总天数:4
  • 最近打卡:2025-05-01 06:58:22

5

主题

184

回帖

1333

积分

金牌会员

积分
1333
发表于 2023-5-8 16:12:25 | 显示全部楼层
Debu*** 发表于 2023-5-8 15:13
If the MCU can only receive 256 bytes, you need to check that the receive buffer size is not overflo ...

This is PC -> MCU -> UART send, I have not done receive tests test.
I did not expect PC-send to lose characters.
回复 支持 反对

使用道具 举报 送花

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|小黑屋|深圳国芯人工智能有限公司 ( 粤ICP备2022108929号-2 )

GMT+8, 2025-5-2 17:47 , Processed in 0.199064 second(s), 118 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表