start/stop running
This commit is contained in:
parent
a50a5e2f00
commit
5e982f8926
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <stdbool.h>
|
||||||
#include <msp430g2452.h>
|
#include <msp430g2452.h>
|
||||||
#include <isr_compat.h>
|
#include <isr_compat.h>
|
||||||
|
|
||||||
@ -71,25 +72,30 @@ ISR(TIMER0_A1, TA0_ISR_Comp) {
|
|||||||
__enable_interrupt();
|
__enable_interrupt();
|
||||||
}
|
}
|
||||||
|
|
||||||
ISR(PORT1, PORT1_ISR) {
|
void inverterExec() {
|
||||||
uint16_t p1Ifg = P1IFG;
|
static bool running = false;
|
||||||
if (p1Ifg & BIT3) {
|
|
||||||
// start
|
if (P1IN & BIT3) {
|
||||||
pulseWidthIdx = 0;
|
if (! running) {
|
||||||
TA0CTL = MC_1 | ID_0 | TASSEL_0 | TACLR;
|
// start
|
||||||
} else if (p1Ifg & BIT4) {
|
pulseWidthIdx = 0;
|
||||||
// stop
|
TA0CTL = MC_1 | ID_0 | TASSEL_0 | TACLR;
|
||||||
TA0CTL = MC_0;
|
running = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (running) {
|
||||||
|
// stop
|
||||||
|
TA0CTL = MC_0;
|
||||||
|
running = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void inverterInit() {
|
void inverterInit() {
|
||||||
// start, stop
|
// start, stop
|
||||||
// BIT3: start, BIT4: stop
|
// BIT3: start, BIT4: stop
|
||||||
// P1OUT &= (BIT3 | BIT4);
|
P1OUT &= (BIT3 | BIT4);
|
||||||
// P1DIR &= (BIT3 | BIT4);
|
P1DIR &= (BIT3 | BIT4);
|
||||||
// P1IES = BIT3;
|
|
||||||
// P1IE |= BIT3 | BIT4;
|
|
||||||
|
|
||||||
// bridge direction
|
// bridge direction
|
||||||
P1OUT &= ~BIT2;
|
P1OUT &= ~BIT2;
|
||||||
@ -110,7 +116,8 @@ void inverterInit() {
|
|||||||
P1DIR &= ~BIT0;
|
P1DIR &= ~BIT0;
|
||||||
P1SEL |= BIT0;
|
P1SEL |= BIT0;
|
||||||
|
|
||||||
TA0CTL = TA0CTL = MC_1 | ID_0 | TASSEL_0 | TACLR;
|
//TA0CTL = MC_1 | ID_0 | TASSEL_0 | TACLR;
|
||||||
|
TA0CTL = MC_0;
|
||||||
|
|
||||||
TA0CCTL0 = CCIE | OUTMOD_4;
|
TA0CCTL0 = CCIE | OUTMOD_4;
|
||||||
TA0CCTL1 = CCIE;
|
TA0CCTL1 = CCIE;
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
void inverterInit();
|
void inverterInit();
|
||||||
|
void inverterExec();
|
||||||
void inverterSetFrequency(uint16_t f);
|
void inverterSetFrequency(uint16_t f);
|
||||||
|
|
||||||
#endif /* INVERTER_H_ */
|
#endif /* INVERTER_H_ */
|
||||||
|
@ -31,6 +31,7 @@ int main() {
|
|||||||
inverterSetFrequency(50);
|
inverterSetFrequency(50);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
inverterExec();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user