Exam 1 (Chapter 1, 4, 5, 6) Flashcards

1
Q

What is a processor?

A

A hardware component and is responsible for the whole computation process of the system

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a microprocessor?

A

A device that is developed on a single integrated circuit. All other units like the I/O unit, a communication unit, and control unit are outside of the chip or integrated circuit. It is visualized in the general-purpose like a personal computer.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a microcontroller?

A

A complex device in which the processor and some of the other units are contained in it. The units like memory, A/D converter or D/A converter, DMA controller, parallel I/O interfaces, and hardware responsible for debugging software are included in the microcontroller unit. They are meant for special purposes and are implemented in devices like displays, modems, refrigerators, and washing machines.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What makes a microcontroller different from a microprocessor?

A

The difference between the microprocessor and the microcontroller is the incorporation of modules like the following:

  1. Timers
  2. Communication interfaces including serial or parallel
  3. Converters like Analog to Digital or Digital to Analog
  4. Interface circuitry
  5. Direct Memory Access (DMA) module

Microcontroller incorporates some of the modules into its chip whereas microprocessors are only a processor on a single chip or a single integrated circuit.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How many bits can the HCS12 CPU manipulate in one operation?

A

The HCS12 microcontroller is a 16-bit microcontroller. Therefore in one operation, it can manipulate 16 bits

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How many different memory locations can the HCS12 access without the expanded memory?

A

Number of memory locations

= 2^16 = 65536

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Why must every computer have some amount of nonvolatile memory?

A
  1. Every computer is possessing software and hardware for its operation.
  2. The software that is responsible for the start-up of the computer resides in the memory part of the hardware.
  3. For a system to start up or being its functionalities, t possesses an interface between the hardware and the user which is called software.
  4. The software should not be erased from the memory, since it is accessed every time.
  5. Hence in order to have un-erasable code in the computer, it needs non-volatile memory which is readable only in functionality.

Therefore, there is a need for non-volatile memory for every computer.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Why must every computer have some amount of volatile memory?

A
  1. Whenever a computer is operating, it has to fetch the data on which it has to perform arithmetical operations.
  2. the data to be fetched resided in the memory segments of the computer.
  3. If the processor goes on fetching the data from the memory, the number of time cycles required increases thereby increase the execution time.
  4. To decrease the execution time in a processor, the data is fetched to volatile memory from the main memory.

Therefore, in order to have effective execution time, volatile memory is needed in every computer.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a source code?

A

Source code means the set of instructions that are written by the programmers. it is a high-level language that is understood by human beings. it is converted into machine language with the help of other utilities in order to make the computer understand.

Examples: C, C++, Java

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is object code?

A

Object code is the set of instructions that are understood by the machine or CPU or processor. The original source code written in the High-level programming language is converted to object code which is in machine-level language by the utility called a compiler. the machine-level language is also called assembly-level language.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Convert 5K, 8K, and 13K to decimal representation.

A
5K = 5(1024) = 5120
8K = 8(1024) = 8192
13K = 13(1024) = 13312
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Write an instruction sequence to configure Port A and Port B for input and output, respectively; read the value of Port A and output the value to Port B.

A
DDRA = 0x00;
DDRB = 0xFF;
PTB = PTA;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Give an instruction to configure the pins 7, 5, 1, and 0 of Port B for output and the remaining pins for input.

A

DDRB = 0xA3;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Assume that ax = 83 and bx = 11. What is the value of ax/bx?

A
#include 
int main ()
{
    int ax = 83;
    int bx = 11;
    int cx = ax/bx;
    printf("ax/bx = ", cx);
    return 0;
}

OUTPUT:
ax/bx = 7

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Assume that ax = 97 and bx = ax % 23. What is the value of bx?

A
#include 
int main ()
{
    int ax = 97;
    int bx = ax%23;
printf("bx = ", bx);
return 0; }

OUTPUT:
bx = 5

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Assume that ax = 0x39 and bx = ax ^ 0x79. What is the value of bx?

A

(0x39) = (0011 1001)
(0x79) = (0111 1001)

^ is XOR

bx = ax ^ 0x79 = (0100 0000) = 0x40

17
Q

Assume that ax = 0x6B and bx = ax & 0xDE. What is the value of bx?

A
(0x6B) = (0110 1011)
(0xDE) = (1101 1110)

& is AND

bx = ax ^ 0xDE = (0100 1010) = 0x4A

18
Q

Write a C program to find the median and mode of an array of integers. When the array has an even number of elements, the median is defined as the average of the middle two elements. Otherwise, it is defined as the middle element of the array. The mode is the element that occurs most frequently. You need to sort the array in order to find the median.

