无线呼叫系统,带日历时钟。这是可以生产的文件。MCU用STM8S103K3T6,呼叫号码4位数,呼叫深度20组,存储号码128组。
Altium Designer画的原理图和PCB图如下:(51hei附件中可下载工程文件)
单片机源程序如下:
- /********************************************************
- 2012.06.08 增加“换钱”语音工作模式
- 2012.07.04 增加时钟、呼叫类型显示
- 2012.07.25 硬件匹配“MST_719_V02”以上
- 2012.08.25 配合新的硬件"MST_719_V04"取消换钱语音,恢复分区模式
- 2012.10.22 更改在设置时间和恢复出厂设置菜单退出时语音相反的错误
- 2013.12.14 增加报警音
- 2014.04.22 更改为“金麒龙”呼叫器速率和编码
- *********************************************************/
- #include <iostm8s103k3.h>
- #include<Prot_define.h>
- #include"ProJ_Voice.H"
- #include"Global_variable.h"
- #include"main.h"
- #include"Proj_Menu.H"
- unsigned int duty_vlue;
- unsigned char key_values;
-
- //系统时钟设置
- void CLK_init(void)
- {
- CLK_CKDIVR = 0x08;
- }
- void EXIT_init(void)
- {
- PB_DDR_DDR4 = 0;
- PB_CR1_C14 = 1;
- PB_CR2_C24 = 1;
- EXTI_CR1 = 0x0c;
- }
- void TIM1_init(void)
- {
- TIM1_PSCRH = 0x00;
- TIM1_PSCRL = 0x07;
- TIM1_CR1 = 0x01;
- }
- void TIM2_init(void)
- {
- CLK_PCKENR1 |= 0X20;
- //TIM2_PSCRH = 0x00;
- TIM2_PSCR |= 0x03;
- TIM2_ARRH = 0x13;
- TIM2_ARRL = 0x88;
- TIM2_IER |= 0x01;
- TIM2_CR1 |= 0x01;
- }
- void Sys_Port_Init(void)
- {
- // PA_DDR = 0X00;
- PA_CR1 |= 0X0E; //0000 1110
- // PA_CR2 = 0X00;
-
- PB_DDR |= 0X6F;
- PB_CR1 |= 0X9F;
- PB_CR2 |= 0X1f;
- PC_DDR |= 0XFF;//
- PC_CR1 |= 0XFF;
- PC_CR2 |= 0XFF;
-
- PD_DDR |= 0X19;
- PD_CR1 |= 0XCD;
- // PD_DDR &= 0XF7;
- // PD_DDR &= 0X37;//20110727
- PD_CR2 |= 0X11;//20110727
-
- PE_DDR |= 0X00;
- PE_CR1 |= 0X20;
-
- PF_DDR = 0X00;
- PF_CR1 |= 0X10;
- }
- unsigned int tt1,tt2,tt_flag;
- #pragma vector=TIM2_OVR_UIF_vector
- __interrupt void TIM2_OVR_UIF(void)
- {
- TIM2_SR1 = 0; // 清除更新中断标记
- tt2++;
- flag_5ms = 1;
- key_values=((PA_IDR&0X0E))>>1;
- key_values|=((PF_IDR&0X10))>>1;
- key_values|=((PB_IDR&0X80))>>3;
- key_values|=((PD_IDR&0XC0))>>1;//增加按键于20110727
- if(tt2 > 99)
- {
- if((Menu_Value==0)&&(Called_Number==0))
- Prot_clock_LED = ~Prot_clock_LED;
- else Prot_clock_LED = 0;
- tt2=0;
- flag_500ms = !flag_500ms;
- if(key_values!=0x7f)
- {
- if(Key_downTime<50)
- Key_downTime++;
- }
- if(flag_500ms)flag_1s=1;
-
- if(Onemin_del++>=120)
- {
- Onemin_del=0;
- flag_1min=1;
- }
- }
- }
- #pragma vector=0x06
- __interrupt void EXTI_PB4(void)
- {
- unsigned char temp;
- temp = PB_IDR&0x10;
- TIM1_CR1=0;
- duty_vlue=TIM1_CNTRH;
- duty_vlue=(duty_vlue<<8)+TIM1_CNTRL;
- TIM1_CNTRH = 0;
- TIM1_CNTRL = 0;
- TIM1_CR1=1;
-
- if(PC<(Frame_L_+1))
- {
- if(duty_vlue<Lower_Limit)
- {
- PC=0;
- }
- else if(duty_vlue>Upper_Limit)
- {
- PC=0;
- }
- else
- {
- if(temp == 0)//if(temp == 0x10)20110727
- {
-
- if(PC<Frame_L_)
- {FS_H<<=1;
- FS_H|=(FS_M>>7);
- FS_M<<=1;
- FS_M|=(FS_L>>7);
- FS_L<<=1;
- if(duty_vlue>Data_0_) FS_L|=0x01;
- }
- duty_vlue=0;
- PC++;
- }
- }
- }
- else
- {
- if(duty_vlue>Last_Lower)
- {
- // flag_FS_OVER=1;
- TIM1_CR1=0;
- TIM1_CNTRH = 0;
- TIM1_CNTRL = 0;
- TIM1_CR1=1;
- if((FS_Hdata==FS_H)&&
- (FS_Mdata==FS_M)&&
- (FS_Ldata==FS_L))
- flag_FS_OVER=1;
- else
- {
- FS_Hdata=FS_H;
- FS_Mdata=FS_M;
- FS_Ldata=FS_L;
- }
- }
- duty_vlue=0;
- PC=0;
- }
- }
- void init_devices(void)
- {
- asm("sim");
- CLK_init();
- Sys_Port_Init();
- EXIT_init();
- TIM1_init();
- TIM2_init();
- IWDG_KR = 0XCC;
- IWDG_KR = 0x55;
- IWDG_PR |= 0x04;
- IWDG_KR = 0x55;
- IWDG_RLR = 0XFF;
- asm("rim");
- }
- /******************************************************************
- - 功能描述:时钟读取
- - 隶属模块:
- - 函数属性:供桌面刷新使用
- - 参数说明:无
- - 返回说明:
- - 注: 每一秒读取一次8563的时钟信息
- ******************************************************************/
- void Right_Time(void)
- {
- reed_rtc(0x02,&SystemTime[2],7);
- system_sec &= 0x7f;
- system_min &= 0x7f;
- system_hour &= 0x3f;
- system_day &= 0x3f;
- system_week &= 0x07;
- system_mon &= 0x1f;
- }
- void Pro_RF_Reseive(void)
- {
- unsigned char Re_Room;
- flag_FS_OVER=0;
- flag_blink=0;
- flag_ProDisplay=1;
- FS_keyvalue=FS_Ldata&0xf;
- Re_Room=Lookup_RoomNumber();
- if(Re_Room==0)
- {Pro_yk();return;}
- switch(Menu_Value)
- {
- case RECEIVE_MODE:
- if(Re_Room==0xa5){ Add_call(); } break;
- case STUDY_COD:
- if(Re_Room==0xaa) Stor_RoomNumber(); break;
- default: break;
- }
- }
- unsigned char warn_del,warn_del2,warn_out_1s;//BF20110317
- unsigned char warn_in; //BF20110317
- void Pro_5ms(void)
- {
- flag_5ms=0;
- flag_ProDisplay=1;
-
- //bf
- /* if(Prot_WarnIN)
- {
- warn_del++;
- if(warn_del>10)
- {
- warn_del2=0;
- warn_in=1;
- //warn_del=0;
- if(warn_out_1s==0)
- {
- warn_out_1s=1;
- Prot_Warnout=1;
- }
- if((warn_del>200)&&(Called_Number==0))
- Prot_Warnout=0;
- }
- }
- else
- {
- warn_del2++;
- if(warn_del>10)
- {
- warn_del=0;
- warn_in=0;
- //warn_del2=0;
- warn_out_1s=0;
- }
- }*/
- if(key_values==0x7f)
- {//bracket_1
- flag_Key_Down=0;
- KeyDown_del=0;
- Key_downTime=0;
- KeyValue=0;
- }//bracket_1
- else
- {//bracket_2
- if(!flag_Key_Down)
- {//bracket_3
- if(KeyDown_del++>5)
- {
- KeyDown_del=0;
- flag_Key_Down=1;
- flag_KeyPro=1;
- asm("nop");asm("nop");
- KeyValue=key_values;
- asm("nop");asm("nop");
- Send_data(0x4b,0x55);
- Returnmod=0;
- }
- }//bracket_3
- else Long_Keydown();
- }//bracket_2
-
- if(flag_yk)
- { yk_del++;
- if(yk_del>120)
- {
- yk_del=0;
- flag_yk=0;
- }
- }
- }
- void Pro_1s(void)
- {
- register uchar i;
- unsigned char K;
- unsigned char j,k1;
- flag_1s=0;
- if(Ptime) //整点报时
- {
- if((system_min==0)&&(system_sec==0))
- {
- // Pro_Display();
- j=system_hour>>4;
- k1=system_hour&0xf;
- buff[0]=0x49;
- buff[1]=0x31;
- buff[2]=0x3a;
- buff[3]=(j ? j : 0x53);
- buff[4]=(j ? 0x3e : 0x53);
- buff[5]=(k1 ? k1 :0x53);
- buff[6]=0x41;
- System_Sound(buff,7);
- }
- }
- if(Called_Number)
- {
- if(Rdis_Time)
- {
- Rdisp++;
- if(Rdisp>=Rdis_Time)
- {
- Rdisp=0;
- Pcall_dis++;
- if(Pcall_dis>Called_Number)
- Pcall_dis=1;
- }
- }
- if(Clear_time)
- {
- if(Called_Number>20)
- K=20;
- else K=Called_Number;
- for(i=0;i<K;i++)
- {
- Call_time[i]++;
- if(Call_time[i]>=Clear_time)
- {
- Pcall_dis=i+1;
- Dele_call();
- }
- }
- }
- if(Remind_time)
- {
- if(Called_Number>20)
- K=20;
- else K=Called_Number;
- for(i=0;i<K;i++)
- {
- if(Remind_buff[i]<Remind_time)
- Remind_buff[i]++;
- }
- if(Remind_buff[Pcall_dis-1]>=Remind_time)
- flag_blink=1;
- else flag_blink=0;
- }
- }
- if(flag_V)
- {
- flag_V++;
- if(flag_V>=3)
- {
- flag_V=0;
- Menu_Value=0;
- }
- }
- if(flag_stor)
- {
- Stor_del++;
- if(Stor_del>=3)
- {
- Stor_del=0;
- flag_stor=0;
- Add_RoomNumber();
- red_iic((Room_PageNumber<<5)+(RoomPage_addr*3)+2,buff2,1);//*
- while((buff2[0]&0x0f)==0x0a)
- {
- ClearWdg();
- Add_RoomNumber();
- red_iic((Room_PageNumber<<5)+(RoomPage_addr*3)+2,buff2,1);
- }//*
- }
- }
- if(Menu_Value)
- {
- Returnmod++;
- if(Returnmod>=240)
- { Returnmod=0;
- Menu_Value=0;}
- }
- }
- void Init_Value(void)
- {
- unsigned char x;
- Menu_Value=0;
- KeyValue=0;
- Returnmod=0;
- flag_V=0;
- flag_Time_Set=0;
- // Prot_Warnout=1;//bf
- red_iic(EEP_KEY_NUMBER,&Key_Number,25);
- Prot_LED=1;
- //Right_Time();
- voice_set(); //语音设置
- delay1ms(500);
- ClearWdg();
- delay1ms(50);
- // Prot_Warnout=0;//bf
- Set_Volume();
- Send_code(0x8d);
- Send_data(0x4a,0x71);//开机音乐
- tm1640_init();
- while (Onemin_del<10)
- {
- for(x=0;x<16;x++) {buff[x]=Onemin_del;}
- Display(buff,16);
- ClearWdg();
- //if(flag_FS_OVER||(key_values!=0x7f))
- if(key_values!=0x7f)
- break;
- }
- Prot_LED=0;//20110727
- //Send_voice(0x50);
- // if(Volume_value)
- Send_data(0x47,0x55);
- Right_Time();
- }
-
- void main(void)
- {
- init_devices();
- Sys_Port_Init();
- Init_Value();
- Send_data(0x4a,0x71);//开机音乐
- while(1)
- {
- if(flag_KeyPro) Pro_KEY();
- if(flag_5ms==1) Pro_5ms();
- if(flag_FS_OVER) Pro_RF_Reseive();
- if(flag_ProDisplay) Pro_Display();
- if(flag_1s) Pro_1s();//Send_code(0x8d);
- // if(flag_playtime && (flag_Key_Down==0)) Play_time(); //当前时间播报,由于代码长度受限,取消此功能
- if(flag_HJ==1){HJ_sound();Send_code(0x8d);}
- if(flag_modsound && (flag_Key_Down==0)) Work_mode_s();
- if(Menu_Value == 0) Right_Time();
- ClearWdg();
- }
- }
复制代码
所有资料51hei提供下载:
MST_526_V04.zip
(470.14 KB, 下载次数: 33)
|