Solve the following problems using the MSP430 IAR Compiler/Assembler . Setup the
ID: 3875377 • Letter: S
Question
Solve the following problems using the MSP430 IAR Compiler/Assembler.
Setup the MSP430 LaunchPad to use Timer A to toggle the red LED each time the timer counts to 50,000. You should be able to do this using:
A- An assembly language program that calls a subroutine to configure Timer to toggle the LED every 50,000 cycles.
B- An assembly language program that sets up an interrupt from Timer A every 50,000 cycles.
C- Repeat the above part B but this time develop a mixed language program that calls the assembly language subroutines from the C language.
Additional requirements:
- For the above problems that combine C and assembly, the input data should be declared in the C portion of the program.
- For the above problems that only use assembly language, the input data should be stored in RAM.
- Code needed to test each problem should be included.
Explanation / Answer
STATUS equ 03h ;Address of the STATUS register
TRISA equ 85h ;Address of the tristate register for port A
PORTA equ 05h ;Address of Port A
COUNT1 equ 08h ;First counter for our delay loops
COUNT2 equ 09h ;Second counter for our delay loops
;****Set up the port****
bsf STATUS,5 ;Switch to Bank 1
movlw 00h ;Set the Port A pins
movwf TRISA ;to output
bcf STATUS,5 ;Switch back to Bank 0
;****Turn the LED on****
Start movlw 02h ;Turn the LED on by first putting it
movwf PORTA ;into the w register and then on the port
;****Add a delay
call Delay
;****Delay finished, now turn the LED off****
movlw 00h ;Turn the LED off by first putting it
movwf PORTA ;into the w register and then on the port
;****Add another delay****
call Delay
;****Now go back to the start of the program
goto Start ;go back to Start and turn LED on again
;****Here is our Subroutine
Delay
Loop1 decfsz COUNT1,1 ;This second loop keeps the LED
goto Loop1 ;turned off long enough for us to
decfsz COUNT2,1 ;see it turned off
goto Loop1 ;
return
;****End of the program****
end ;Needed by some compilers, and also
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.