无线视频、音频传输模块的驱动编程(RC5808)

MCU:PIC16F1829

无线发射模块:VER001

无线接收模块:RCT7615

硬件原理图:



硬件连接说明:


频点
序号寄存器配置值频点发送器拨码接收器拨码(2\3\4)备注
10x0290657402000
20x02910
5760
3001
30x0291a
5780
4010
40x02984
5800
5011
50x0298e
5820
6100
60x02998
5840
7101
70x02a02
5860
8110
80x02a0c
5880
9111 














程序源代码:

#include <pic.h>
#include <pic16f1829.h>
#include "Mydefine.h"
#include "Ram.h"

#define _XTAL_FREQ 8000000	//用于精确延时  8M
//#define _XTAL_FREQ 32000000	//用于精确延时  32M
//配置为内部8MHZ的RC时钟源,看门狗关闭,上电复位使能,MCLR引脚为复位引脚,欠压复位开启,读保护
//如果RC=8MHZ _PLLEN_ON

__CONFIG(FCMEN_ON&FOSC_INTOSC&IESO_OFF&CLKOUTEN_OFF&BOREN_ON&CPD_ON&CP_ON&MCLRE_OFF&WDTE_OFF);
//__CONFIG(LVP_OFF&BORV_19&STVREN_ON&PLLEN_ON&WRT_OFF);//32M
__CONFIG(LVP_OFF&BORV_19&STVREN_ON&PLLEN_OFF&WRT_OFF);//8M

void init()
{
		//OSCCON = 0xf0;			//f0内部时钟源32MHz 4xPLL
		OSCCON=0X72;			//内部时钟源8MHz 禁止4xPLL  
		OPTION_REG=0x03;		//预分频为1:16,内部时钟
		ANSELB=0x00;        //
		ANSELA=0x00; 
		//TRISB = 0x07;//RB3,2,4
		TRISA = 0x38;//RA3\4\5拨码输入
}

void myspi1(uint8 add , uint32 data)
{	
	SPILE = 0;
	for(Q=0;Q <= 4;Q++)
	{
		SDO = 0;
		if(add&0x01)SDO=1;
		__delay_us(1);
		SCK = 1;
		__delay_us(1);
		SCK = 0;
		add >>= 1;
	}
	for(Q=0;Q <= 19;Q++)
	{
		SDO = 0;
		if(data&0x01)SDO=1;
		__delay_us(1);
		SCK = 1;
		__delay_us(1);
		SCK = 0;
		data >>= 1;
	}
  SPILE = 1;
	__delay_us(2);
  SPILE = 0;
}

void main()          
{
    init();
		__delay_ms(1000);
		lstatus = PORTA;
		lstatus &= 0x38;

    while(1)
    { 
				switch(lstatus)
				{
						case 0x00:		
								ADD = 0x08;
								DATA = 0x000000;
								myspi1(ADD , DATA);
								ADD = 0x11;
								DATA = 0x02906;
						    myspi1(ADD , DATA);
						break;
						case 0x08:
								ADD = 0x08;
								DATA = 0x000000;
								myspi1(ADD , DATA);
								ADD = 0x11;
								DATA = 0x02910;
						    myspi1(ADD , DATA);
						break;
						case 0x10:
								ADD = 0x08;
								DATA = 0x000000;
								myspi1(ADD , DATA);
								ADD = 0x11;
								DATA = 0x0291a;
						    myspi1(ADD , DATA);
						break;
						case 0x18:
								ADD = 0x08;
								DATA = 0x000000;
								myspi1(ADD , DATA);
								ADD = 0x11;
								DATA = 0x02984;
						    myspi1(ADD , DATA);
						break;
						case 0x20:
								ADD = 0x08;
								DATA = 0x000000;
								myspi1(ADD , DATA);
								ADD = 0x11;
								DATA = 0x0298e;
						    myspi1(ADD , DATA);
						break;
						case 0x28:
								ADD = 0x08;
								DATA = 0x000000;
								myspi1(ADD , DATA);
								ADD = 0x11;
								DATA = 0x02998;
						    myspi1(ADD , DATA);
						break;
						case 0x30:
								ADD = 0x08;
								DATA = 0x000000;
								myspi1(ADD , DATA);
								ADD = 0x11;
								DATA = 0x02a02;
						    myspi1(ADD , DATA);
						break;
						case 0x38:
								ADD = 0x08;
								DATA = 0x000000;
								myspi1(ADD , DATA);
								ADD = 0x11;
								DATA = 0x02a0c;
						    myspi1(ADD , DATA);
						break;
						default:break;
				}//END switch(lstatus)
				while(1)
				{
					status = PORTA;
					status &= 0x38;
					if(lstatus != status)
					{
						lstatus = status;
						break;
					}//END if(lstatus != status)
					__delay_ms(500);
				}//END while(1)
    }//END while(1)
}//END main()

void interrupt pic(void)   //接收中断处理
{
;
}






评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值