
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

Homework Assignment #
Due Wednesday, May 13
Homework Programming Objective:
Write a syntactically correct 9S12 assembly program that will toggle Bits 3 and 6 of Port T (PT and PT6) at approx. 150 milliseconds (msec) intervals such that PT3 and PT6 will be each otherās complement. The program should run in an infinite cycle. The addresses to access to PORTT and DDRT, respectively, are posted in the Labs Section of the Class Web Page. The 150msec timing should be implemented as a "software delay", i.e., the time needed for the program to leave a loop after its entry on top should be approximately 150msec. The number of clock cycles for fetching and executing instructions are published in the CPU12 Reference Manual (Tables A-1, and A-2), and one clock cycle takes 125ns (8 MHz). The core of the delay loop should take approx. 100 microseconds. In order to prove that your program would do the job, you should show your calculations (i.e., develop a formula for your approach) to achieve the inner delay of 100 microseconds (usec), and the total delay of 150msec. Choose the code, data, and variable locations for your program such that it could run on the system in the Lab but you are not required to prove that it has actually run. Turn in your assembled .lst file and comment on your code for full credit.
Homework try points:
(1) Write a single (inner) software delay loop that requires 100 usec to complete.
(2) Show your calculations for part (1) (i.e., develop a formula for your approach).
(3) Write a single loop (outer) that will execute exactly 1500 times.
(4) Compute how many clock cycles a single pass through the loop of part (3) would take.
(5) Write initialization code that would initialize Bit 3 of Port T to a ā1ā and Bit 6 of Port T to a ā0ā.
(6) Write code that would read bits 3 and 6 of Port T, complement the bits, and then write the complemented values back to bits 3 and 6 of Port T as outputs.
(7) Combine the code segments of parts (1), (3), (5), and (6) into a program that performs the stated objective. Turn in your assembled .lst file.
(8) Provide commented code.