Question
IN C LANGUAGE In this experiment, we design and implement a 9S12DG256 -based digital system that contains an 8 -bit, bi-directional, binary counter ; and
IN C LANGUAGE
In this experiment, we design and implement a 9S12DG256 -based digital system that contains an 8 -bit, bi-directional, binary counter
; and an 8 -bit, bi-directional, one -hot rotator. Both run at approximately 1 Hz by software-generated delay . The counting direction (upward or
downward) for the counter, and the rotating direction (left or right) for the rotator, are given respectively by logic signals provided by a 2-bit DIP switch: CNT_DIR: 0 for upward, and 1 for downward;ROT_DIR: 0 for left, and 1 for right.The state of the counter,and that of the rotator are displayed with two 8 -bit LED bars
It is recommended that you use Port A as the counter, and Port B as the rotator. Port K can be used for signals CNT_DIR, and ROT_DIR, respectively. Make sure that you configure the ports for general purpose I/O and that you get the data directions correct (e.g ., Port A should be configured as an 8 -bit output port) Programming Symbolic names should be used wherever possible to improve your programs readability. Portability should also be taken into account. The following symbolic names should be used . PRTA, PRTB, PRTK CNT_DIR, ROT_DIR
Psuedo Code ------------------------------------------
Configure Port A to be an 8-bit output port;
Configure Port B to be an 8-bit output port;
Initialize Port A to 0;
Initialize Port B such that only 1 bit is ON;
while (1) {
delay for the effect of soft clock;
read Port K;
if (CNT_DIR is 0)
increment Port A;
else
decrement Port A;
if (ROT_DIR is 0)
left-rotate Port B;
else
right-rotate Port B;
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Only got this much done.
DDRA = 0xFF;
PORTA = 0x00;
DDRB = 0xFF:
PORTB = 0x01;
DDRK = 0x00;
PORTK = 0xFF
for(;;){
CNT _ DIR = PORTK & 0x01;
ROT _ DIR = PROTK & 0x02;
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