You are on page 1of 5

Section A 1.

(i) A microcontroller is a highly integrated chip, which includes on single chip, all or most of the parts needed for a controller. The microcontroller typically includes: CPU (Central Processing Unit), RAM (Random Access Memory), EPROM/PROM/ROM (Erasable Programmable Read Only Memory), I/O (input/output) serial and parallel, timers, interrupt controller. (ii) Microprocessor is general-purpose digital computer central processing unit (CPU). The microprocessor is general-purpose device and additional external circuitry are added to make it microcomputer. 2. Advantages - MCUs have on-chip resources to achieve a higher level of integration and reliability at a lower cost. - Built-in resources increase reliability because they do not require any external circuitry to be working for the resource to function. Disadvantages less speed. requires software to function at optimum. 3. (i) -processor register that indicates where a computer is in its program sequence. -stores the address of the next instruction which is to be fetched. -contains the address pointer value of the current instruction. (ii) 21 bits 4. The W register is central to most programs. This instruction moves a constant into the W register. It also means move literal to working register. Therefore, this means move the value 9F from the literal to the working register.

5. (i) PORTA can be set as input port by using TRISA=1. Setting a TRISx bit (= 1) will make the corresponding PORTx pin an input. (ii) PORTA can be set as output port by using TRISA=0. Clearing a TRISx bit (= 0) will make the corresponding PORTx pin an output. -Timer register Control register B register Stacker pointer 6. -Using simple loop -Using delay function library -Using the PIC18 timers -Using for loop

7. Synchronous -Clock source is synchronized -Data is synchronized with clock -i.e. a common clock source for the communicating devices is necessary Asynchronous -No common clock source is required -Clock is recognized by the receiver automatically 8. E (Enable) used by the LCD to latch information presented to its data pins. RS (Register Select) If RS = 0, the instruction command code register is selected, allowing the user to send a command such as clear display, cursor at home, and so on. If RS = 1, the data register is selected, allowing the user to send data to be displayed on the LCD. 9. Motorola, Texas, Hitachi, ARM, Toshiba, Freescale.

Section B Question 1 a. (i) Used to store information temporarily. (ii) 8 bits (iii) MOVLW 88H b. (i) 32 bytes several thousand bytes (ii) MOVLW 55H MOVWF 1H / PORTB c. C=0 DC=0 Z=1 d. (i) MOVLW 15H MOVWF 7 (ii) MOVLW MOVWF MOVWF ADDWF ADDWF MOVLW 15H 7 6 7 6 6

Question 2 a. It is easier and less time consuming. Easier to modify and update. You can use code available in function libraries. C code is portable to other microcontrollers with little or no modification. b. Unsigned char bit size: 8 bit, data range: 0 255 Unsigned int bit size: 16 bit, data range: 0 65535

c. #include <p18f4550.h> void delay (void) { unsigned char int i; for (i=0; i<10000; i++); } void main (void) { TRISB=0; while (1) { PORTB=0; delay_ms (250); PORTB=0xFF; delay_ms (250); } } d. #include <p18f4550.h> void main (void) { TRISBbits.RB5=1; TRISBbits.RB3=0; while (1) { if (PORTBbits.RB5 == 1) PORTBbits.RB3 = 0; delay_ms (500); PORTBbits.RB3 = 1; delay_ms (500); else PORTBbits.RB3 = 0; } }

Question 3 a. When information is sent across one wire, one data bit at a time, its called serial. Instead of squishing bits together, bits are sent over more wires simultaneously (parallel). b. (i) Half-duplex data can be sent in both direction but not at the same time. Eg.: Walkie talkie. (ii) Full-duplex data can be sent in both direction simultaneously (at the same time). Eg.: telephone. c. The MAX232 is an integrated circuit, first created by Maxim Integrated Products, that converts signals from an RS-232 serial port to signals suitable for use in TTL compatible digital logic circuits. The MAX232 is a dual driver/receiver and typically converts the RX, TX, CTS and RTS signals. d. In the interrupt method, whenever any device needs the microcontrollers service, the device notifies it by sending an interrupt signal. Upon receiving an interrupt signal, the microcontroller stops whatever it is doing and serves the device. The program associated with the interrupt is called interrupt service routine (ISR) or interrupt handler. e. 1. It finishes the instruction it is executing and saves the address of the next instruction (program counter) on the stack. 2. It jumps to a fixed location in memory called the interrupt vector table. The interrupt vector table directs the microcontroller to the address of the interrupt service routine (ISR). 3. The microcontroller gets the address of the ISR from the interrupt vector table and jumps to it. It starts to execute the interrupt service subroutine until it reaches the last instruction of the subroutine, which is RETFIE (return from interrupt exit). 4. Upon executing the RETFIE instruction, the microcontroller returns to the place where it was interrupted. First, it gets the program counter (PC) address from the stack by popping the top bytes of the stack into the PC. Then it starts to execute from the address.

You might also like