EE 308
Homework #5
Due Feb. 23, 2000

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 determine the number of negative 8-bit numbers in an array which starts at address 0x8000 and ends at address 0xBFFF. Save the results in a variable called negative_numbers.

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

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