- What is the difference between microprocessor and
microcontroller?
Microcontroller differs from a
microprocessor in many ways. First and the most important is its functionality.
In order for a microprocessor to be used, other components such as memory, or
components for receiving and sending data must be added to it. In short that
means that microprocessor is the very heart of the computer. On the other hand,
microcontroller is designed to be all of that in one. No other external
components are needed for its application because all necessary peripherals are
already built into it. Thus, we save the time and space needed to construct
devices
- Draw a block diagram of microcontroller and briefly explain
the function of I/O port, timer and ADC?
- When the microcontroller is reset, what is the value of the
program counter holds?
One of the most important effects of a
reset is setting a program counter (PC) to zero (0000h), which enables the
program to start executing from the first written instruction.
- In a serial communication of microcontroller, it needs a
protocol. Explain how the protocol works in microcontroller?
The rules of exchange of data are called
protocol. Protocol is therefore defined in advance so there wouldn't be any
misunderstanding between the sides that are communicating with each other.
Let's suppose we have the following
protocol. The logical unit "1" is set up on the transmitting line
until transfer begins. Once the transfer starts, we lower the transmission line
to logical "0" for a period of time (which we will designate as T),
so the receiving side will know that it is receiving data, and so it will
activate its mechanism for reception. Let's go back now to the transmission
side and start putting logic zeros and ones onto the transmitter line in the
order from a bit of the lowest value to a bit of the highest value. Let each
bit stay on line for a time period which is equal to T, and in the end, or
after the 8th bit, let us bring the logical unit "1" back on the line
which will mark the end of the transmission of one data.
- What is the difference between address bus and data bus?
That
"way" is called "bus". Physically, it represents a group of
8, 16, or more wires
There are two types of buses: address and data bus. The first one consists of as many lines as the amount of memory we wish to address, and the other one is as wide as data, in our case 8 bits or the connection line. First one serves to transmit address from CPU memory, and the second to connect all blocks inside the microcontroller.
There are two types of buses: address and data bus. The first one consists of as many lines as the amount of memory we wish to address, and the other one is as wide as data, in our case 8 bits or the connection line. First one serves to transmit address from CPU memory, and the second to connect all blocks inside the microcontroller.
- How the data in the memory unit is read and written by the
CPU?
Memory consists of all memory locations,
and addressing is nothing but selecting one of them. This means that we need to
select the desired memory location on one hand, and on the other hand we need
to wait for the contents of that location. Beside reading from a memory
location, memory must also provide for writing onto it. This is done by
supplying an additional line called control line. We will designate this line
as R/W (read/write). Control line is used in the following way: if r/w=1,
reading is done, and if opposite is true then writing is done on the memory
location.
- As a result of some interference our microcontroller stops
executing the program, or worse, it starts working incorrectly. How does
the microcontroller overcome this problem?
To overcome this obstacle, we need to
introduce one more block called watchdog. This block is in fact another
free-run counter where our program needs to write a zero in every time it
executes correctly. In case that program gets "stuck", zero will not
be written in, and counter alone will reset the microcontroller upon achieving
its maximum value. This will result in executing the program again, and
correctly this time around. That is an important element of every program to be
reliable without man's supervision
- PIC memory unit consist of Flash, EEPROM and RAM, explain
the role played by each of it.
Program memory (FLASH)- for
storing a written program.
Since memory made in FLASH technology can be programmed and cleared more than once, it makes this microcontroller suitable for device development.
EEPROM - data memory that needs to be saved when there is no supply.
It is usually used for storing important data that must not be lost if power supply suddenly stops. For instance, one such data is an assigned temperature in temperature regulators. If during a loss of power supply this data was lost, we would have to make the adjustment once again upon return of supply. Thus our device looses on self-reliance.
RAM - data memory used by a program during its execution.
In RAM are stored all inter-results or temporary data during run-time.
Since memory made in FLASH technology can be programmed and cleared more than once, it makes this microcontroller suitable for device development.
EEPROM - data memory that needs to be saved when there is no supply.
It is usually used for storing important data that must not be lost if power supply suddenly stops. For instance, one such data is an assigned temperature in temperature regulators. If during a loss of power supply this data was lost, we would have to make the adjustment once again upon return of supply. Thus our device looses on self-reliance.
RAM - data memory used by a program during its execution.
In RAM are stored all inter-results or temporary data during run-time.
- How many clock cycle of oscillator, the free run timer will
increase it value by one? What is the maximum value of 8bits free run
timer?
FREE-RUN TIMER is an 8-bit
register inside a microcontroller that works independently of the program. On
every fourth clock of the oscillator it increments its value until it reaches
the maximum (255), and then it starts counting over again from zero.
- “PIC is a RISC microcontroller”, what is the meaning of this
statement? How many Instructions available for 16F877?
Microcontrollers with Harvard architecture
are also called "RISC microcontrollers". RISC stands for Reduced Instruction
Set Computer.
Since PIC16F84 is a RISC microcontroller,
that means that it has a reduced set of instructions, more precisely 35
instructions.
- With the aid of timing diagram, explain what is the meaning
of instruction cycle?
Clock from the oscillator enters a
microcontroller via OSC1 pin where internal circuit of a microcontroller
divides the clock into four even clocks Q1, Q2, Q3, and Q4 which do not
overlap. These four clocks make up one instruction cycle (also called machine
cycle) during which one instruction is executed.
- How does the pipelining help to increase the performance of
microcontroller?
Instruction cycle consists of cycles Q1,
Q2, Q3 and Q4. Cycles of calling and executing instructions are connected in
such a way that in order to make a call, one instruction cycle is needed, and
one more is needed for decoding and execution. However, due to pipelining, each
instruction is effectively executed in one cycle.
- Why the impulse of reset in PIC needs to last for 72ms?
Following
a supply, oscillator starts oscillating. Oscillation at first has an unstable period
and amplitude, but after some period of time it becomes stabilized.
That impulse lasts 72ms which is enough
time for an oscillator to get stabilized.
- What are the operations can be performed by ALU?
Arithmetic logic unit is responsible for
performing operations of adding, subtracting, moving (left or right within a
register) and logic operations.
- What is status register? Which bits of status register can
be affected by ALU instruction execution?
Status Register
As an addition in doing operations in
arithmetic and logic, ALU controls status bits (bits found in STATUS register).
Execution of some instructions affects status bits, which depends on the result
itself. Depending on which instruction is being executed, ALU can affect values
of Carry (C), Digit Carry (DC), and Zero (Z) bits in STATUS register.
- When TRISB register is set, what is the direction of data
flow in port B? Write a short program to set four pins as output and four
pin as input in port B.
When the TRISB register is set, Port B is set as input, the data
will flow into PIC through the pins the Port B.
The following is a short program to set four pins as output and
four pin as input in port B.
Bsf STATUS, RP0 ;Bank1
Movlw 0x0F ;Defining input and output pins
Movwf TRISB ;Writing
to TRISB register
- In PIC, why PORTA pin RA4 is normally used to input signal
only?
It is important to note that PORTA pin RA4
can be input only. On that pin is also situated an external input for timer
TMR0. Whether RA4 will be a standard input or an input for a counter depends on
T0CS bit (TMR0 Clock Source Select bit). This pin enables the timer TMR0
to increment either from internal oscillator or via external impulses on
RA4/T0CKI pin.
- What is the difference between GPR and SFR in term of memory
access in PIC?
Locations of RAM memory are also called GPR
registers which is an abbreviation for General
Purpose Registers. GPR registers can be accessed regardless of which
bank is selected at the moment.
Registers
which take up first 12 locations in banks 0 and 1 are registers of specialized
function assigned with certain blocks of the microcontroller. These are called Special
Function Registers. When different
bank is selected, for SPR, we will access to a different memory location even though
we use the same register name.
- How the memory bank can be selected in PIC?
By changing the value of RPO in status register, we
can select different memory bank.
Bcf STATUS, RP0 ;Select memory bank 0
Bsf STATUS, RP0 ;Select memory bank 1
- When microcontroller is interrupted, how the STACK is
applied?
PIC16F84 has a 13-bit stack with 8 levels,
or in other words, a group of 8 memory locations, 13 bits wide, with special
purpose. Its basic role is to keep the value of program counter after a jump
from the main program to an address of a subprogram . In order for a program to
know how to go back to the point where it started from, it has to return the
value of a program counter from a stack. When moving from a program to a
subprogram, program counter is being pushed onto a stack (example of this is
CALL instruction). When executing instructions such as RETURN, RETLW or RETFIE
which were executed at the end of a subprogram, program counter was taken from
a stack so that program could continue where was stopped before it was
interrupted.
- Explain the difference between direct addressing and indirect
addressing,.
Direct Addressing is done through a 9-bit
address. This address is obtained by connecting 7th bit of direct address of an
instruction with two bits (RP1, RP0) from STATUS register as is shown on the
following picture. Any access to SFR registers is an example of direct
addressing.
Indirect unlike direct addressing does not
take an address from an instruction but derives it from IRP bit of STATUS and
FSR registers. Addressed location is accessed via INDF register which in fact
holds the address indicated by a FSR. In other words, any instruction which
uses INDF as its register in reality accesses data indicated by a FSR register
- What is the
application of interrupt? How it affect the program flow?
Interrupts
are a mechanism of a microcontroller which enables it to respond to some
events at the moment they occur, regardless of what microcontroller is doing at
the time. This is a very important part, because it provides connection between
a microcontroller and environment which surrounds it. Generally, each interrupt
changes the program flow, interrupts it and after executing an interrupt
subprogram (interrupt routine) it continues from that same point on.
- Why INTF bit must
cleared in interrupt routine?
After
interrupt is processed, bit whose setting caused an interrupt must be cleared,
or interrupt routine would automatically be processed over again during a
return to the main program.
- What is the
function of pre-scalar in PIC? What is the oscillator clock highest
divisor can be set by prescaler?
Prescaler is a name for the part of a
microcontroller which divides oscillator clock before it will reach logic that
increases timer status. Number which divides a clock is defined through first
three bits in OPTION register. The highest divisor is 256. This actually means
that only at every 256th clock, timer value would increase by one. This
provides us with the ability to measure longer timer periods.
- If 4MHz oscillator is applied to a PIC, what is period per
increment in Timer0 status and Watchdog timer status when prescaler rate
select bit is set to 111?
For Timer0 :
Period per increment
= 256x(1/4MHz)x4 = 256us
For Watchdog timer:
Period per increment = 128x(1/4MHz)x4 = 128us
State five
considerations when selecting microcontroller in embedded system design.
The
following items must be taken into consideration
- Number of I/O pins required
- Interfaces required
- Memory requirements
- Number of interrupts required
- Real-time considerations
- Development environment
- Processing speed required
- Memory architecture
Overestimate
the memory required may cause unnecessarily expensive solution.
Underestimate
the memory required may cause project delay.
•
Verify
EPROM, RAM, and peripheral access times. Add wait states if necessary.
•
Verify
that setup and hold times are met, both to the peripheral device and to the
microprocessor.
•
Make
sure crystal type match the system specifications. If using and external oscillator; be sure it
matches duty cycle and drive-level requirements of the microprocessor.
•
Verify
that bus loading is not exceeded.
•
Verify
that loading of I/O port pins is not exceeded – either sinking or sourcing
current.
•
Verify
that inputs to timers meet frequency and duty cycle limitations of the part.
This usually depends on the microprocessor or timer IC clock speed.







No comments:
Post a Comment