Skip to content
Glenn Lopez edited this page Feb 12, 2014 · 5 revisions
  1. For the Z8 port interface below, write the C statements that will initialize the PORT lines, as appropriate for the peripheral devices (ie. Switches are input devices, LEDs are output devices). Output lines should be configured for push-pull operation.
  • PCADDR = 0x01;
  • PCCTL = 0x80;
  • PCADDR = 0x03;
  • PCCTL = 0x00;
    1. Write the C statement that will turn ON all three LEDs in the circuit below, while sending logic 0 to PORT lines that are not connected to an LED.

    00001100b = 0C ----> PAOUT = 0x0C;

    1. Write the C statements that will:
    • assign the logic level of the switch to a char variable named “switch!”
    • mask off all PORT lines that are not connected to the switch
    • unsigned char "switch1";
    • switch1 = PCIN;
    • switch1 = switch1 & 0x80; //<-- 0x80 is-inbinary 10xx 00xx
    Clone this wiki locally