Question: D. Pre-Lab preparation Each student is to create and debug a C program to meet the following specifications: 1. Two decade counters (A and B):


D. Pre-Lab preparation Each student is to create and debug a C program to meet the following specifications: 1. Two decade counters (A and B): Counter A counts up or down from 0 to 9, and rolls over (repeat), but Counter B always counts up (never changes direction). 2. controlled by two switches, SW1 and SW2 a. SW1: start/stop both counters (1=start, 0 = = stop) b. SW2: direction of Counter A (1 = count down, O = count up); Counter B is always counting up (not affected by SW2). 3. switch connections on the microcontroller a. SW1: microcontroller I/O port pin PA1 b. SW2: microcontroller I/O port pin PA2 (In the laboratory, these lines will be connected to the Digilent Studio.) 4. Changing SW2 while counting is enabled (SW1=1) should change the count direction on the next count change. 5. Display the two counter values A and B by writing to port pins PA[8:5] and PA[12:9], respectively. In the laboratory, these lines will be connected to eight virtual LEDs, via the Studio. 6. Count period should be approximately 0.5 s. Prior to lab, design the C program with a main program, and two separate " functions" as follows: O The main program is to initialize port directions and variables, and then execute an endless loop. The loop calls the delay function, sets the direction variable based on position of switch SW2, and calls the count function if counting is enabled by switch S1. o A delay function should produce a half-second time delay (do nothing" for about half a second). As time permits, adjust the delay function to be accurate within 10% of the nominal value (0.5 seconds +/- 10%). o A count function should update the counters, according to the setting of a direction variable passed as a parameter from main, and display the new value on port pins PA[12:9] and PA[8:5]. The count values are to be static global variables. D. Pre-Lab preparation Each student is to create and debug a C program to meet the following specifications: 1. Two decade counters (A and B): Counter A counts up or down from 0 to 9, and rolls over (repeat), but Counter B always counts up (never changes direction). 2. controlled by two switches, SW1 and SW2 a. SW1: start/stop both counters (1=start, 0 = = stop) b. SW2: direction of Counter A (1 = count down, O = count up); Counter B is always counting up (not affected by SW2). 3. switch connections on the microcontroller a. SW1: microcontroller I/O port pin PA1 b. SW2: microcontroller I/O port pin PA2 (In the laboratory, these lines will be connected to the Digilent Studio.) 4. Changing SW2 while counting is enabled (SW1=1) should change the count direction on the next count change. 5. Display the two counter values A and B by writing to port pins PA[8:5] and PA[12:9], respectively. In the laboratory, these lines will be connected to eight virtual LEDs, via the Studio. 6. Count period should be approximately 0.5 s. Prior to lab, design the C program with a main program, and two separate " functions" as follows: O The main program is to initialize port directions and variables, and then execute an endless loop. The loop calls the delay function, sets the direction variable based on position of switch SW2, and calls the count function if counting is enabled by switch S1. o A delay function should produce a half-second time delay (do nothing" for about half a second). As time permits, adjust the delay function to be accurate within 10% of the nominal value (0.5 seconds +/- 10%). o A count function should update the counters, according to the setting of a direction variable passed as a parameter from main, and display the new value on port pins PA[12:9] and PA[8:5]. The count values are to be static global variables
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
