-
Notifications
You must be signed in to change notification settings - Fork 4
Lab 3 Questions
- Examine the Z8 Microcontroller board schematic. Identify the test switch interface. Which port pin is connected to the test switch? What logic level is generated by the test switch when it is pressed?
Logic low is generated when the switch is pressed. As per schematics pin 42 (PC0_T1IN) is connected to the port
- Running the program at full speed, push the “test” push button several times. What did you observe?
Red and Green or Yellow will stay on depending on what was on at the time the button is released.
- Which bit of which port is used to sense the logic state of the “test” switch?
0 and port C
- Stop debugging and “single step” through the program. After you notice a repetitive pattern, hold in the “test” Push Button while you single step. Continue to single step with the test button pushed, then, repeat without pushing the test push button. Can you explain this behavior?
If statement works as expected; script changes the state of led for 1 to 0 and 0 to 1 if the button is pressed.
- What bitwise logical operations are performed in this program?
Both AND & XOR | AND is used for push_b&0x01 XOR is used otherwise you will have a switch bouncing effect of the led.
- Explain the function of bit masking, as used in this program.
Bit masking (push_b=push_b&0x01) is used in this script to be able to use both buttons to control the same function.
- Does this program stop by itself? Why?
As long as the conditions for the loop is true then it will be stuck in this routine till the condition is false. For the program to stop by it self we need to have an else statement, or an "if(){" condition telling the loop to "break;" when the condition is reached.
- How does “=” differ from “==”?
"=" means "is" (aka: assigning operator) and "==" means "is equal to" (aka: conditional operator). Example: "push_button == 0x00" means push_button IS EQUAL TO to 0x00 while "push_button = PCIN" means push_button IS PCIN
- What is a “compound statement”?
Statements enclosed inside curly braces.
If you are having trouble with this course, I highly suggest you learn how to program in C using code::blocks before doing anything with your microcontroller. This course is poorly designed and failing at it may not be entirely your fault. How well you do in your courses is a reflection of how good your instructors are -- never give them an excuse to say otherwise. “The mind is not a vessel to be filled, but a fire to be kindled.” — Plutarch