Quick

November 9, 2017 | Author: Khairil Amirul Mohd Aziz | Category: Microcontroller, Computer Data Storage, Central Processing Unit, Electronic Design, Computer Data
Share Embed Donate


Short Description

note...

Description

05/04/2012

Answers

Some Quick Exercises

• The three main elements are: Processor, memory and I/O • A microcontroller has processor, memory and I/O on one chip, while microprocessor needs separate memory and I/O chips to form a working system • Flash ROM can be electrically re-written many times, but is non-volatile

• State the three main elements in any microprocessor system • State the difference between a microprocessor and microcontroller • State the advantages of flash ROM, compared with other memory types.

1

2

Answers

Some Quick Exercises • Microcontroller contains on chip memory, input/output (I/O) ports and the processor CPU. • State the main function of I/O ports • Name THREE (3) types of I/O communication ports.

3

• communication between microcomputer and the outside world (external system) such as humans and machine • serial port, parallel port, USB port

4

1

05/04/2012

Some Quick Exercises

Answers • 128k = 128 x 1024 bytes • 128 x 1024 x 8 bits = 1,048,576 bits

• How many bits does the 128k MCU program memory contain?

5

Some Quick Exercises

6

Answers • Common File: Rewriting the hardware definitions for each and every programs to be used for the same board can be troublesome. All the programs using the same hardware/circuit can just include the common hardware definitions file into the source code

• Why it’s a good practice to put all hardware definitions into a common file? • State three PIC chip options, which are determined by the configuration code. (#config … )

• PIC Chip Options: Watchdog timer, High speed programming, Low voltage programming, Incircuit debugger, code protection, memory write, brown-out reset, power-up timer 7

8

2

05/04/2012

Some Quick Exercises

Answers • Serial vs Parallel: The data has to be converted to serial form in a shift register and transmitted one bit at a time on a single line, while parallel data is transferred 8 (or more) bits at a time.

• Why serial data communication is generally slower than parallel? • Why serial data communication can achieve higher speed compared to parallel communication by being clocked at a greater rate?

• A number of factors allow serial to be clocked at a greater rate: • Clock skew between different channels is not an issue (for unclocked asynchronous serial communication links) • Serial connection requires fewer interconnecting cables, occupies less space. The extra space allows for better isolation of the channel from surroundings • Crosstalk is less of an issue compared to parallel, because fewer conductors in proximity.

9

Some Quick Exercises •

Answers

This function initializes the RS232… The oscillator frequency to be used is 10MHz. The baud rate required is 9600 bps. Calculate the value of X to obtain the required baud rate.

• Oscillator frequency = 10MHz. • Baud Rate = 9600 bps X = (Fosc / Baud Rate / 16) – 1 = (10MHz / 9600 / 16) - 1 = 65 – 1 = 64

void init_rs232( ) { BRGH = 1; SPBRG = X; TX9 = 0; SYNC = 0; SPEN = 1; TXEN = 1; CREN = 1; SREN = 0; TXIE = 0; RCIE = 0;

10

/* set baud rate */ /* ninebits?1:0,,,8- or 9-bit transmission */ /* asynchronous */ /* enable serial port pins */ /* enable the transmitter & (automatically)TXIF=1 */ /* enable reception */ /* no effect */ /* disable tx interrupts */ /* disable rx interrupts */

} 11

12

3

05/04/2012

Some Quick Exercises

Answers

• What are the advantages of in-circuit programming and debugging over the corresponding conventional development process?

13

Some Quick Exercises

• The program can be run, single stepped and paused in the actual target hardware • allowing hardware and timing faults to be identified as well a the usual syntax and logical errors • the chip does not need to be removed from the application hardware once fitted, preventing possible damage 14

Answers • The conventional process is to build prototype hardware, download the program to the microcontroller and test it in circuit. • Simulation allows the design to be tested and debugged before building hardware. • The schematic can then be converted into a netlist and a layout to produce the final PCB without prototyping.

• What are the advantages of using circuit simulation software such as Proteus over the corresponding conventional development process?

15

16

4

05/04/2012

Some Quick Exercises

Answers

• What is a compiler (for C programming) and what does a compiler do?

• Compiler is a program that processes statements written in a programming language and turns them into machine language that a computer's processor uses. • The compiler gets the syntax error in the written program before turning the C statements into machine instructions 17

Some Quick Exercises

18

Answers

• PIC is a family of Harvard architecture microcontrollers. Sketch the block diagram of a Harvard architecture microcontroller.

19

• Block diagram of a Harvard Architecture:

20

5

05/04/2012

Some Quick Exercises

Answers

• Von Neumann is another type of microcontroller architecture besides Harvard architecture. Sketch the block diagram of a von Neumann architecture microcontroller.

• Block diagram of a von Neumann architecture :

21

Some Quick Exercises

22

Answers • In a system using von Neumann architecture, the CPU can be either reading an instruction or reading/writing data from/to the memory. Both cannot occur at the same time since the instructions and data use the same bus system. • In a system using the Harvard architecture, the CPU can both read an instruction and perform a data memory access at the same time, can thus be faster for a given circuit complexity because instruction fetches and data access do not contend for a single memory pathway.

• What are the advantages of Harvard architecture compared to von Neumann architecture?

23

24

6

05/04/2012

Some Quick Exercises

Answers

• EEPROM is a type of memory widely used in computers and other electronic devices. State the type of EEPROM. • EEPROM is realized by using arrays of floating gate transistors. State one advantage of floating gate transistors that is useful in EEPROM. • Flash memory is one type of EEPROM which is able to achieve faster erase/write speed compared to traditional EEPROM. Why?

• Non-volatile memory which can be electrically re-written many times. • The ability to store an electrical charge for extended periods of time even without a connection to a power supply. • Flash memory works much faster than traditional EEPROMs because it writes data in chunks/blocks, usually 512 bytes in size, instead of 1 byte at a time.

25

26

Some Quick Exercises

Answers

#include #include #define _XTAL_FREQ 20000000 // Set the oscillator frequency to 20MHz void main( ) { TRISC=0x00; //Port C as outputs T2CON = 0b01010000; // Timer 2 control register PR2 = 0b01111111; CCP1CON = 0b00111100; //Set to PWM mode CCPR1L=63;

• • • • • • • • •

TMR2ON=1; //Turn on Timer 2 while(1) { } } //End of Program

Calculate the pulse width, duty cycle and frequency of the pulse generated in the program below. The circuit uses a 20MHz oscillator.



27

Instruction clock frequency = 20/4 = 5MHz Instruction clock period = 0.2 us Timer2 counts from 0 to 127 (0b01111111 ) Pre-scaler set at 1 Time for Timer 2 to reset = 127 x 0.2 us = 25.4 us Post-scaler = 10, but unused in PWM mode Pulse period = Time for Timer 2 to reset = 25.4 us Pulse frequency = 1/(pulse period) = 1/(25.4us) = 39.37kHz Every time Timer2 counts until 63 (determined by CCPR1L) output of CCP1 (Pin RC2 or C2) will turn from high to low, the time taken (Pulse width) is 63 x 0.2 us = 12.6us OR 1.26 x 10e-5 seconds Duty cycle = 12.6us / 25.4us = 49.6%

28

7

05/04/2012

Some Quick Exercises

Answers

• Describe TWO characteristics of an activehigh switch.

29

• An active high switch pulls up the logic level to HIGH when being pressed/pushed. • An active high switch requires a pull down resistor to pull down the logic level to LOW when the switch is released. 30

The End • That’s all for this time. • Enjoy your time playing around with microcontroller and interfacing 

31

8

View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF