芯片解密|单片机解密|IC解密|芯片破解|芯片复制| PCB抄板|软件开发

飞芯科技-芯片解密|单片机解密|IC解密|芯片破解|芯片复制| PCB抄板|软件开发

芯片破解CH32V103的多串口通讯及验证

芯片破解H32V103配置有3个串口,适用于需要同时使用多个串口工作的环境,例如用在一个采用串口屏来显示工作界面并绘制数据波形曲线、一个串口用来控制数据记录仪来存储原始数据、一个串口来控制MP3音频播放模块来播报数据或发出语音提示等。
那么这3个串行通讯口都使用哪些引脚呢?
其使用的引脚情况如表1所示:


  
串口序号
  
TX
RX
USART1
A.9
A.10
USART2
A.2
A.3
USART3
B.10
B.11


其中,USART1主要供打印输出之用,其接口电路如图1所示。


串口1接口电路



芯片破解|
USART1执行老本行,来完成信息输出的工作;而将USART2USART3组成一个模拟双方收发数据的终端。
那完成这一任务都需要哪些器件呢?
一条杜邦线,一个USBTTL通信串口模块及导线,具体的连接形式如图2所示。
杜邦线的作用是将USART2TX连接到USART3RX,这样就用一条杜邦线连接起了模拟通信的收发双发。
USBTTL通信串口模块大的作用,则是将USART1的输出信息传输到电脑,并通过串口助手等工具软件来显示信息。
当然了,如果你要想令USART2USART3的地位平等,那也很容易,无非是再添加一条杜邦线,将空置的2个通讯引脚连接起来便是了!


u8 TxBuffer[] = "Buffer Send fromUSART2 to USART3 by polling!";
然后通过USARTx_CFG函数对USART2USART3进行初始化,其内容如下:
  1. 芯片破解|void USARTx_CFG(void)
  2. {
  3. GPIO_InitTypeDef GPIO_InitStructure;
  4. USART_InitTypeDef USART_InitStructure;
  5. RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2|RCC_APB1Periph_USART3, ENABLE);     RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA |RCC_APB2Periph_GPIOB , ENABLE);
  6. /* USART2 TX-->A.2   RX-->A.3 */
  7. GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
  8. GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  9. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;  
  10. GPIO_Init(GPIOA, &GPIO_InitStructure);
  11. GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;
  12. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
  13. GPIO_Init(GPIOA, &GPIO_InitStructure);
  14. /* USART3 TX-->B.10  RX-->B.11 */
  15. GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
  16. GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  17. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;  
  18. GPIO_Init(GPIOB, &GPIO_InitStructure);
  19. GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11;
  20. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
  21. GPIO_Init(GPIOB, &GPIO_InitStructure);   
  22. USART_InitStructure.USART_BaudRate = 115200;
  23. USART_InitStructure.USART_WordLength = USART_WordLength_8b;
  24. USART_InitStructure.USART_StopBits = USART_StopBits_1;
  25. USART_InitStructure.USART_Parity = USART_Parity_No;
  26. USART_InitStructure.USART_HardwareFlowControl=USART_HardwareFlowControl_None;
  27. USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;
  28. USART_Init(USART2, &USART_InitStructure);
  29. USART_Cmd(USART2, ENABLE);
  30. USART_Init(USART3, &USART_InitStructure);
  31. USART_Cmd(USART3, ENABLE);
  32. }



联系方式

地址:石家庄市新华区民族路77号华强广场D座2009
电话:0311-88816616/87087811
手机:13315190088
传真:0311-67901001
联系人:张工
网址:www.feixindz.com
邮箱:feixindz@163.com
微信:xinpianjiemi
QQ:527263666/568069805

在线客服
热线电话

企业微信