Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;-------------------------------------------------------------------------------
- ; MSP430 Assembler Code Template for use with TI Code Composer Studio
- ;
- ;
- ;-------------------------------------------------------------------------------
- .cdecls C,LIST,"msp430.h" ; Include device header file
- ;-------------------------------------------------------------------------------
- .text ; Assemble into program memory
- .retain ; Override ELF conditional linking
- ; and retain current section
- .retainrefs ; Additionally retain any sections
- ; that have references to current
- ; section
- ;-------------------------------------------------------------------------------
- RESET mov.w #__STACK_END,SP ; Initialize stackpointer
- StopWDT mov.w #WDTPW|WDTHOLD,&WDTCTL ; Stop watchdog timer
- ;-------------------------------------------------------------------------------
- ; Main loop here
- ;-------------------------------------------------------------------------------
- mainloop
- mov.b #0xFF, &P1DIR ; all P1 pins set to output
- mov.b #0x01, R15 ; define initial value for counter as 1
- call #count
- count:
- loop mov.b R15, &P1OUT ; counter LED output
- call #delay
- cmp.b #0x63, R15 ; if counter hits 99 (01100011)
- ; reset counter to 0
- ; else keep counting
- jz rst
- inc.b R15
- jmp loop
- rst
- mov.b #0x00, R15
- jmp loop
- ret
- delay: ; Delay routine of about 0.7s
- mov.w #00004h, R11
- loop_a mov.w #0D901h, R10
- loop_b dec.w R10
- jnz loop_b
- dec.w R11
- jnz loop_a
- ret
- ;-------------------------------------------------------------------------------
- ; Stack Pointer definition
- ;-------------------------------------------------------------------------------
- .global __STACK_END
- .sect .stack
- ;-------------------------------------------------------------------------------
- ; Interrupt Vectors
- ;-------------------------------------------------------------------------------
- .sect ".reset" ; MSP430 RESET Vector
- .short RESET
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement