M
maha384
Guest
Denne kodeks fungerer ikke, når jeg aktivere WDT.Og jeg ved ikke, problemet eller SÅDAN GØR vagthund TIMER ARBEJDE.# define AC PORTA.F1
# define VALVE PORTA.F2
# define STARTER PORTA.F3
# define INPUT PORTB.F3
# define ALARM PORTB.F7
# define RESET PORTB.F6
# define forsinkelse 1000
# define startup_prd 5
# define wait_prd 10
# define noload_prd 20
void Main (void)
(
usignerede CHAR n, x;
TMR0 = 0x00;
OPTION_REG = 0x0f;
TRISA = 0X02;
TRISB = 0x48;
VALVE = 0;
STARTER = 0;
ALARM = 0;
standby:
ASM (CLRWDT);
VALVE = 0;
STARTER = 0;
delay_ms (forsinkelse);
if (INPUT == 1) (goto standby
else (goto start
start:
ALARM = 0;
delay_ms (forsinkelse);
for (n = 0; n <3 n )
(
delay_ms (forsinkelse);
if (INPUT == 1) goto standby;
VALVE = 1;
STARTER = 1;
for (x = 0; x <startup_prd; x )
(
DELAY_MS (forsinkelse);
/ / ASM (CLRWDT);
if (INPUT == 1) goto standby;
if (AC == 0) (STARTER = 0; goto normal
) ASM (CLRWDT);
VALVE = 0;
STARTER = 0;
if (n == 2) (ALARM = 1; goto alarm
delay_ms (forsinkelse);
if (INPUT == 1) goto standby;
for (x = 0; x <wait_prd; x )
(
delay_ms (forsinkelse);
ASM (CLRWDT);
)
if (INPUT == 1) goto standby;
)
normal:
ASM (CLRWDT);
if (AC == 1) (ALARM = 1; VALVE = 0; goto alarm
delay_ms (forsinkelse);
if (INPUT == 0) goto normal;
if (INPUT == 1) goto noload;
goto normal;
alarm:
ASM (CLRWDT);
delay_ms (forsinkelse);
if (RESET == 0) (ALARM = 0; goto standby
goto alarm;
noload:
for (n = 0; n <noload_prd; n )
(
delay_ms (forsinkelse);
ASM (CLRWDT;
)
if (INPUT == 0) goto normal;
VALVE = 0;
goto standby;
)
# define VALVE PORTA.F2
# define STARTER PORTA.F3
# define INPUT PORTB.F3
# define ALARM PORTB.F7
# define RESET PORTB.F6
# define forsinkelse 1000
# define startup_prd 5
# define wait_prd 10
# define noload_prd 20
void Main (void)
(
usignerede CHAR n, x;
TMR0 = 0x00;
OPTION_REG = 0x0f;
TRISA = 0X02;
TRISB = 0x48;
VALVE = 0;
STARTER = 0;
ALARM = 0;
standby:
ASM (CLRWDT);
VALVE = 0;
STARTER = 0;
delay_ms (forsinkelse);
if (INPUT == 1) (goto standby
else (goto start
start:
ALARM = 0;
delay_ms (forsinkelse);
for (n = 0; n <3 n )
(
delay_ms (forsinkelse);
if (INPUT == 1) goto standby;
VALVE = 1;
STARTER = 1;
for (x = 0; x <startup_prd; x )
(
DELAY_MS (forsinkelse);
/ / ASM (CLRWDT);
if (INPUT == 1) goto standby;
if (AC == 0) (STARTER = 0; goto normal
) ASM (CLRWDT);
VALVE = 0;
STARTER = 0;
if (n == 2) (ALARM = 1; goto alarm
delay_ms (forsinkelse);
if (INPUT == 1) goto standby;
for (x = 0; x <wait_prd; x )
(
delay_ms (forsinkelse);
ASM (CLRWDT);
)
if (INPUT == 1) goto standby;
)
normal:
ASM (CLRWDT);
if (AC == 1) (ALARM = 1; VALVE = 0; goto alarm
delay_ms (forsinkelse);
if (INPUT == 0) goto normal;
if (INPUT == 1) goto noload;
goto normal;
alarm:
ASM (CLRWDT);
delay_ms (forsinkelse);
if (RESET == 0) (ALARM = 0; goto standby
goto alarm;
noload:
for (n = 0; n <noload_prd; n )
(
delay_ms (forsinkelse);
ASM (CLRWDT;
)
if (INPUT == 0) goto normal;
VALVE = 0;
goto standby;
)