Question
Write a code fragment in code warrior to do the following a) The main program should continuously read the number at PORT A and take
Write a code fragment in code warrior to do the following
a) The main program should continuously read the number at PORT A and take an average after each 8 readings. Any time the average is greater than 10, an external alarm attached to Port B bit 0 should be turned on by writing a 1 to the bit. If the average is less than 10 the alarm should be off. Assume that the sum of 8 readings is never greater than 255. (There are a bunch of ways to test if the average is greater than 10. For example, you could subtract 10 from the sum and use a Branch if Greater than Zero (BGT) instruction. For really efficient coding, skip the subtraction step and just subtract 80 from the sum).
b) At the same time, every 10 ms the processor should momentarily stop what it is doing and read the input from a sensor attached to Port H, bit 0. If this bit is set a warning light attached to bit 1 of Port B should turn on. If the bit is cleared the light should turn off. (Hint: in Instant Quiz question 4, you had to generate an interrupt every 40 ms. Modify your code to generate one every 10 ms.)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started