11f02e与stc15f104w资料代码兼容吗

STC11F02E串口切换的问题,已经成功解决的朋友帮下忙啊,谢谢了!!_百度知道
STC11F02E串口切换的问题,已经成功解决的朋友帮下忙啊,谢谢了!!
我是如下做的;&#47,不能正常下载程序.0和P3,重新换回到 P3,但是这2个pin脚和P1.7.0和P3; temp=P1STC11F02E的一款20pin脚的芯片,串口是默认的P3.6与P1;先确定它的地址 while(1) { AUXR1=1,后来我就把TXD与RXD2根线接到P1.7是等价的,说明串口并没有从P3口切换到P1口,希望能得到你的帮助,在STC官网上面查了资料的.1: sfr AUXR1=0xA2,说要把AUTR1特殊功能寄存器置1.6与P1; 然后再循环里面给它赋值1;&#47,又能正常下载程序.1的话!
提问者采纳
貌似AUXR1的最高位才是控制串口切换的,赋值应该是AUXR1 |= 0X80;
提问者评价
其他类似问题
为您推荐:
其他1条回答
是端口重映射?这个芯片 表示不懂
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁查看: 615|回复: 0
STC11F02E单键控制的两种模式选择
OMG! 今晚,出去买烟时,走着想着,构思着,一个按键控制四个数码管显示;按第一下高位显示1H并闪烁;按第二下低位显2H并闪烁;
按第三下则把选择后的状态用拉幕的方式显示出来;
PCB打了10个样品收到了,今天组装了并下载以前的程序个功能是好;现在程序改好了,空闲时下载到新的板子上,再调试调试,应该是可以的;
好了,上代码了!//#pragma src(signle.a51)
#include &reg52.h&
#include &display.c&
#define uchar unsigned char
#define uint unsigned int
//sfr PCON = 0x87h;
sbit Key1 = P3^2;
sbit BUZ = P3^1;
sbit Signle = P3^0;
sbit Led0&&= P1^0;
sbit JDQ&&= P1^2;
sbit Dp = P1^5;
sbit SMG1 = P3^7;
sbit SMG2 = P3^5;
sbit SMG3 = P3^4;
sbit SMG4 = P3^3;
uint Key_count,Time_value,BTime_C
uchar Beep_time,Key_flag,BTime_Flag,JDQ_flag,BP_Count,LM_Count,LM_GroupCNT;
uchar BT_Sec,Sec,Min,Hour,Key_Select,Key_long_flag,Key_long_
uchar Led_Scan,Led_Loop,Sec_1,Min_1,Hour_1,BT_Sec_1;
uchar Key_Select_F
//uchar Display_number[]={0xd7,0x14,0xcd,0x5d,0x1e,0x5b,0xdb,0x15,0xdf,0x5f,0x00};
uchar code Display_number[]={0x28,0xeb,0x32,0xa2,0xe1,0xa4,0x24,0xea,0x20,0xa0,0xff,0xf7}; // -
uchar code Display_string[]={0xff,0xff,0xff,0xf7,0xeb,0x61,0x32,0xf7,0xff,0xff,0xff,0xff,0xff,0xff};//
uchar code Display_string2[]={0xff,0xff,0xff,0xf7,0x32,0x61,0x32,0xf7,0xff,0xff,0xff,0xff,0xff,0xff};//;
uchar code Display_NUM[]={0,1,2,3,4,5,6,7,8,9,10,11};
uchar Clock[]={0xff,0xff,0xff,0xeb,0x32,0xf7,0xeb,0x32,0xf7,0xeb,0x32,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
//---------------------------------------------------
//---------------------------------------------------
//4COM 共阳数码管 1234 SR410361K
//---------------------------------------------------
//P1.0 A;& & |---|
//P1.2 B;& & |& &|
//P1.4 C;& & |---|
//P1.6 D;& & |& &|
//P1.7 E;& & |---|
//P1.5 Dp;
//SMG1=P3.7,SMG2=P3.5,SMG3=P3.4,SMG4=P3.3;
//---------------------------------------------------
//---------------------------------------------------
void display_Scan(void);
void Delay_ms();
void Clock_Prog();
void Clock_Prog_1();
void Delay_ms(uint Tms)
{
&&uint i,j;
&&for(i=Ti&0;i--)
&&for(j=1220;j&0;j--)
&&{;}
void Delay_us(uint Tus)
{
&&while(--Tus);
void Buz(void)
&&{
& &
& & for(i=0;i&200;i++)
& & {
& && &BUZ=~BUZ;
& &&&Delay_us(300);
& & }
& & BUZ=0;
&&}
void Beep_Bi(void)
{
&&if(Beep_time!=0)
&&{
& &Beep_time--;
& &BUZ=~BUZ;
&&}
&&else
&&{
& &BUZ=0;
&&}
void T0_ini()
{
& &TMOD=0x12;
&&TH1=()/256;
&&TL1=()%256;
&&TR1=1;
&&ET1=1;
&&TH0=6;
&&TL0=6;
&&TR0=0;
&&ET0=1;
void TM0(void)interrupt 1
{
&&uint Time_C
&&TF0=0;
&&Time_Count++;BTime_Count++;
&&BP_Count++;
&&if(BTime_Count==2000)
&&{
& &BT_Sec++;BTime_Flag=~BTime_F
&&}
&&if(BP_Count==2)& && &//1ms DiDa B
&&{
& &BP_Count=0;
& &Beep_Bi();
&&}
&&if(Key_Select_Flag==1)& &//1Hz
&&{
& & if(Time_Count==2000)
& &{
& &&&Time_Count=0;Dp=~Dp;Signle=~S
& &}
&&}
&&if(Key_Select_Flag==2)& &//2Hz
&&{
& &if(Time_Count==1000)
& &{
& & Time_Count=0;Dp=~Dp;Signle=~S
& &}
&&}
& & //if(Time_Count==2000) // ext atxl 12MHz;500ms
&&//if(Time_Count==1333) // ext atxl 8MHz 500
&&//if(Time_Count==998) // 500ms
& & //{
&&// Time_Count=0;
& &//BTime_Flag=~BTime_F
& &//BT_Sec++;
&&// Dp=~Dp;
& &//BT_Sec_1++;
&&// Signle=~S
& &/*/if(Key_flag==1)
& &{
& & BT_Sec=0;
& & if(BT_Sec_1==2)
& & {
& && &BT_Sec_1=0;
& &&&Sec_1++;
& &&&if(Sec_1==60)
& &&&{
& && &Sec_1=0;Min_1++;
& &&&}
& &&&if(Min_1==60)
& &&&{
& && &Min_1=0;Hour_1++;
& &&&}
& &&&if(Hour_1==24)
& &&&{
& && &Hour_1=0;
& &&&}
& & // Clock_Prog_1();
& & }
& &} */
// }
&&if(BT_Sec==2)
&&{
& &BT_Sec=0;
& &Sec++;
& &if(Sec==60)
& &{
& & Sec=0;Min++;
& &}
& &&&if(Min==60)& && &&&
& &{
& & Min=0;Hour++;
& &}
& &if(Hour==24)
& &{
& & Hour=0;
& &}
& &//Clock_Prog();
&&}
void TM1(void)interrupt 3
{
&&TH1=()/256;
&&TL1=()%256;
&&Led_Scan=1;Led_Loop++;Led_Loop=Led_Loop&0x03;
&&
& & Key1=1;
& & if(Key1==0)
& & {
& &&&Key_count++;
& &if(Key_count==20)
& &{
& &&&Beep_time=100;
& &&&Key_flag=1;
& &&&TR0=1;
& &&&Key_Select++;
& &&&if(Key_Select==3)
& &&&{
& && &Key_Select=0;Key_flag=0;
& &&&}
&&//&&}
&&// if(Key_count&=20*50)
&&// {& &&&
&&//&&Key_count=500; // 设置长按快跳进度
&&//&&Key_long_flag=1;
&&//&&{
& && & if(Key_Select==1)
& &&&{
& && &Key_Select_Flag=0;
& & Key_Select_Flag=1;
& &&&// Min++; if(Min==60)Min=0;
& &&&}
& & if(Key_Select==2)
& &&&{
& & Key_Select_Flag=0;
& & Key_Select_Flag=2;
& &&&// Hour++; if(Hour==24)Hour=0;
& && &&&}& &
&&//&&}
&&// }
& &}
&&}
& &&&else
& &{Key_count=0;Key_long_flag=0;Key_Select_Flag=0;}
& &}
& &void Clock_Prog()
&&{
& &//Clock[0]=Display_number[10];
& &//Clock[1]=Display_number[10];
& &Clock[3]=Display_number[Hour/10];
& &Clock[4]=Display_number[Hour%10];
& &Clock[5]=Display_number[11];//
& &Clock[6]=Display_number[Min/10];
& &Clock[7]=Display_number[Min%10];
& &Clock[8]=Display_number[11];//
& &Clock[9]=Display_number[Sec/10];
& &Clock[10]=Display_number[Sec%10];
& &//Clock[11]=Display_number[10];
& &//Clock[12]=Display_number[10];
& &//Clock[13]=Display_number[10];
& &//Clock[14]=Display_number[10];
&&}
& &void Clock_Prog_1()
&&{
& &//Clock[0]=Display_number[10];
& &//Clock[1]=Display_number[10];
& &Clock[3]=Display_number[Hour/10];
& &Clock[4]=Display_number[Hour%10];
& &Clock[5]=Display_number[11];//
& &Clock[6]=Display_number[Min_1/10];
& &Clock[7]=Display_number[Min_1%10];
& &Clock[8]=Display_number[11];//
& &Clock[9]=Display_number[Sec_1/10];
& &Clock[10]=Display_number[Sec_1%10];
& &//Clock[11]=Display_number[10];
& &//Clock[12]=Display_number[10];
& &//Clock[13]=Display_number[10];
& &//Clock[14]=Display_number[10];
&&}
&&void SmgDisp(uchar ch,uchar num)
&&{
&&
&&number=
&&//P3=0x03;
&&P1=0
&&SMG1=0;SMG2=0;SMG3=0;SMG4=0;
&&switch(ch)
&&{
& &case 1:SMG4=1;LM_Count=0;& & //SMG排列 1 2 3 4 第四个数码管
& &case 2:SMG3=1;LM_Count++;& & //SMG排列 1 2 3 4 第三个数码管
& &case 3:SMG2=1;LM_Count++;& & //SMG排列 1 2 3 4 第二个数码管
& &case 4:SMG1=1;LM_Count++;& & //SMG排列 1 2 3 4 第一个数码管
& &default:
&&}
& &//P1=Display_number[Clock[number]];
&&//P1=Display_string[number];
&&if(Key_Select==0||Key_Select_Flag==1)
&&{
& &P1=Display_string[number];
&&}
&&if(Key_Select_Flag==2)
&&{
& &P1=Display_string2[number];
&&}
&&//P1=Clock[number];
&&}
&&void CheckTime()
&&{
&&if(Led_Scan)
&&{
& &switch(Led_Loop)
& &{
& & case 0:SmgDisp(4,LM_Count+LM_GroupCNT); //第一个数码管
& & case 1:SmgDisp(3,LM_Count+LM_GroupCNT); //第二个数码管
& & case 2:SmgDisp(2,LM_Count+LM_GroupCNT); //第三个数码管
& & case 3:SmgDisp(1,LM_Count+LM_GroupCNT); //第四个数码管
& &}
& &&&Led_Scan=0;
&&}
&&}
&&
void Display(void)
{
&&if(BTime_Flag&(Key_Select==2)&(Key_long_flag==0))
& &{
& &P1=0SMG1=0;SMG2=0;SMG3=0;SMG4=0;
& && && && & //P3=0x00;
&&}
&&else
&&{
& &if(BTime_Flag)
&&{
& &Dp=0;SMG1=1;& && & //P3=0x80;
& &Delay_ms(1);SMG1=0;& && &//P3=0x00;
& &Dp=0;SMG2=1;& && & //P3=0x20;
& &Delay_ms(1);SMG2=0;& && &//P3=0x00;
&&}
&&//P1=Display_number[Hour/10];
&&P1=Display_string[4];
& &SMG1=1;& && && & //P3=0x80;
&&Delay_ms(1);
& &SMG1=0;& && && & //P3=0x00;
& &P1=0
& &//P1=Display_number[Hour%10];
&&P1=Display_string[5];
& &SMG2=1;& && && & //P3=0x20;
& &Delay_ms(1);
& &SMG2=0;& && && & //P3=0x00;
& &P1=0
&&}
&&if(BTime_Flag&(Key_Select==1)&(Key_long_flag==0))
& &{
& &P1=0SMG1=0;SMG2=0;SMG3=0;SMG4=0; //P3=0x00;
&&}
&&else
&&{
& &if(BTime_Flag)
&&{
& &Dp=0;SMG3=1;& && & //P3=0x10;
& &Delay_ms(1);SMG3=0;& && &//P3=0x00;
& &Dp=0;SMG4=1;& && & //P3=0x08;
& &Delay_ms(1);SMG4=0;& && &//P3=0x00;
&&}
&&//P1=Display_number[Min/10];
&&P1=Display_string2[4];
& &SMG3=1;& && && & //P3=0x10;
& &Delay_ms(1);
& &SMG3=0;& && && & //P3=0x00;
& &P1=0
& &//=Display_number[Min%10];
&&P=Display_string2[5];
& &SMG4=1;& && && & //P3=0x08;
& &Delay_ms(1);
& &SMG4=0;& && && & //P3=0x00;
& &P1=0
&&}
void exint0(void)interrupt 0
{
&&Buz();T0_ini();EX0=0;EA=1;
void Display_Scan(void)
{&&
&&P1=0x00;
&&P3=0x00;
//---------&A&--------------
&&//P1=0x01;
&&P1=0
&&P3=0x80;& &//smg1
&&Delay_ms(1);
&&P1=0
&&P3=0x00;
&&P1=0
&&P3=0x20;& &//smg2
&&Delay_ms(1);
&&P1=0
&&P3=0x00;
&&P1=0
&&P3=0x10;& &//smg3
&&Delay_ms(1);
&&P1=0
&&P3=0x00;
&&P1=0
&&P3=0x08;& &//smg4
&&Delay_ms(1);
&&P1=0
&&P3=0x00;
&&P1=0
&&Delay_ms(100);
//---------&B&--------------
&&P1=0
&&P3=0x80;
&&Delay_ms(1);
&&P1=0
&&P3=0x00;
&&P1=0
&&P3=0x20;
&&Delay_ms(1);
&&P1=0
&&P3=0x00;
&&P1=0
&&P3=0x10;
&&Delay_ms(1);
&&P1=0
&&P3=0x00;
&&P1=0
&&P3=0x08;
&&Delay_ms(1);
&&P1=0
&&P1=0
&&P3=0x00;
&&Delay_ms(100);
//---------&C&--------------
&&//P1=0x10;
&&P1=0
&&P3=0x80;
&&Delay_ms(1);
&&P1=0
&&P3=0x00;
&&P1=0
&&P3=0x20;
&&Delay_ms(1);
&&P1=0
&&P3=0x00;
&&P1=0
&&P3=0x10;
&&Delay_ms(1);
&&P1=0
&&P3=0x00;
&&P1=0
&&P3=0x08;
&&Delay_ms(1);
&&P1=0
&&P1=0
&&P3=0x00;
&&Delay_ms(100);
//---------&D&--------------
&&P1=0
&&P3=0x80;
&&Delay_ms(1);
&&P1=0
&&P3=0x00;
&&P1=0
&&P3=0x20;
&&Delay_ms(1);
&&P1=0
&&P3=0x00;
&&P1=0
&&P3=0x10;
&&Delay_ms(1);
&&P1=0
&&P3=0x00;
&&P1=0
&&P3=0x08;
&&Delay_ms(1);
&&P1=0
&&P3=0x00;
&&Delay_ms(100);
//---------&E&--------------
&&P1=0x7f;
&&P3=0x80;
&&Delay_ms(1);
&&P1=0
&&P3=0x00;
&&P1=0x7f;
&&P3=0x20;
&&Delay_ms(1);
&&P1=0
&&P3=0x00;
&&P1=0x7f;
&&P3=0x10;
&&Delay_ms(1);
&&P1=0
&&P3=0x00;
&&P1=0x7f;
&&P3=0x08;
&&Delay_ms(1);
&&P1=0
&&P3=0x00;
&&Delay_ms(100);
//---------&F&--------------
&&P1=0
&&P3=0x80;
&&Delay_ms(1);
&&P1=0
&&P3=0x00;
&&P1=0
&&P3=0x20;
&&Delay_ms(1);
&&P1=0
&&P3=0x00;
&&P1=0
&&P3=0x10;
&&Delay_ms(1);
&&P1=0
&&P3=0x00;
&&P1=0
&&P3=0x08;
&&Delay_ms(1);
&&P1=0
&&P3=0x00;
&&Delay_ms(100);
//---------&G&--------------
&&P1=0xf7;
&&P3=0x80;
&&Delay_ms(1);
&&P1=0
&&P3=0x00;
&&P1=0xf7;
&&P3=0x20;
&&Delay_ms(1);
&&P1=0
&&P3=0x00;
&&P1=0xf7;
&&P3=0x10;
&&Delay_ms(1);
&&P1=0xf7;
&&P3=0x08;
&&P1=0
&&P3=0x00;
&&Delay_ms(1);
&&P1=0x00;
&&P3=0
&&Delay_ms(100);
//------------------------------
&&P1=0
&&P3=0x00;
&&Delay_ms(200);
&&P1=0x00;
&&P3=0
&&Delay_ms(200);
//------------------------------
&&P1=0x00;
&&P3=0x80;
&&Delay_ms(30);& &//smg1
&&P1=0x00;
&&P3=0x20;
&&Delay_ms(30); //smg2
&&P1=0x00;
&&P3=0x10;
&&Delay_ms(30); //smg3
&&P1=0x00;
&&P3=0x08;&&//smg4
&&Delay_ms(30);
&&P1=0x00;
&&P3=0
&&Delay_ms(200);
&&P1=0
&&P3=0x00;
&&Delay_ms(200);
&&P1=0x00;
&&P3=0
&&Delay_ms(200);
void main(void)
{
& &
&&Buz();Display_Scan();& && && && && && && && && && && && && && && && && && && && && && && && && &
& &T0_ini();Clock_Prog();
& &while(1)
& &{
///*/-------------按键小于2次有分钟睡眠模式-----------------
& &if(Hour==4)
& &{
& & EX0=1;
& & EA=1;
& & Key_flag=0;
& & Min_1=0;
& & Hour_1=0;& && && && && && && &
& & Signle=1;
& & TR0=1;
& & P1=0
& & PCON=0x02;
& &}
////---------------------------------------------------------& &*/
& &//Clock_Prog();
& &if(Sec%5==0)
& &{&&
& &&&//for(LM_GroupCNT=0;LM_GroupCNT&13;LM_GroupCNT++)//拉幕时钟时分秒显示
& & for(LM_GroupCNT=0;LM_GroupCNT&10;LM_GroupCNT++)
& & {
& &&&for(k=65500;k&0;k--)
& &&&{
& && &CheckTime();
& &&&}
& & }
& &}
& &else
& &Display();
& &}
}
复制代码
Powered by

我要回帖

更多关于 stc15f104w引脚图 的文章

 

随机推荐