-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtimer.c
87 lines (82 loc) · 3.16 KB
/
timer.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#include <msp430.h>
#include "motor.h"
extern tick, count, direction; // define for global
//NOTE check this
void timer_A1_setup(void){
//setup timer A
TA3CTL |= TASSEL__ACLK | ID_0 | TACLR; // use ACLK assuming 32 KHz
TA3CCTL0=CCIE;
}
void Timer_A1_ISR(void)__interrupt[TIMER3_A0_VECTOR]{
//switch(TA3IV){
// case TA3IV_TA3CCR1: // change motor pole state
P1OUT ^= BIT0; // TEST INTERRUPT FREQ
if(direction == 'F'){
switch (tick){
case one:
PosOne();
tick++; // increment tick <-- global for motor position
P7OUT ^= 0xFF; // just cuz i like lights
//TA3CCR1 = TA3CCR1 + count; // set capture for next tick
P1OUT ^= BIT0;
break;
case two:
PosTwo();
tick++; // increment tick <-- global for motor position
P7OUT ^= 0xFF; // just cuz i like lights
//TA3CCR1 = TA3CCR1 + count; // set capture for next tick
P1OUT ^= BIT0;
break;
case three:
PosThree();
tick++; // increment tick <-- global for motor position
P7OUT ^= 0xFF; // just cuz i like lights
// TA3CCR1 = TA3CCR1 + count; // set capture for next tick
P1OUT ^= BIT0;
break;
case four:
PosFour();
tick = 0; // increment tick <-- global for motor position
P7OUT ^= 0xFF; // just cuz i like lights
//TA3CCR1 = TA3CCR1 + count; // set capture for next tick
P1OUT ^= BIT0;
break;
default:
break;
}
}
else{
switch (tick){
case one:
PosFour();
tick++; // increment tick <-- global for motor position
P7OUT ^= 0xFF; // just cuz i like lights
//TA3CCR1 = TA3CCR1 + count; // set capture for next tick
P1OUT ^= BIT0;
break;
case two:
PosThree();
tick++; // increment tick <-- global for motor position
P7OUT ^= 0xFF; // just cuz i like lights
//TA3CCR1 = TA3CCR1 + count; // set capture for next tick
P1OUT ^= BIT0;
break;
case three:
PosTwo();
tick++; // increment tick <-- global for motor position
P7OUT ^= 0xFF; // just cuz i like lights
// TA3CCR1 = TA3CCR1 + count; // set capture for next tick
P1OUT ^= BIT0;
break;
case four:
PosOne();
tick = 0; // increment tick <-- global for motor position
P7OUT ^= 0xFF; // just cuz i like lights
//TA3CCR1 = TA3CCR1 + count; // set capture for next tick
P1OUT ^= BIT0;
break;
default:
break;
}
}
}