为了正常的体验网站,请在浏览器设置里面开启Javascript功能!

使用三星S3F9488单片机,编写的程序,感觉老是重启,请大虾们指点.txt

2017-12-30 12页 doc 28KB 50阅读

用户头像

is_954223

暂无简介

举报
使用三星S3F9488单片机,编写的程序,感觉老是重启,请大虾们指点.txt使用三星S3F9488单片机,编写的程序,感觉老是重启,请大虾们指点.txt 使用三星S3F9488单片机,编写的程序,感觉老是重启,请大虾们指点 #include "ioS3C9488.h"// #include "intrinsics.h"//包含内部函数 #include "math.h" #pragma vector = __TIMERB_UNDERFLOW_vector __root __interrupt void interrupt0(); #define uchar unsigned char #de...
使用三星S3F9488单片机,编写的程序,感觉老是重启,请大虾们指点.txt
使用三星S3F9488单片机,编写的程序,感觉老是重启,请大虾们指点.txt 使用三星S3F9488单片机,编写的程序,感觉老是重启,请大虾们指点 #include "ioS3C9488.h"// #include "intrinsics.h"//包含内部函数 #include "math.h" #pragma vector = __TIMERB_UNDERFLOW_vector __root __interrupt void interrupt0(); #define uchar unsigned char #define uint unsigned int #define Set_Bit(byte,bit) (byte|=(1< #define Clr_Bit(byte,bit) (byte&=~(1< __code const volatile uchar SmartOption[4] @0x003c = {0xFF,0x00,0xBB,0xFB}; //定义P0.0-P0.2为次晶振,EESET void delay(uint i); //单位为1ms void Err1( ); void Err2( ); void Winter( ); void Summer( ); void Cotton( ); void Wool( uchar m2); void Shoes( ); void Clothes(uchar m4 ); void Flea( ); void Temp( ); void Booking( uchar temp1); //void Interrupt0( ); void initialize( ); //初始化程序 void scan( ); // void heat_work(); //加热 void heat_stop(); void fan_work(); //风扇 void fan_stop(); void modify_time(); //修改时间 void buz(); uchar LCD0[11]={0x00,0x60,0x40,0x20,0x80,0x80,0x40,0x00,0x00,0x80,0xE0}; //显示0-9,E- uchar LCD1[11]={0x10,0xB0,0X20,0XA0,0X20,0X00,0XB0,0X00,0X20,0x40,0XE0}; //显示0-9,E- uchar KEY[6]={0XEF,0XDF,0XBF,0X7F,0XFE,0XFD}; //按钮1-6 uchar LED[]={0x01,0x02,0x04,0x08,0x80,0x10,0x20,0x40}; //数码管高电位 uchar time[6]; uchar ID=0; uchar hour=0,min=0,sec=0; uint flag=0; uchar temp=0; /*****************************************************************/ //主函数 /****************************************************************/ void main( ) { //BTCON=0XFF; SP=0XC0; asm("DI"); //ADCON=0X8D; //1vs采样一次 BTCON=0XFB; //稳定晶振为62.5ms OSCCON=0X04; CLKCON=0X8F; //没有分频 LCDCON=0X94; //LCD的占空比,信号为FW/128 LCDVOL=0X89; // LCD的亮度设置 P0CONH=0XFF;P0CONL=0X80;P0PUR=0XFF; //p0.3为采样口 P1CONH=0XFF;P1CONL=0XA6; P1PUR=0XFF; //P1.0有待最后确定 P2CONH=0XFF;P2CONL=0XFF; P3CONH=0XFA;P3CONL=0X00; //P3.0为输入,全是输入 P3INT=0X00; //不启用外部中断 P4CONH=0x16;//0X02; P4CONL=0X7F;//0X3F; //STPCON=0XA5; //允许STOP指令 TACON=0X00; //初始化 TBCON=0X00; //TINTPND=0X00; //待定??? // VLDCON=0X1D; //VLDCON=0XDD; //WTCON=0X52; //待定 //SYM=0X08; //允许所有中断运行 //asm("DI"); asm("EI"); initialize( ); //初始化 while(1) { if (P3==KEY[3]) delay(10); if(P3==KEY[3]) { void buz(); Winter( ); Err2(); Err1(); /*if(P3==KEY[0]) delay(10); if(P3==KEY[0]) { void buz(); Booking( ); while(P3==KEY[0]); }*/ if(P3==KEY[1]) delay(10); if(P3==KEY[1] ) { void buz(); void Flea(); while(P3==KEY[1]); if(P3==KEY[5]) delay(10); if(P3==KEY[5]) { void buz(); ID++; if(ID>5) ID=0; switch(ID) { case 0: Winter( ); Cotton(0); break; case 1: Winter( ); Clothes(0); break; case 2: Winter( ); Wool(0); break; case 3: Winter( ); Shoes(0); break; case 4: Summer( ); Clothes(1); break; case 5: Summer( ); Wool(1); break; default: break; } while(P3==KEY[5]); } while(P3==KEY[3]); } } } /**************************************************************************/ //功能函数 /**************************************************************************/ void delay(uint i ) // MS { uint k; uint a; for(k=0;k for(a=0;a<500; a++) asm("NOP"); } void initialize( ) { uchar r; // WTCON=0X56; //P4=0X17; P0=0X00; P1=0X00; P2=0XFF; P4=0X17; delay(1000); //P1=0XF0; //P0=0XF0; //P1=P1_1_High; WTCON=0X12; //给蜂鸣器1K脉冲 for(r=0;r<10;r++) delay(500); //P1=0xf2; WTCON=0X10; // WTCON=0X16; P2=0X00; P4=0X00; P1=0XF0; P0=0XF0; } void scan( ) { static uchar x1,x2=5; for(x1=4;x1<8;x1++) { P2=LED[x1]; if(x2<2) x2=5; P1=LCD0[time[x2--]]; } } void Err2( ) { uchar t; if (P3==0x01) delay(10); if (P3==0x01) { void buz(); while(1) { Set_Bit(P1,1); for(t=0;t<10;t++) delay(1000); Clr_Bit(P1,1); for(t=0;t<10;t++) delay(1000); } } } void Winter( ) { Clr_Bit(P0,5); Set_Bit(P4,0); Set_Bit(P0,4); } void Summer( ) { Clr_Bit(P0,4); Set_Bit(P4,0); Set_Bit(P0,5); void Cotton( ) { uchar s1=0; Clr_Bit(P0,6); Set_Bit(P4,1); /* time[0]=0; time[1]=0; time[2]=0; time[3]=0; time[4]=2; time[5]=0;*/ sec=0; min=0; hour=2; modify_time(); //TBCON=0x22; TBDATAH=0XC3; //定时为50MS TBDATAL=0X50; TBCON=0x22; if(P3==KEY[4]) delay(10); if(P3==KEY[4]) { void buz(); s1++; TBCON=0x2E; //计时开始 heat_work(); //heat_stop(); fan_work(); //fan_stop(); if(flag==20) { sec-=1; modify_time(); } if(s1==2) { heat_stop(); fan_stop(); TBCON=0x22; //停止计时和禁止中断 s1=0; } } } void Booking(uchar temp1 ) { //uchar ID=0; //ID++; switch( temp1) { case 0: min=20;break; case 1:min=40;break; case 2:hour=1;break; default:sec=0,min=0,hour=0;break; } } void Interrupt0( ) { uint t=0; // uint flag=0; t++; if(t==20) { flag=20; t=0; } else flag=0; } void heat_work() { P1=P1_2_High; } void heat_stop() { P1=P1_2_Low; } void fan_work() { P1=P1_0_High; } void fan_stop() { P1=P1_0_Low; } void modify_time() { // uchar temp=0; if(sec==0) { if((min==0)&&(hour==0)) { heat_stop(); fan_stop(); if(P3==KEY[0]) // 预约 delay(10); if(P3==KEY[0]) { void buz(); Booking(temp ); temp++; if(temp==3) temp=0; while(P3==KEY[0]); } else TBCON=0x22; //停止计时和禁止中断 } else sec=59; if((min-=1)==0&&hour!=0) { //if((hour-=1)>=0) min=59; hour-=1; } } //sec%=60; //temp2= //min-=temp1/60; //temp2=min; //min%=60; // hour=(hour-temp/60)%12; time[0]=sec%10; time[1]=sec/10; time[2]=min%10; time[3]=min/10; time[4]=hour%10; time[5]=hour/10; scan(); } void buz() { WTCON=0X32; //给蜂鸣器4K脉冲 delay(500); P1=0xf2; WTCON=0X30; } 烧写到硬件里,老是感觉重启,LED闪烁很厉害,蜂鸣器一直发出吱吱的声音,给的是1KHZ 的频率,望大虾们指点迷津,程序不全,说太长发不了
/
本文档为【使用三星S3F9488单片机,编写的程序,感觉老是重启,请大虾们指点&#46;txt】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。

历史搜索

    清空历史搜索