查看: 100|回复: 1

ASRPRO-4M,SBUS,接收超时中断,波特率100kbps,2位停止位

[复制链接]

1

主题

3

帖子

21

积分

注册会员

Rank: 2

积分
21
发表于 2024-7-3 15:20:47 | 显示全部楼层 |阅读模式
本帖最后由 hello51twen51 于 2024-7-5 10:51 编辑

如题,天问Block"字符编程"模式,使用ASRPRO-4M的UART0(PB5 TX ,  PB6  RX),SBUS,接收超时中断,波特率100kbps,2位停止位,偶校验


回复

使用道具 举报

1

主题

3

帖子

21

积分

注册会员

Rank: 2

积分
21
 楼主| 发表于 2024-7-5 10:47:16 | 显示全部楼层

ASRPRO-4M,SBUS,接收超时中断,100000bps,2位停止位,偶校验


使用的是鹿小班ASR-PRO开发板,字符编程模式,不理会语音输入输出,主要看UART的代码配置,代码如下

  1. #include "asr.h"
  2. extern "C"{ void * __dso_handle = 0 ;}
  3. #include "setup.h"
  4. #include "HardwareSerial.h"
  5. #include "myLib/asr_event.h"


  6. #include <stdio.h>
  7. #include <string.h>
  8. #include <inttypes.h>

  9. /*---------------------------------------------------------------------------------------------------------*/
  10. /* Includes of local headers */
  11. /*---------------------------------------------------------------------------------------------------------*/

  12. #define RUN_LED_ON digitalWrite(4,0)
  13. #define RUN_LED_OFF digitalWrite(4,1)
  14. #define RUN_LED_TOG digitalRead(4) ? digitalWrite(4,0) : digitalWrite(4,1)

  15. //用于查看程序运行时长
  16. uint32_t ul_sys_second = 0;


  17. uint32_t ul_uart0_irq_cnt = 0;//进入中断函数的次数
  18. uint32_t ul_uart0_rec_fream_cnt = 0;//接收超时中断的次数
  19. uint32_t ul_uart0_rec_byte_cnt = 0;//接收字节的个数
  20. uint8_t uc_uart0_rec_dat = 0;//接收到的最新字节

  21. //以下8个变量,前4个是进中断时的值,后4个时退出中断时候的值,方便调试打印
  22. uint32_t ul_mask_int_value_1 = 0;
  23. uint32_t ul_ris_value_1 = 0;
  24. uint32_t ul_mis_value_1 = 0;
  25. uint32_t ul_timeout_value_1 = 0;

  26. uint32_t ul_mask_int_value_2 = 0;
  27. uint32_t ul_ris_value_2 = 0;
  28. uint32_t ul_mis_value_2 = 0;
  29. uint32_t ul_timeout_value_2 = 0;


  30. uint32_t snid;
  31. void user_task_1();
  32. void ASR_CODE();

  33. //10进制格式打印一个无符号32位数据,调试打印用
  34. void print_ul_10_dat(uint32_t ul_dat)
  35. {
  36. Serial.write(ul_dat % 1000000 / 100000 + 0x30);
  37. Serial.write(ul_dat % 100000 / 10000 + 0x30);
  38. Serial.write(ul_dat % 10000 / 1000 + 0x30);
  39. Serial.write(ul_dat % 1000 / 100 + 0x30);
  40. Serial.write(ul_dat % 100 / 10 + 0x30);
  41. Serial.write(ul_dat % 10 + 0x30);
  42. Serial.write(0x0A);
  43. }
复制代码
SSCOM配置,8位数据位,2位停止位,EVEN偶校验,点击弹窗的OK后,需要输入100000作为波特率

image.png

测试数据如下,每帧30(因为我使用的SBUS是每帧25个字节个)字节,每20ms发一帧
image.png
上图中,可以看到左下角 S:9180,和图中红框标记
ul_uart0_irq_cnt =
000306
ul_uart0_rec_byte_cnt =
009180
ul_uart0_rec_fream_cnt =
000306

的一致,且 9180/ 30 = 306,刚好等于接收的帧数
image.png
image.png
回复

使用道具 举报

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

本版积分规则

QQ|Archiver|手机版|小黑屋|好好搭搭在线 ( © 好好搭搭在线 浙ICP备19030393号-1 )

GMT+8, 2024-7-16 16:28 , Processed in 0.099654 second(s), 26 queries .

Powered by Discuz!

© 2001-2024 Comsenz Inc.

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