Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. ;-------------------------------------------------------------------------------
  2. ; MSP430 Assembler Code Template for use with TI Code Composer Studio
  3. ;
  4. ;
  5. ;-------------------------------------------------------------------------------
  6. .cdecls C,LIST,"msp430.h" ; Include device header file
  7. ;-------------------------------------------------------------------------------
  8. .text ; Assemble into program memory
  9. .retain ; Override ELF conditional linking
  10. ; and retain current section
  11. .retainrefs ; Additionally retain any sections
  12. ; that have references to current
  13. ; section
  14.  
  15. ;-------------------------------------------------------------------------------
  16. RESET mov.w #__STACK_END,SP ; Initialize stackpointer
  17. StopWDT mov.w #WDTPW|WDTHOLD,&WDTCTL ; Stop watchdog timer
  18.  
  19. ;-------------------------------------------------------------------------------
  20. ; Main loop here
  21. ;-------------------------------------------------------------------------------
  22.  
  23. mainloop
  24. mov.b #0xFF, &P1DIR ; all P1 pins set to output
  25. mov.b #0x01, R15 ; define initial value for counter as 1
  26. call #count
  27. count:
  28. loop mov.b R15, &P1OUT ; counter LED output
  29. call #delay
  30. cmp.b #0x63, R15 ; if counter hits 99 (01100011)
  31. ; reset counter to 0
  32. ; else keep counting
  33. jz rst
  34. inc.b R15
  35. jmp loop
  36. rst
  37. mov.b #0x00, R15
  38. jmp loop
  39. ret
  40. delay: ; Delay routine of about 0.7s
  41. mov.w #00004h, R11
  42. loop_a mov.w #0D901h, R10
  43. loop_b dec.w R10
  44. jnz loop_b
  45. dec.w R11
  46. jnz loop_a
  47. ret
  48.  
  49. ;-------------------------------------------------------------------------------
  50. ; Stack Pointer definition
  51. ;-------------------------------------------------------------------------------
  52. .global __STACK_END
  53. .sect .stack
  54.  
  55. ;-------------------------------------------------------------------------------
  56. ; Interrupt Vectors
  57. ;-------------------------------------------------------------------------------
  58. .sect ".reset" ; MSP430 RESET Vector
  59. .short RESET
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement