Timer
.include "msp430x2xx.inc" org 0xf800start: mov.w #(WDTPW|WDTHOLD),&WDTCTL mov.w #0x280, SP mov.b #255,&P1DIR mov.b #0,&P1OUT mov.w #(TASSEL_2|MC_2|ID_3|TAIE), &TACTL eintgg: jmp ggisr: xor.b #1,&P1OUT ;toggle LED.1 on interrupt bic.w #1, &TACTL ;clearing the TAIFG (flag) reti org 0xfffe ;reset vector dw start org 0xfff0 dw isrPort 1
.msp430; exemple d'utilisation du Bouton poussoir de P1.3 du launchpadDEBUTP equ 0xC000 ; 16kO de EEROMRAM_H equ 0x03FF ; 512 octets de RAMRAL_B equ 0x0200VECRES equ 0xFFFE ; vecteuVECP1I equ 0xFFE4WDTCTL equ 0x0120 ; Watchdog/timer controlWDTPW equ 0x5a00 ; Watchdog POWERWDTHOLD equ 0x0080 ; retenir le watchdogP1DIR equ 0x0022 ; Port P1 directionP1OUT equ 0x0021 ; Port P1 outputP1IN equ 0x0020 ; Port P1 inputP1REN equ 0x0027 ; Port P1 resistor enableP1IE equ 0x0025 ; Port P1 interrupt enableP1IES equ 0x0024 ; Port P1 interrupt edge selectP1IFG equ 0x0023 ; Port P1 interrupt flag; poids des bits de P1P1_0 equ 0x01P1_1 equ 0x02P1_2 equ 0x04P1_3 equ 0x08P1_4 equ 0x10P1_5 equ 0x20P1_6 equ 0x40P1_7 equ 0x80BOUTON equ P1_3LED_R equ P1_0LED_V equ P1_6 .org DEBUTP mov.w #WDTPW|WDTHOLD, &WDTCTL ; on desactive le chien de garde mov.w #0x280,SP;initialisation du port P1.0 bis.b #P1_0, P1DIR ; mise en sortie de P1.0 (LED ROUGE) bic.b #P1_0, P1OUT ; eteindre la led rouge bis.b #P1_6, P1DIR ; LED verte bic.b #P1_6, P1OUT;initialisation du port P1.3 bic.b #P1_3, P1DIR ; mise en entrée de P1.3 (BP) bis.b #P1_3, P1OUT bis.b #P1_3, P1REN ; mise en service de la résistance PULL UP interne bis.b #P1_3, P1IES bis.b #P1_3, P1IE ; autorise l'interruption sur P1.3 bic.b #P1_3, P1IFG ; FLAG P1I.3 de P1.3 a zero eintloop: call #allume_led call #eteint_led jmp loopallume_led: bis.b #LED_R,P1OUT ; on allume la led reteteint_led: bic.b #LED_R,P1OUT ; on eteint la led retinterP1: xor.b #LED_V,P1OUT ;bis.b #LED_V,P1OUT bic.b #P1_3, P1IFG ; FLAG P1I.3 de P1.3 a zero reti; Vecteurs .org VECP1I dw interP1 .org VECRES dw DEBUTP.end.msp430; exemple d'utilisation du Bouton poussoir de P1.3 du launchpadDEBUTP equ 0xC000 ; 16kO de EEROMRAM_H equ 0x03FF ; 512 octets de RAMRAL_B equ 0x0200VECRES equ 0xFFFEVECP1I equ 0xFFE4WDTCTL equ 0x0120 ; Watchdog/timer controlWDTPW equ 0x5a00 ; Watchdog POWERWDTHOLD equ 0x0080 ; retenir le watchdogP1DIR equ 0x0022 ; Port P1 directionP1OUT equ 0x0021 ; Port P1 outputP1IN equ 0x0020 ; Port P1 inputP1REN equ 0x0027 ; Port P1 resistor enableP1IE equ 0x0025 ; Port P1 interrupt enableP1IES equ 0x0024 ; Port P1 interrupt edge selectP1IFG equ 0x0023 ; Port P1 interrupt flag; poids des bits de P1P1_0 equ 0x01P1_1 equ 0x02P1_2 equ 0x04P1_3 equ 0x08P1_4 equ 0x10P1_5 equ 0x20P1_6 equ 0x40P1_7 equ 0x80BOUTON equ P1_3LED_R equ P1_0LED_V equ P1_6 .org DEBUTP mov.w #WDTPW|WDTHOLD, &WDTCTL ; on desactive le chien de garde mov.w #0x280,SP;initialisation du port P1.0 bis.b #P1_0, P1DIR ; mise en sortie de P1.0 (LED ROUGE) bic.b #P1_0, P1OUT ; eteindre la led rouge bis.b #P1_6, P1DIR ; LED verte bic.b #P1_6, P1OUT;initialisation du port P1.3 bic.b #P1_3, P1DIR ; mise en entrée de P1.3 (BP) bis.b #P1_3, P1OUT bis.b #P1_3, P1REN ; mise en service de la résistance PULL UP interne bis.b #P1_3, P1IES bis.b #P1_3, P1IE ; autorise l'interruption sur P1.3 bic.b #P1_3, P1IFG ; FLAG P1I.3 de P1.3 a zero eintloop: call #allume_led call #eteint_led jmp loopallume_led: bis.b #LED_R,P1OUT ; on allume la led reteteint_led: bic.b #LED_R,P1OUT ; on eteint la led retinterP1: xor.b #LED_V,P1OUT ;bis.b #LED_V,P1OUT bic.b #P1_3, P1IFG ; FLAG P1I.3 de P1.3 a zero reti; Vecteurs; .org 0xFFE8; dw interP1 .org VECP1I dw interP1 .org VECRES dw DEBUTP.end