In a product line, there are three sensors “W,” “H,” and \"L\" for controlling t
ID: 2085097 • Letter: I
Question
In a product line, there are three sensors “W,” “H,” and "L" for controlling the width, height and the length of a product. If one of the dimensions of the product is greater than a specified value (out of range), the sensors can detect it.
The sensors “W”, “H”, and "L" send two digital signals (0 = ok or 1= out of range) to a microcontroller MSP430G2553. There is a "Red" lamp, indicating that for two consecutive products at least one of the dimensions has been out of range (Cnd.).
There is also a Push button for resetting the Red lamp.
Configure the GPIO in MSP430G2553 based on the following inputs and outputsInputs
Sensor H: p1.0
Sensor W: p1.1
Sensor L: p1.2
Reset: P1.3 (Reset the condition and lamp)
Outputs
Red Lamp : p1.4
And switch the "Red" lamp on or off based on the conditions mentioned above (Cnd.).
Explanation / Answer
MAIN:
mov.w #0280h, SP ; initialize stack pointer
mov.w #WDTPW+WDTHOLD, &WDTCTL ; stop the watchdog timer
bis.b #00010000b, &P1DIR ; make PORT1.0, 1.1, 1.2, 1.3 as input and 1.4 as output (rest are input)
CHECK_INPUT:
bit.b #00000001, &P1IN ; check if sensor H is active
jc LAMP_ON ; if yes then goto label LAMP_ON
bit.b #00000010, &P1IN ; check if sensor W is active
jc LAMP_ON ; if yes then goto label LAMP_ON
bit.b #00000100, &P1IN ; check if sensor L is active
jc LAMP_ON ; if yes then goto label LAMP_ON
bit.b #00001000, &P1IN ; check if RESET is active
jc LAMP_OFF ; if yes then goto label LAMP_ON
jmp CHECK_INPUT ; continue checking the inputs
LAMP_ON:
bis.b #00010000, &P1OUT ; make red led on
jmp CHECK_INPUT ; go back to check input
LAMP_OFF:
bic.b #00010000, &P1OUT ; make red led off
jmp CHECK_INPUT ; go back to check input
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.