Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "msp430.h"                     ; #define controlled include file
  2.  
  3.         NAME    main                    ; module name
  4.  
  5.         PUBLIC  main                    ; make the main label vissible
  6.                                         ; outside this module
  7.         ORG     0FFFEh
  8.         DC16    init                    ; set reset vector to 'init' label
  9.  
  10.         RSEG    CSTACK                  ; pre-declaration of segment
  11.         RSEG    CODE                    ; place program in 'CODE' segment
  12.  
  13. init:   MOV     #SFE(CSTACK), SP        ; set up stack
  14.         MOV.W   #1, R4
  15.         MOV.B   #0x00, P1SEL
  16.         MOV.B   #00000000b, P1DIR
  17.         MOV.W   #0xFFFF, R7
  18.         MOV.W   #WDTPW+WDTHOLD,&WDTCTL  ; Stop watchdog timer
  19.  
  20.  
  21. ;R4 is the input register, R5 is the size counter for the input
  22. ;R6 is the counter for longpress
  23. main:                                  ; main program
  24.         MOV.B   P1IN, R8
  25.         CLRC
  26.         CMP.W   #100000000b, R4
  27.         JC     setoutput
  28.         CLRC
  29.         CMP.B   #0, P1IN
  30.         JZ     getinput0
  31.         JMP main
  32.         JMP $                           ; jump to current location '$'
  33.                                         ; (endless loop)
  34.  
  35. setoutput:
  36.         MOV.B #0xFF, P1DIR              ;Set direction to output
  37.         MOV.B #0xFF, P1OUT                 ;Send the inputted number to the output
  38.         ;BIS.B #0xFF, P1DIR              ;Set direction to output
  39.         JMP outputloop                  
  40.        
  41. getinput0:
  42.         CLRC
  43.         RLC R4
  44.         MOV.W #0xFFFF, R6
  45.         JMP longpress
  46.        
  47.        
  48. longpress:
  49.         DEC R6
  50.         CLRC
  51.         CMP.W #0, R6
  52.         JZ longpress1
  53.         JMP longpress
  54.        
  55. longpress1:
  56.         CLRC
  57.         CMP.B #0, P1IN
  58.         JZ      _add
  59.         JMP     main
  60.        
  61. _add:
  62.         ADD #1b, R4
  63.         JMP main
  64.  
  65. outputloop:
  66.         JMP $
  67.        
  68. flash:
  69.         MOV.B   #0xFF, P1DIR
  70.         MOV.B   #0xFF, P1OUT
  71.      
  72. wait:
  73.         DEC     R7
  74.         CMP     #0, R7
  75.         ;JNC     getinput
  76.         JMP     wait
  77.        
  78.         END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement