⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tea5767._c

📁 用TEA5767 自己动手制作的收音机。效果很好
💻 _C
字号:
#include<iom32v.h>
#include<macros.h>
#define uchar unsigned char 
#define uint unsigned int 
#define ulong unsigned long 
void delay()
{
uchar i=0;
for (i=0;i<200;i++)
;
}
unsigned char radio_write_data[5]={0x69,0x28,0xa0,0x13,0x00};   //要写入TEA5767的数据
void inputbyte(uchar CD)  //写入一字节数据
{
uchar i,mid=0;
for (i=0;i<8;i++)
{
mid=CD&0x80;
if (mid==0)
PORTC&=~BIT(PA0);
else 
PORTC|=BIT(PA0);
PORTC|=BIT(PA1); 
delay();
PORTC&=~BIT(PA1);
delay();
CD=CD<<1;
}
}
long radio=87000000;
int N=0;
void GetKey(void)	
{ 
		if(!(PINA&0x20)){
		radio+=100000;
		if (radio>108000000)
		radio=87000000;
		N=(long)((radio-225000)*4)/32768;
		PORTC|=BIT(PA2); 
		inputbyte(N>>8);
		inputbyte(N);
		inputbyte(0xa0);
		inputbyte(0x13);
		inputbyte(0x00);
		PORTC&=~BIT(PA2);
		delay();
		
		}
		else if(!(PINA&0x10)){
		radio-=100000;
		if (radio<87000000)
		radio=108000000;
		N=(long)((radio-225000)*4)/32768;
		PORTC|=BIT(PA2); 
		inputbyte(N>>8);
		inputbyte(N);
		inputbyte(0xa0);
		inputbyte(0x13);
		inputbyte(0x00);
		PORTC&=~BIT(PA2);
		delay();
		}
		
		
}

void main()
{
uchar i=0;
DDRC=0xff;
DDRA=0x00;
PORTA=0xff;
delay();
//PORTC|=BIT(PA3); 
PORTC|=BIT(PA4); 
while(1)
{
 GetKey();
}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -