EE 308
Homework #6
Due Feb. 25, 1998

For the homework problems which follow assume you have included the file hc12.h in your C program. Thus, you can refer to PORTB when you want to access a byte at address 0x0001. Where I ask for "some code" just write that part of a C program which will do the task. Where I ask for "a program" write a complete program, include the #include "hc12.h" line, the declaration of variables, the main()function, etc.

  1. Write some C code which will make bits 3-0 of PORT B input and bits 7-4 of PORT B output.

  2. Write some C code which will read Port B, and write a 0x55 to Port A if Bit 2 of Port B is high, and write a 0xaa to Port A if Bit 2 of Port B is low.

  3. Write a C program to to swap the last element of an array with the first element, the next-to-last element with the second, etc. Assume the array has 0x20 8-bit numbers. Initialize the array as a global variable with the line (finish the line to contain 0x20 numbers from 0x00 to 0x1f):
    unsigned char array[]={0x00,0x01,0x02,0x03,0x04,0x05,...};

  4. Write a C program which makes Port A and output, and displays alternating 0xaa and 0x55 on Port A forever. Between each display, use a "delay(n)" function to pause for 50 ms.

  5. Write a C program which implements the Part 4 of Lab 5.