亲测 可用 上传视频 太麻烦了
stm32单片机433M无线解码源程序如下:
- #include "led.h"
- #include "delay.h"
- #include "key.h"
- #include "sys.h"
- #include "usart.h"
- #include "timer.h"
-
- /************************************************
- APB1 的时钟为 36M, 而从 STM32 的内部时钟树图得知:当 APB1 的时钟分频数为 1 的
- 时候, TIM2~7 的时钟为 APB1 的时钟,而如果 APB1 的时钟分频数不为 1,那么 TIM2~7 的时
- 钟频率将为 APB1 时钟的两倍。因此, TIM3 的时钟为 72M,再根据我们设计的 arr 和 psc 的值,
- 就可以计算中断时间了。计算公式如下:
- Tout= ((arr+1)*(psc+1))/Tclk;
- 其中:
- Tclk: TIM3 的输入时钟频率(单位为 Mhz)。
- Tout: TIM3 溢出时间(单位为 us)
- 1ms=1000us
- ************************************************/
- uint8_t rf_data[4];
- extern uint8_t decode_ok; //解码成功标志位
- extern uint8_t RF;
- int main(void)
- {
-
- delay_init(); //延时函数初始化
- NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); //设置NVIC中断分组2:2位抢占优先级,2位响应优先级
- uart_init(115200); //串口初始化为115200
- LED_Init(); //LED端口初始化
- TIM3_Int_Init(79,71);//10Khz的计数频率,计数到5000为500ms 90us
- while(1)
- {
- if(decode_ok == 1) //解码成功
- {
- switch(rf_data[2])
- {
- case 0x84: //解码为0xf8,点亮LED
- {
- LED0=0;
- break;
- }
- case 0x82: //解码为0xf2,熄灭LED
- {
- LED1=0;
- break;
- }
- case 0x81: //解码为0xf2,熄灭LED
- {
- LED0=1;
- LED1=1;
- break;
- }
- }
- }
- }
- }
复制代码
所有资料51hei提供下载:
433解码程序.rar
(292.75 KB, 下载次数: 650)
|