HC 05實現電腦與stm32通訊

2021-08-21 13:58:37 字數 1407 閱讀 1416

藍芽在通訊中代替的是串列埠通訊時的一根線,所以在串列埠通訊改藍芽通訊時無需更改**,只需將藍芽連到微控制器上,注意若使用usart1,注意連線位置,之前我用的正點mini的板子,pa9、10用跳線帽和usb串列埠r和t連在一起,導致我把藍芽的r和tlian連在了usb的t和r上,藍芽根本沒和微控制器連在一起,從而無法通訊,正確連線方式應為藍芽r——pa10,t——pa9

初始化設定上電過程中長按藍芽上的小按鈕,直到紅色由長亮變為隔1s亮2s,由此進入at模式,串列埠助手配置即可。

#include "sys.h"

#include "bluetooth.h"

#if system_support_ucos

#include "includes.h"

#endif

#if 1

#pragma import(__use_no_semihosting)

//±ê×¼¿âðèòªµäö§³öº¯êý

struct __file

; file __stdout;

_sys_exit(int x)

//printf函式,重心

int fputc(int ch, file *f)

#endif

u8 usart_rx_buf2[usart_rec_len2];

u16 usart_rx_sta2=0;

void uart2_init(u32 bound)

#if en_usart2_rx

void usart2_irqhandler(void)

else //»¹ã»êõµ½0x0d

}}

} #ifdef os_ticks_per_sec

osintexit();

#endif

} #endif

#ifndef __bluetooth_h

#define __bluetooth_h

#include "stdio.h"

#include "sys.h"

#define usart_rec_len2 200 //¶¨òå×î´ó½óêõ×ö½úêý 200

extern u16 usart_rx_sta2; //½óêõ״쬱ê¼ç

//èç¹ûïë´®¿úöð¶ï½óêõ£¬çë²»òª×¢êíòôïâºê¶¨òå

void uart2_init(u32 bound);

#endif

由此,在主函式中新增「bluetooth.h」,主函式內設定好波特率,記得線查對,就可以用了。

樹莓派與STM32通訊

硬體 使用ch340的usb轉ttl 一般接有 根線 電源 gnd tx rx 操作 開啟樹莓派的終端 輸入 lsusb 會顯示出相應的usb裝置 找到hl 340 usb serial 輸入 pip list 檢視是否安裝pyserial 在測試之前要檢視usb的裝置號 在終端輸入 ls l de...

stm32通用定時器中斷實現步驟

1.使能定時器時鐘 rcc apb1periphclockcmd 注意通用定時器掛在哪條匯流排上 2.初始化定時器,配置arr,psc tim timebaseinit 3.開啟定時器中斷,配置nvic void tim itconfig nvic init 4.使能定時器 tim cmd 5.編寫...

STM32驅動L501(4G)模組實現無線通訊

1 軟硬體說明 硬體說明 mcu 51 stm3232最小系統板 我喜歡用模組進行評估測試,最小系統板是 買的,各位有相關資源即可 4g l501採用官方evb評估板,如下圖 我放的是l505的,501被我飛線了,太難看不放了,除了模組不同基本一樣 模組開發說明 為了實現stm32驅動l501模組實...