EE 308
Homework #5
Due Feb. 21, 2001

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 A output and bits 7-4 of PORT A input.

  2. Write some C code which will set bits 3 and 5 of the eight-bit register at address 0x0075 while leaving the other bits unchanged.

  3. Write some C code which will clear bits 1 and 6 of the eight-bit register at address 0x0076 while leaving the other bits unchanged.

  4. Write some C code which makes Port B an input, Port A an output, then 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.

  5. Write a C program which makes Port A an output, and displays alternating 0xaa and 0x55 on Port A forever. Between each display, use a "delay()" function to pause for about 64 ms. Use the timer overflow function of the HC12 to implment the delay.

  6. Write a C program which implements Part 5 of Lab 5. Use the "delay()" function of Problem 5 to implement the needed delays for this program.