-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCONTRAPTION_2k15.c
71 lines (59 loc) · 1.39 KB
/
CONTRAPTION_2k15.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include <msp430g2553.h>
#define INTP1 BIT1
#define INTP2 BIT2
#define INTP3 BIT3
#define OUT1 BIT0
#define OUT2 BIT6
#define OUT3 BIT0
void main()
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
BCSCTL1 = CALBC1_1MHZ; // Set DCO to 1MHz
DCOCTL = CALDCO_1MHZ;
P1DIR = OUT1+OUT2+OUT3;
P1OUT=0;
P2DIR &=~(INTP1 + INTP2+INTP3);
P2IE |= (INTP1 + INTP2+INTP3);
P2IES &= ~(INTP1 + INTP2+INTP3);
P2REN|= (INTP1 + INTP2+INTP3);
P2IFG =0;
P2OUT&=~(INTP1 + INTP2+INTP3);
_enable_interrupt();
while(1)
{
_bis_SR_register(GIE+LPM0_bits);
}
}
#pragma vector=PORT2_VECTOR
__interrupt void Port_2(void)
{
int i;
// _delay_cycles(300);
if(P2IFG&BIT1) //WATER_PUMP
{
for(i=3000;i>0;i--)
_delay_cycles(1000);
P1OUT = OUT2;
for(i=10000;i>0;i--)
_delay_cycles(2000);
}
else if(P2IFG&BIT2) //BLOWER
{
for(i=3000;i>0;i--)
_delay_cycles(1000);
P1OUT = OUT2;
for(i=5000;i>0;i--)
_delay_cycles(1000);
}
else if(P2IFG&BIT3) //LIFT
{
for(i=2000;i>0;i--)
_delay_cycles(1000);
P1OUT = OUT3;
for(i=10000;i>0;i--)
_delay_cycles(1000);
}
_bic_SR_register_on_exit(LPM0_bits);
P1OUT = 0;
P2IFG = 0; // Clear P2IFG
}