CMPEN 472, The Pennsylvania State University
Homework 10: Rapid Data Transmission with HCS12
Due: April 14, 2021 11:30pm
Objective
To learn the general-purpose timer module and the timer interrupt, to learn real-time Rapid Data Transmission programming.
Textbook Reading (for next homework):
- MC9S12C Family Data Sheet: Chapters 5, 8, 13, and 15
Instruction
- The HCS12 chip includes a general-purpose Timer Module, for use in many applications. Write a program to periodically
read the Timer Module’s free-running Timer Counter indirectly. Display the Timer Counter values on the Terminal and
plot the data on a PC screen. Develop and debug your program using CodeWarrior Debugger/Simulator. - Be sure to clearly understand the HCS12 chip’s Timer Module functions: Output Compare, Input Capture, Timer Interrupt, and free-running Timer Counter.
- Write the Homework 10 program to accommodate the following:
- Initialize
- Your program starts from address $3100, and data section at $3000
- Your program starts with serial SCI port baud rate set to
2M baud (at 24MHz, same baud rate and clock frequency as Homework 8 and 9)
and SCI port is connected to a Terminal in the CodeWarrior Simulator - Program execution starts – Print the Welcome message on the Terminal
- Wait for the first RETURN key hit on the terminal while running a ‘typewriter’ function
- Print a short instruction – guiding the user
- Wait for the Switch SW0 pressing – Assume that Switch SW0 is at PORTB bit 0.
- Start the Timer Module Channel 2 Output Compare interrupt generation at every 125 usec interval (8KHz rate).
Each time the Output Compare interrupt occurs, carry out the following tasks:- Service the Output Compare (OC) register (update the counter compare number) for the next interrupt.
Also clear the OC interrupt flag (if you selected the Fast Flag Clear option, updating the timer OC register
for the next interrupt will also clear the interrupt flag). - Read the Timer Counter value and print the value in decimal number to the Terminal.
Print the 16-bit number in decimal. - Increment the data transmit counter
- Service the Output Compare (OC) register (update the counter compare number) for the next interrupt.
- Wait for the data transmit count to be 1024, to complete the data transmit session
- Repeat the last 3 steps, beginning with Switch SW0 press waiting, indefinitely
- Once you verify the above program working, make a modification – to print the numbers in main program and NOT in the interrupt service program. Principally we want to keep the interrupt service routine short and minimal. You may capture the data in the interrupt service routine but its printing must be done in the main program (outside of the interrupt service routine). And you also need to create a flag ‘happened’ so that when a new data is captured, the ‘happened’ flag becomes TRUE and when you printed the new data, the ‘happened’ flag becomes FALSE.
- Copy the HW10 sample program, hw10samp1fSim.asm file. Study it, assemble it, debug it, and run it on
the CodeWarrior HCS12 Debugger/Simulator. This program uses Timer channel 2 Output Compare
interrupt generation of 125usec for the countdown timer. You may use some parts of this program. - For the CodeWarrior Debugger/Simulation, please follow the updated Full Chip Simulator guide for HW10.
- Data printed on the Simulator Terminal can be captured to a file. See the demonstration in class and the Full Chip Simulator guide for HW10. You may name the captured data file ‘RxData3.txt’ and you can view the ‘RxData3.txt’ file with Notepad or Wordpad program in your PC.
- You may use MS Excel program to plot the data. OR download free SciLab Program from SciLab Home page. This program allows your PC to read and plot data.
- Once the ‘RxData3.txt’ file is created, run SciLab program. Then have the SciLab program read the data from the ‘RxData3.txt’ file and plot the data on a plot window.
- For a sample SciLab commands for plotting data, copy the SciLabCOM.txt file. It shows the list of SciLab commands, you can view or edit with any text editor or SciLab. You can also run it (same as MATLAB .m file) in SciLab if you change the file name to ‘SciLabCOM.sce’
- Check the plot and verify the signal frequency. Use magnify feature to see the signal wave details. Identify one cycle of signal wave, check how many points are plotted. (again for plotting, one may also use MS Excel)
- You can acquire another set of 1024-point data as follows:
- Press the switch SW0.
- New set of data should be recorded into the ‘RxData3.txt’ file.
- Write a report of your experiments. Your report must include:
- Cover sheet with course and your information. Click here to download the Homework 10 Report Format.
- Captured data plot and captured data analysis.
- Plot full 1024pts and plot magnified 2 signal cycles. Identify one cycle of signal wave, and verify correct signal frequency by counting how many points are plotted in one cycle.
- Detailed explanation of each plot and operation verification.
- Create your report in MS Word (.doc file) or .pdf file.
- Submit both the program file (.asm) and the report file (.doc or .pdf).
- Make your program user friendly by giving directions as to how to correctly use your program. Once your program is running, everything must be self-explanatory to user at the Terminal.
- Also, make your program ‘fool-proof’, never crash or stop based on wrong user response.
- Be sure to put many comments so that grader and others can clearly and quickly understand your program. Comments are very important in assembly language programs.
- You may want to see and check the Sample Grading Sheet for this homework.
- Copy your ‘main.asm’ file to ‘cmpen472hw10_YourLastName.asm’. For example, mine will be ‘cmpen472hw10_choi.asm’ Do not ZIP your ‘cmpen472hw10_YourLastName.asm’ file.
- Name your Homework 10 report file to ‘cmpen472hw10_YourLastName_RPT.doc’. For example, mine will be ‘cmpen472hw10_choi_RPT.doc’ Do not ZIP your ‘cmpen472hw10_YourLastName_RPT.doc’ file.
- Turn-in your project source code file through Penn State CANVAS. Upload your source code file into the CANVAS Assignment’s Homework submission. Be sure to select CMPEN 472 class and correct Homework number, and with correct file name.
Congratulations on your 10th CMPEN 472 homework completion!
http://www.cse.psu.edu/~kxc104/class/cmpen472/21s/…


0 comments