A
#include "c:\cwHCS12\include\hcs12.h"
int median, mode, mode_cnt;
void swap (int *pt1, int *pt2);
void bubble (int a[], int n);
#define n 22
int array_x [] = {1,3,4,5,10,13,24,33,2,15,18,19,30,22,24,30,90,98,98,98,97,98};
int main (void)
{
int i, j,k;
bubble(array_x, n);
if ((n % 2) == 0)
median = (array_x[n/2 - 1] + array_x[n/2]) / 2;
else
 median = array_x[n/2];
mode_cnt = 1;
mode = array_x[0];
for (i = 0; i < n; i++){
 k = 1;
 for (j = i+1; j < n; j++) {
 if (array_x[j] == array_x[i])
 k++;
 }
 if (k > mode_cnt) {
 mode = array_x[i];
mode_cnt = k;
 }
}
return 0;
}
19
Q

Write a switch statement that will examine the value of an integer variable xx and store
one of the following messages in an array of seven characters, depending on the value
assigned to xx (terminate the message with a NULL character):
a) Cold if xx = 1
b) Chilly if xx = 2
c) Warm if xx = 3
d) Hot if xx = 4

A
void main(void) 
{
    char str1[7] = “Cold”;
    char str2[7] = “Chilly”;
    char str3[7] = “Warm”;
    char str4[7] = “Hot”;
    char str_x[7];
    switch (xx) 
    {
        case 1:
            strcpy (str_x, str1);
            break;
        case 2:
            strcpy(str_x, str2);
            break;
        case 3:
            strcpy(str_x, str3);
            break;
        case 4:
            strcpy(str_x, str4);
    }
}
20
Q

Write a loop to compute the sum of the squares of the first 100 odd integers.

A
void main(void)
{
    int i, j;
    int sq_sum = 0;
    for (i = 0; i < 100; i++) 
    {
        j = 2 * i + 1;
        sq_sum += j * j;
    }
}
21
Q

Write a program to find the first five numbers that when divided by 2, 3, 4, 5, and 6, leave a remainder of 1 and, when divided by 7, have no remainder.

A

include

int main (void)
{
    int counter = 1;
    int i = 0;
    while(counter < 6)
    {
        if(i%2==1 && i%3==1 && i%5==1 && i%4==1 && i%6==1 && i%7==0)
        {
            printf("%d. %d\n", counter, i);
            counter++;
        }
        i++;
    }
    return 0;
}
22
Q

What are the requirements for interrupt processing?

A

The basic requirements for interrupt processing are

  1. Saving the program counter value so that the interrupted program can be resumed after the interrupt servicing.
  2. Saving the CPU status so the interrupted program can be resumed correctly after the interrupt processing.
  3. There must be some way to identify the cause of the interrupt. This must be provided by the hardware of the processor.
  4. Resolving the starting address of the corresponding interrupt service.
  5. Restoring the CPU status and the program counter after the interrupt processing.
  6. Be able to restart the interrupted program.
23
Q

Write an instruction sequence to prevent the COP timer from timing out and resetting the microcomputer.

A
ARMCOP = 0x55;
ARMCOP = 0xAA;
24
Q

Suppose you want to generate a 24-MHz E-clock; propose a set of values for the SYNR and REFDV register to achieve this goal using a 3-MHz crystal oscillator and the PLL circuit.

A

The 24-MHz E clock is derived from a 48-MHz PLLCLK.
48 x 10^6 = 2 x 3 x 10^6 x (SYNR + 1) / (REFDV + 1)
SYNR = 8 x REFDV + 7
Set REFDV to 0, then SYNR is 7

25
Q

Suppose you want to generate a 24-MHz E-clock; propose a set of values for the SYNR and REFDV registers to achieve this goal using a 6-MHz crystal oscillator and the PLL circuit.

A

The 24-MHz E clock is derived from a 48-MHz PLLCLK.
48 x 10^6 = 2 x 6 x 10^6 x (SYNR + 1) / (REFDV + 1)
SYNR = 4 x REFDV + 3
Set REFDV to 0, then SYNR is 3

26
Q

Write a program to drive the LED circuit in Figure 4.16 and display one LED at a time from the one driven by pin 7 toward the one driven by pin 0 and then reverse. Repeat this operation forever. Each LED is lighted for about 400 ms assuming that the HCS12 uses an 8-MHz crystal oscillator to generate a system clock. Use the RTI to trigger the change of the LED light patterns. It may take several RTIs to trigger one change of the LED pattern for this problem.

A
#include "c:\cwHCS12\include\hcs12.h"
#include "c:\cwHCS12\include\SetClk.h"
char ix;
char cnt;
char ledPat[] = {0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01,
 0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
void main(void) {
 SetClk8();
 ix = 0;
 cnt = 0;
 DDRB = 0xFF; // configure Port B for output
 DDRJ |= 0x02;// configure PJ1 pin for output
 PTJ &= 0xFD;// enable LEDs to light
 RTICTL = 0x7F; // set RTI timeout interval to about 1/8 s
 CRGINT |= RTIE; // enable RTI interrupt
 asm("cli");
 PTB = ledPat[ix];
 while(1);
}
// RTI interrupt service routine
interrupt void rtiISR(void){
 CRGFLG = 0x80; // clear RTIF flag
 cnt++;
 if(cnt == 4){
 ix++;
 cnt = 0;
 PTB = ledPat[ix];
 }
 if(ix == 15)
 ix = 0;
}