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

USB to 2 serial ports-STC8H tests, and bugs

[复制链接]

该用户从未签到

4

主题

87

回帖

684

积分

高级会员

积分
684
发表于 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 ?





回复 送花

使用道具 举报

  • TA的每日心情
    奋斗
    昨天 08:00
  • 签到天数: 137 天

    [LV.7]常住居民III

    2

    主题

    27

    回帖

    614

    积分

    高级会员

    积分
    614
    发表于 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

    回复 支持 反对 送花

    使用道具 举报

    该用户从未签到

    551

    主题

    9602

    回帖

    1万

    积分

    管理员

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

    1.png

    回复 支持 反对 送花

    使用道具 举报

  • TA的每日心情
    开心
    2024-5-9 11:28
  • 签到天数: 1 天

    [LV.1]初来乍到

    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
    回复 支持 反对 送花

    使用道具 举报

  • TA的每日心情
    开心
    2024-5-16 07:55
  • 签到天数: 116 天

    [LV.6]常住居民II

    25

    主题

    305

    回帖

    1057

    积分

    荣誉版主

    Cyber Hamster

    积分
    1057
    发表于 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.
    (=・ω・=)
    回复 支持 反对 送花

    使用道具 举报

  • TA的每日心情
    开心
    2024-5-16 07:55
  • 签到天数: 116 天

    [LV.6]常住居民II

    25

    主题

    305

    回帖

    1057

    积分

    荣誉版主

    Cyber Hamster

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

    使用道具 举报

  • TA的每日心情
    慵懒
    2024-4-14 18:10
  • 签到天数: 2 天

    [LV.1]初来乍到

    18

    主题

    41

    回帖

    426

    积分

    中级会员

    积分
    426
    发表于 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.
    回复 支持 反对 送花

    使用道具 举报

  • TA的每日心情
    开心
    2024-5-16 07:55
  • 签到天数: 116 天

    [LV.6]常住居民II

    25

    主题

    305

    回帖

    1057

    积分

    荣誉版主

    Cyber Hamster

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

    使用道具 举报

    该用户从未签到

    4

    主题

    87

    回帖

    684

    积分

    高级会员

    积分
    684
     楼主| 发表于 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

    主题

    87

    回帖

    684

    积分

    高级会员

    积分
    684
     楼主| 发表于 2023-5-8 16:12:25 | 显示全部楼层
    DebugLab 发表于 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, 2024-5-25 12:19 , Processed in 0.069810 second(s), 67 queries .

    Powered by Discuz! X3.5

    © 2001-2024 Discuz! Team.

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