標(biāo)題:
兩個(gè)STM32單片機(jī)之間串口通信的程序
[打印本頁(yè)]
作者:
cenyufu
時(shí)間:
2024-9-9 14:46
標(biāo)題:
兩個(gè)STM32單片機(jī)之間串口通信的程序
實(shí)現(xiàn)兩個(gè)STM32F103單片機(jī)之間的串口通信
單片機(jī)源程序如下:
#include "led.h"
#include "sys.h"
#include "usart1.h"
#include "usart2.h"
#include "stdio.h"
#include "delay.h"
int main(void)
{
int16_t i=0;
LED_Init();
usart1_Init(115200);
usart2_Init(115200);
LED = 1;
//在這個(gè)while不斷的循環(huán)
while(1)
{
printf("i=%d\r\n",i);
Delay_ms(1000);
i++;
// if(USART1_STA & 0x8000)
// {
// LED = 0;
// //表示成功接收到數(shù)據(jù)
// //發(fā)回來(lái)電腦屏幕
// USART1_Send_data((char *)USART1_REC,USART1_REC_MAX);
//
// //發(fā)給另一個(gè)單片機(jī)
// USART2_Send_data((char *)USART1_REC,USART1_REC_MAX);
// USART1_STA &=~(0x8000);
// }
}
}
復(fù)制代碼
原理圖: 無(wú)
仿真: 無(wú)
代碼:
兩個(gè)STM32的串口通信.7z
(190.98 KB, 下載次數(shù): 9)
2024-9-9 15:10 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1