MSP430-assembly language part-1.1-Interrupt & Pull up/down

Photo of author

By Jackson Taylor

Digital input with INTERNAL PULL DOWN in “P1.4”
      .include “msp430g2x31.inc”
      org 0xf800                           
      mov.w #(WDTPW|WDTHOLD), &WDTCTL
      mov.b #0x10, P1REN
      CLR.B P1OUT
      CLR R5  
      mov.b #0x1, &P1DIR 
L1:   MOV.b &P1IN,  r5
      AND.b #0x10,r5
      tst r5
      JZ L1
      mov.b #0x41, &P1OUT     
L3:   jmp L3
      org 0xfffe
      dw 0xf800
External interrupt at port 1
Basic Steps
1)Enable global interrupt(eint)
2)Enable external interrupt (on p1.4–P1IE  )
3)select interrupt edge (IP1IES)
4)clear P1IFG flag starting the program
5)clear P1IFG flag in your interrupt service routine
.include “msp430g2x31.inc”
      org 0xf800                 
      mov.w #(WDTPW|WDTHOLD), &WDTCTL
      mov.w #0x280, SP
      mov.b #0x10, P1REN
      CLR.B P1OUT
      mov.b   #001h,&P1DIR           
      bis.b   #010h,&P1IE        ;enable interrupt on p1.4   
      bis.b   #010h,&P1IES       ;select -ve edge
      bic.b   #010h,&P1IFG       ;clear interuupt flag       
      eint ;enables interrup
      gg:jmp gg   
P1ISR:    mov.b   #001h,&P1OUT          
          bic.b   #010h,&P1IFG           
          reti                          
          ORG     0FFE4h                 
          DW      P1ISR    
          ORG     0FFFEh                 
          DW      0xf800
LONG DELAY LOOP
.INCLUDE “msp430x2xx.inc”
 ORG 0xf800        
 MOV #(WDTPW|WDTHOLD), &WDTCTL
 MOV #0x280,SP
 MOV.B #0x41, &P1DIR
 MOV.B #0x41, &P1OUT
LOOP1:
 MOV #65000,R4
 MOV #65000,R5
 CALL #LOOP2
 JMP LOOP1
LOOP2:
 DEC R4
 TST R4
 JNZ LOOP2
LOOP3:
 DEC R5 
 TST R5
 JNZ LOOP3
 XOR.B #0x41,&P1OUT
 RET
 ORG 0xfffe DW 0xF800
LED BLINKING USING BIT INSTRUCTION
.INCLUDE “msp430x2xx.inc”
 ORG 0xf800        
 MOV #(WDTPW|WDTHOLD), &WDTCTL
 MOV #0x280,SP
 MOV.B #0x41, &P1DIR
 MOV.B #0, &P1OUT
LOOP2:
 MOV #65000,R4
 CALL #LOOP1
 JMP LOOP2
LOOP1:
 DEC R4
 BIT #0xFFFE,R4   ;SIMPLY “AND”S BETWEEN SRC & DST.
                                 ;RESULT WILL NOT AFFECT SRC & DST.
                                  ;USED FOR BIT TESTING
 JNZ LOOP1
 XOR.B #0x41,&P1OUT
 RET
 ORG 0xfffe
  DW 0xF800
Next Timer
http://jimmyjosep.blogspot.in/2013/12/msp430-assembly-language-part-2.html
for More examples visit 
http://www.mikekohn.net/micro/naken_asm.php
Basic Steps
1)Enable global interrupt(eint)
2)Enable external interrupt (on p1.4–P1IE  )
3)select interrupt edge (IP1IES)
4)clear P1IFG flag starting the program
5)clear P1IFG flag in your interrupt service routine
.include “msp430g2x31.inc”
      org 0xf800                 
      mov.w #(WDTPW|WDTHOLD), &WDTCTL
      mov.w #0x280, SP
      mov.b #0x10, P1REN
      CLR.B P1OUT
      mov.b   #001h,&P1DIR           
      bis.b   #010h,&P1IE        ;enable interrupt on p1.4   
      bis.b   #010h,&P1IES       ;select -ve edge
      bic.b   #010h,&P1IFG       ;clear interuupt flag       
      eint ;enables interrup
      gg:jmp gg   
P1ISR:    mov.b   #001h,&P1OUT          
          bic.b   #010h,&P1IFG           
          reti                          
          ORG     0FFE4h                 
          DW      P1ISR    
          ORG     0FFFEh                 
          DW      0xf800
LONG DELAY LOOP
.INCLUDE “msp430x2xx.inc”
 ORG 0xf800        
 MOV #(WDTPW|WDTHOLD), &WDTCTL
 MOV #0x280,SP
 MOV.B #0x41, &P1DIR
 MOV.B #0x41, &P1OUT
LOOP1:
 MOV #65000,R4
 MOV #65000,R5
 CALL #LOOP2
 JMP LOOP1
LOOP2:
 DEC R4
 TST R4
 JNZ LOOP2
LOOP3:
 DEC R5 
 TST R5
 JNZ LOOP3
 XOR.B #0x41,&P1OUT
 RET
 ORG 0xfffe DW 0xF800
LED BLINKING USING BIT INSTRUCTION
.INCLUDE “msp430x2xx.inc”
 ORG 0xf800        
 MOV #(WDTPW|WDTHOLD), &WDTCTL
 MOV #0x280,SP
 MOV.B #0x41, &P1DIR
 MOV.B #0, &P1OUT
LOOP2:
 MOV #65000,R4
 CALL #LOOP1
 JMP LOOP2
LOOP1:
 DEC R4
 BIT #0xFFFE,R4   ;SIMPLY “AND”S BETWEEN SRC & DST.
                                 ;RESULT WILL NOT AFFECT SRC & DST.
                                  ;USED FOR BIT TESTING
 JNZ LOOP1
 XOR.B #0x41,&P1OUT
 RET
 ORG 0xfffe
  DW 0xF800
Next Timer
http://jimmyjosep.blogspot.in/2013/12/msp430-assembly-language-part-2.html
for More examples visit 
http://www.mikekohn.net/micro/naken_asm.php
http://jimmyjosep.blogspot.in/2013/12/msp430-assembly-language-part-2.html
for More examples visit 
http://www.mikekohn.net/micro/naken_asm.php
http://jimmyjosep.blogspot.in/2013/12/msp430-assembly-language-part-2.html
for More examples visit 
http://www.mikekohn.net/micro/naken_asm.php
http://jimmyjosep.blogspot.in/2013/12/msp430-assembly-language-part-2.html
for More examples visit 
http://www.mikekohn.net/micro/naken_asm.php
http://jimmyjosep.blogspot.in/2013/12/msp430-assembly-language-part-2.html
for More examples visit 
http://www.mikekohn.net/micro/naken_asm.php
http://jimmyjosep.blogspot.in/2013/12/msp430-assembly-language-part-2.html
for More examples visit 
http://www.mikekohn.net/micro/naken_asm.php
http://jimmyjosep.blogspot.in/2013/12/msp430-assembly-language-part-2.html
for More examples visit 
http://www.mikekohn.net/micro/naken_asm.php
http://jimmyjosep.blogspot.in/2013/12/msp430-assembly-language-part-2.html
for More examples visit 
http://www.mikekohn.net/micro/naken_asm.php