Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "msp430.h" ; #define controlled include file
- NAME main ; module name
- PUBLIC main ; make the main label vissible
- ; outside this module
- ORG 0FFFEh
- DC16 init ; set reset vector to 'init' label
- RSEG CSTACK ; pre-declaration of segment
- RSEG CODE ; place program in 'CODE' segment
- init: MOV #SFE(CSTACK), SP ; set up stack
- MOV.W #1, R4
- MOV.B #0x00, P1SEL
- MOV.B #00000000b, P1DIR
- MOV.W #0xFFFF, R7
- MOV.W #WDTPW+WDTHOLD,&WDTCTL ; Stop watchdog timer
- ;R4 is the input register, R5 is the size counter for the input
- ;R6 is the counter for longpress
- main: ; main program
- MOV.B P1IN, R8
- CLRC
- CMP.W #100000000b, R4
- JC setoutput
- CLRC
- CMP.B #0, P1IN
- JZ getinput0
- JMP main
- JMP $ ; jump to current location '$'
- ; (endless loop)
- setoutput:
- MOV.B #0xFF, P1DIR ;Set direction to output
- MOV.B #0xFF, P1OUT ;Send the inputted number to the output
- ;BIS.B #0xFF, P1DIR ;Set direction to output
- JMP outputloop
- getinput0:
- CLRC
- RLC R4
- MOV.W #0xFFFF, R6
- JMP longpress
- longpress:
- DEC R6
- CLRC
- CMP.W #0, R6
- JZ longpress1
- JMP longpress
- longpress1:
- CLRC
- CMP.B #0, P1IN
- JZ _add
- JMP main
- _add:
- ADD #1b, R4
- JMP main
- outputloop:
- JMP $
- flash:
- MOV.B #0xFF, P1DIR
- MOV.B #0xFF, P1OUT
- wait:
- DEC R7
- CMP #0, R7
- ;JNC getinput
- JMP wait
- END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement