Skip to content
Glenn Lopez edited this page Dec 9, 2016 · 10 revisions
  1. 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

  1. 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.

  1. Which bit of which port is used to sense the logic state of the “test” switch?

0 and port C

  1. 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.

  1. 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.

  1. 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.

  1. 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.

  1. 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

  1. What is a “compound statement”?

Statements enclosed inside curly braces.

Clone this wiki locally