Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <XE164F.h>
- #include <../lcd_XE164.h>
- //----------------Variablendeklaration--------------------------------------
- //eingänge
- sbit grad60=P1_IN^1; //melder60
- sbit grad90=P1_IN^2; //melder90
- sbit sw_temp=P1_IN^3; //schalter60/90
- sbit einaus=P1_IN^4; //ein aus schalter
- sbit pegel1=P1_IN^5; //pegal wasserpegal S3
- //ausgänge
- sbit heizung=P1_OUT^0; //heizung
- sbit motor=P1_OUT^6; //motor M
- sbit zulauf=P1_OUT^7; //zulauf Y
- sbit ablauf=P4_OUT^0; //ablaufventil/pumpe P
- sbit schleudern=P4_OUT^1; //schleudern M(schleudern)
- int phase4=0;
- int sekzaehler=0; //zähler sekunden
- //------------------Funktionsdeklaration------------------------------------
- void init (void);
- void MAIN_vUnlockProtecReg(void);
- void regelung (void);
- //------------------Hauptprogramm-------------------------------------------
- void main (void)
- {
- init();
- while(1)
- {
- regelung();
- }
- }
- void init (void)
- {
- P1_IOCR00=0;
- P1_IOCR01=0;
- P1_IOCR02=0;
- P1_IOCR03=0;
- P1_IOCR04=0;
- P1_IOCR05=0;
- P1_IOCR06=0x80;
- P1_IOCR07=0x80;
- P4_IOCR00=0x80;
- P4_IOCR01=0x80;
- lcd_init();
- lcd_clr();
- //timer aktivierung/definierung
- MAIN_vUnlockProtecReg();
- GPT12E_KSCCFG=0x0003;
- GPT12E_T2=39062; //timer auf einer sekunde
- GPT12E_T2CON=0x18C7;
- GPT12E_T3=39062; //timer auf einer sekunde
- GPT12E_T3CON=0x18C7;
- //Interruptfreigaben
- GPT12E_T3IC=0x046;
- GPT12E_T2IC=0x046;
- PSW_IEN=1;
- }
- //----------------------unlock definition-------------------------------------------------
- void MAIN_vUnlockProtecReg(void)
- {
- //timerentrigelung notwendig
- unsigned int uwPASSWORD;
- SCU_SLC =0xAAAA;
- SCU_SLC =0x5554;
- uwPASSWORD = SCU_SLS & 0x00FF;
- uwPASSWORD =
- (~uwPASSWORD)& 0x00FF;
- SCU_SLC= 0x9600 |uwPASSWORD;
- SCU_SLC= 0x0000;
- }
- void phase3f (void) interrupt 0x20
- {
- if(phase4==0)
- {
- sekzaehler++;
- GPT12E_T2=39062;
- motor=1;
- heizung=0;
- lcd_curs(0);
- lcd_str("phase3 t2 ");
- if (sekzaehler==10)
- {
- motor=0;
- phase4=1;
- sekzaehler=0;
- lcd_curs(0);
- lcd_str("phase3 t2 voll ");
- }
- }
- }
- void phase4f (void) interrupt 0x21
- {
- if(phase4==1)
- {
- schleudern=1;
- sekzaehler++;
- ablauf=1;
- GPT12E_T3=39062;
- lcd_curs(0);
- lcd_str("phase4 t3 ");
- if (sekzaehler==5)
- {
- ablauf=0;
- lcd_curs(0);
- lcd_str("phase4 t3 ablauf off ");
- }
- if (sekzaehler==10)
- {
- phase4=0;
- ablauf=0;
- schleudern=0;
- sekzaehler=0;
- lcd_curs(0);
- lcd_str("phase4 t3 zeit um schleudern aus");
- }
- }
- }
- void regelung (void)
- {
- //Füllen phase1
- while(pegel1==0&&!phase4)
- {
- zulauf=1;
- lcd_curs(0);
- lcd_str("phase1 füllen ");
- }
- zulauf=0;
- //heizung phase3
- if (phase4==0)
- {
- lcd_curs(0);
- lcd_str("phase3 +heizen ");
- if (sw_temp==0)
- {
- if (grad60==0)
- {
- heizung=1;
- }
- else
- {
- heizung=0;
- }
- }
- else
- {
- if (grad90==0)
- {
- heizung=1;
- }
- else
- {
- heizung=0;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement