Quantcast
Channel: MSP low-power microcontrollers
Viewing all articles
Browse latest Browse all 64959

Forum Post: RE: MSP430 Interrupt

$
0
0
#include void main( void ) { WDTCTL = (WDTPW | WDTHOLD); // Stop watchdog timer BCSCTL1 = CALBC1_1MHZ; // Set DCO range DCOCTL = CALDCO_1MHZ; // Set DCO step and modulation P1DIR = 0x04 + BIT1+ BIT6; // Set P1.2 to output-direction//Bit1 = g , Bit6 = f P1REN = (0x08 | 0x10 | 0x20); // Enable resistors at P1.3/4/5 P1OUT = (0x08 | 0x10 | 0x20 | BIT1 | BIT6 ); // Pull-up resistors at P1.3/4/5 P2DIR = (BIT1 | BIT2 | BIT3 | BIT4 | BIT5); //Bit1 = a , Bit2 = d , Bit3 = e , Bit4 = c , Bit5 = b) P2OUT = (BIT1 | BIT2 | BIT3 | BIT4 | BIT5); P1IE = (0x08 | 0x10 | 0x20); P1IES = (0x08 | 0x10 | 0x20); P1IFG = (0x08 | 0x10 | 0x20); P1SEL = 0x04; // Set selection register 1 for timer-function TA0CCTL1 = OUTMOD_7; // Reset/set TA0CCR0 = 20000; // Period TA0CCR1 = 1500; // Duty-cycle TA0CTL = (TASSEL_2 | MC_1); // SMCLK, timer in up-mode _BIS_SR(GIE); while( 1 ) // Endless-loop (main-program) {} } #pragma vector=PORT1_VECTOR __interrupt void P1_ISR(void) { if( (P1IFG & 0x08) ) // Button at P1.3 pressed (S2 on LaunchPad) { TA0CCR1 = 1000; // Servo in middle position (1.5ms) P2OUT ^= ~(BIT1 | BIT2 | BIT3 | BIT4 | BIT5); P1OUT ^= ~(BIT6+BIT1); P1OUT ^= BIT6; P2OUT ^= (BIT1+BIT2+BIT3+BIT5+BIT4); P1IES ^= BIT3; } else if( (P1IFG & 0x10) ) // Button at P1.4 pressed { TA0CCR1 = 1500; // Servo in minimum position (1.0ms) P2OUT ^= ~(BIT1 | BIT2 | BIT3 | BIT4 | BIT5); P1OUT ^= ~(BIT6+BIT1); P2OUT ^= (BIT1+BIT4); P1IES ^= BIT4; } else if( (P1IFG & 0x20) ) // Button at P1.5 pressed { TA0CCR1 = 2000; // Servo in maximum position (2.0ms) P2OUT ^= ~(BIT1 | BIT2 | BIT3 | BIT4 | BIT5); P1OUT ^= ~(BIT6+BIT1); P1OUT ^= BIT1; P2OUT ^= (BIT1+BIT2+BIT3+BIT5); P1IES ^= BIT5; } P1IFG &= ~(0x08 | 0x10 | 0x20); } So I am continue to make my 3 floor lift with interrupts and 7 segment display thanks to you guys I manage to make it work without segment display. But when I added the segment display its not working properly.(The numbers are not shows up right and when I press the P1.3, P1.5 wont work unless I press P1.4)And another problem is its not show the current level only shows when I continue to press it.

Viewing all articles
Browse latest Browse all 64959

Latest Images

Trending Articles



Latest Images