Question

In: Electrical Engineering

For the mspfr6989 write program #2 1(b) Write a program that will make LED1 blink 5...

For the mspfr6989 write program #2

1(b) Write a program that will make LED1 blink 5 times when S1 is pressed, and then stop.

Program #2 – Using both S1 and S2 1 Write a program like 1(b) above, but the LED1 will blink until S2 is pressed. 2 Write a program that simulates a motor coming up to speed. When S1 is pressed, LED1 blinks at 50% duty cycle for 10 cycles (indicating a motor coming up to speed). After that time, LED2 comes on (indicating the motor is at speed), and can be turned off by pressing S2. 3 Create a flexible program for 2(b) that will reverse the operation of the LEDs if S2 is pressed first (LED2 shows ramp-up, and LED1 shows motor at full speed). Must use functions to control all timing, LED access, etc… Main program should just have loops and function calls.

Solutions

Expert Solution


;blink_led.asm
list P = 16F877A
include P16F877A.inc

STATUS EQU 0x03
PORTB EQU 0x06
TRISB EQU 0x86
PORTD EQU 0x08
TRISD EQU 0x88
CBLOCK 0x20
Kount120us ;Delay count (number of instr cycles for Delay)
Kount100us
Kount1ms
Kount10ms
Kount1s
Kount10s
Kount1m
ENDC

org 0x0000 ;line 1
goto START ;line 2 ($0000)
org 0x05
START
banksel TRISD
movlw 0x00
movwf TRISD
movwf TRISB
banksel PORTB
clrf PORTB
clrf PORTD
call Delay100ms
repeat movlw 0xFF
movwf PORTB
Call Delay1s
movlw 0x00
movwf PORTB
Call Delay1s
goto repeat
;==========================================================
;DELAY SUBROUTINES
Delay120us
banksel Kount120us
movlw H'C5' ;D'197'
movwf Kount120us
R120us
decfsz Kount120us
goto R120us
return
;
Delay100us
banksel Kount100us
movlw H'A4'
movwf Kount100us
R100us
decfsz Kount100us
goto R100us
return
;
;1ms Delay
Delay1ms
banksel Kount1ms
movlw 0x0A ;10
movwf Kount1ms
R1ms
call Delay100us
decfsz Kount1ms
goto R1ms
return
;
;10ms Delay
; call 100 times of 100 us Delay (with some time discrepancy)
Delay10ms
banksel Kount10ms
movlw H'64' ;100
movwf Kount10ms
R10ms
call Delay100us
decfsz Kount10ms
goto R10ms
return
;;
;1 sec Delay
;call 100 times of 10ms Delay
Delay1s
banksel Kount1s
movlw H'64'
movwf Kount1s
R1s
call Delay10ms
decfsz Kount1s
goto R1s
return
;;
;10 s Delay
;call 10 tiems of 1 s Delay
Delay10s
banksel Kount10s
movlw H'0A' ;10
movwf Kount10s
R10s
call Delay1s
decfsz Kount10s
goto R10s
return
;
;1 min Delay
;call 60 times of 1 sec Delay
Delay1m
banksel Kount1m
movlw H'3C' ;60
movwf Kount1m
R1m
call Delay1s
decfsz Kount1m
goto R1m
return
;;
;100 msec Delay
;call 10 times of 10ms Delay
Delay100ms
banksel Kount1s
movlw H'0A' ;10
movwf Kount1s
R100ms
call Delay10ms
decfsz Kount1s
goto R100ms
return
;;
;======================================================
END
;Increase delay at instw and dataw to 100ms and start up to 100ms (2014-1-7)


Related Solutions

Write a program for the msp430 to make led1 and led 2 alternate blinking 2. repeat...
Write a program for the msp430 to make led1 and led 2 alternate blinking 2. repeat the program to make each led blink 5 times in a sequence, then 5 times simultaneously
1.write a program for the msp430 to make led 1 blink at 50 percent duty cycle....
1.write a program for the msp430 to make led 1 blink at 50 percent duty cycle. 2 modify the program to make led 1 blink 5 times, make a long pause, then blink 5 more times then stop. The time delays should be carried out in subroutines
1.write a program for the msp430FR6989 to make led 1 blink at 50 percent duty cycle....
1.write a program for the msp430FR6989 to make led 1 blink at 50 percent duty cycle. 2 modify the program to make led 1 blink 5 times, make a long pause, then blink 5 more times then stop. The time delays should be carried out in subroutines
1. write a program for the msp430fr6989 that will light LED1, whenever S1 is pressed. It...
1. write a program for the msp430fr6989 that will light LED1, whenever S1 is pressed. It should turn off whenever S1 is released. 2. Write a program that will make LED1 blink 5 times when S1 is pressed, and then stop.
Write a C program to blink two LEDs connected to Raspberry pi. One must blink at...
Write a C program to blink two LEDs connected to Raspberry pi. One must blink at a rate of 1 Hz and the other at a rate of 2 HZ.
using code composer studio 1. write a program for the msp430fr6989 that will light LED1, whenever...
using code composer studio 1. write a program for the msp430fr6989 that will light LED1, whenever S1 is pressed. It should turn off whenever S1 is released. 2. Write a program that will make LED1 blink 5 times when S1 is pressed, and then stop.
Make a C program to blink/toggle a LED every second with the Atmega128 chip. Hint: Because...
Make a C program to blink/toggle a LED every second with the Atmega128 chip. Hint: Because the delay function has a maximum delay limit, you will need an internal counter to accumulate delays to one second. a) Write code that uses the timer interrupt for implementation. b) Write code that uses stopwatch on the second toggle in Atmel Studio
Make a C program to blink/toggle a LED every second with the Atmega128 chip. Hint: Because...
Make a C program to blink/toggle a LED every second with the Atmega128 chip. Hint: Because the delay function has a maximum delay limit, you will need an internal counter to accumulate delays to one second. a) Write code that uses the delay function for implementation b) Write code that uses a stopwatch on the third toggle
1. IN C LANGUAGE: Write a code that makes the MSP430 blink the red LED and...
1. IN C LANGUAGE: Write a code that makes the MSP430 blink the red LED and the green LED at the same time. The two LEDs should be on at the same time and then off at the same time
1. Write a code that makes the MSP430 blink the red LED and the green LED...
1. Write a code that makes the MSP430 blink the red LED and the green LED at the same time. The two LEDs should be on at the same time and then off at the same time
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT