Skip to content

Instantly share code, notes, and snippets.

@blakewrege
Last active August 29, 2015 14:11
Show Gist options
  • Save blakewrege/bd7cd139882d0f052ed7 to your computer and use it in GitHub Desktop.
Save blakewrege/bd7cd139882d0f052ed7 to your computer and use it in GitHub Desktop.
button interrupt broke
#include <msp430.h>
#include <libemb/serial/serial.h>
#include <libemb/conio/conio.h>
#include <libemb/shell/shell.h>
#define push (P1IN&BIT3)
int p1[4] = {
BIT5,BIT6,BIT7,
BIT4+BIT6+BIT7,
BIT4+BIT5+BIT7,
BIT4+BIT5+BIT6 };
int a1[4] = {
BIT4,
BIT5,
BIT6,
BIT7,
};
int p2[10]={
BIT2+BIT1+BIT3+BIT4+BIT5+BIT6, //0
BIT1+BIT5, //1
BIT2+BIT1+BIT7+BIT3+BIT4, //2
BIT2+BIT1+BIT7+BIT5+BIT4, //3
BIT6+BIT7+BIT5+BIT1, //4
BIT2+BIT6+BIT7+BIT5+BIT4, //5
BIT2+BIT6+BIT7+BIT5+BIT4+BIT3, //6
BIT2+BIT1+BIT5, //7
BIT2+BIT1+BIT3+BIT4+BIT5+BIT6+BIT7, //8
BIT2+BIT1+BIT5+BIT7+BIT6 //9
};
int counter[4]= {
0,
0,
0,
0
};
int v=0;
int n=1;
int w=0;
int k=0;
unsigned int ii;
unsigned int i;
int main(void) {
WDTCTL = WDTPW | WDTHOLD; //
BCSCTL1 = CALBC1_1MHZ; // the usual
DCOCTL = CALDCO_1MHZ; //
P1DIR = ~BIT3; // 1111 0111: all outputs except P1.3
P1REN =BIT3;
P1IE |=BIT3;
P1IES |=BIT3;
P1IFG &= ~BIT3;
P1OUT |=BIT3;
P1OUT = 0b00001000; // ____ 1000: P1.7 thru P1.4 select bubble
P2SEL &= ~(BIT6 | BIT7); // XIN & XOUT as outputs
P2DIR = -1; // P2.1 thru P2.7 turn on segments
P2OUT = BIT0; // all segments on
TA1CCTL0 = CCIE; //We'd use OUTMOD_x for PWM waves, but we just need it to fire an interrupt
TA1CCR0 = 1000;//500;
TA1CTL = TASSEL_2 | MC_1 | ID_1;
serial_init(9600);
cio_printf("\n\r| ");
_BIS_SR(LPM4_bits | GIE);
for(;;){}
}
#pragma vector=PORT1_VECTOR
__interrupt void Port_1(void)
{
P1OUT ^= BIT0;
while (!(BIT3 & P1IN)) {
__delay_cycles(100000000);
return 0;
}
P1IFG &= ~BIT3;
}
#pragma vector=TIMER1_A0_VECTOR // TA1 CCR0 Interrupt
__interrupt void Timer1_A0 (void)
{
v=v+1;
w=w+1;
k=k+1;
P1OUT = p1[k];
P1OUT ^= 0;
P1OUT |= BIT3;
P2OUT = p2[w];
P2OUT ^= ~BIT0;
cio_printf("%u ",v);
__delay_cycles(35000);
if(k < 2){
k = k-3;
if(w < 9){
w = w-9;
__delay_cycles(3000000);
if(v < 1){
v = v-1;
P1OUT ^= BIT0;
__delay_cycles(300000);
cio_printf("|\n\r | ");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment