Anda di halaman 1dari 5

Week 1 - Revision

1
C programming

write a compiler directive # include <pic.h> 2


C Programming

Write the statement to set PORT D to outputs TRISD = 0B00000000 ; 3


C Programming

Write the statement to set bit 3 of PORT D to output TRISD3 = 0 ; 4


C Programming

Write the statement to set PORT D to 136 PORTD = 136; 5


C Programming

Write the statement to set bit 5 of PORT D to 1 RD5 = 1 ; 6


C Programming

What characters are used for the start of an inline comment // 7


C Programming

What characters are used for a block comment /* to start

*/ to end 8
C Programming

What is the max number held in an unsigned char 255 9


C Programming

What is the max number held in a signed char + 127 to -128 10


C Programming

What is the max number held in an unsigned int 65535 11


C Programming

What is the range of numbers held in a bit 0-1 12


C Programming

What is the scope of a bit variable (hint you may wish to try this in your code) bit variables must be global or static 13
Practical

Explain the steps required to determine the time of execution of the following code running on a 4MHz device
for(int i = 0 ; i ,= 33000 ; i++) {}

Include the setting of breakpoints, setting the sim frequency, running to first break, zero stopwatch, run to second break, note time 14
Programming

Write the declaration for an array of a char variable data which contains the following data: 0xff, 0b10101010, 234, 112, 0x34 char data[] = {0xff, 0b10101010, 234, 112, 0x34} ;

15
Programming

Write the statement to place the number 112 into address 254 of the EEPROM eeprom_write(254, 112) ; 16
Programming

A program has the following function prototype declared


void displayDigit (char number, char side) ;

Write a statement to display the number 7 on the right. displayDigit (7, RIGHT) ; 17
Hardware

State the number of bits in a stack register 13 bits wide 18


Hardware

State the number of bytes available as general purpose registers 368 - See page 25 of the manual 19
Hardware

State the Total number of bytes of RAM memory 512 - See page 25 of the manual 20
Hardware

State the number of RAM bytes used by SFR's (Special Function Registers) 143 - See page 25 of the manual 21
Instruction set

With reference to the resource PIC Instruction Set page 29-3, State the number of bits used for the opcode for a Byte-oriented file register operations

6 - Bits 8 to 13 inclusive 22
Fetch - Execute

What is the purpose of the 'Fetch - Execute' cycle check google for answer - see lecture week 4 23
Fetch - Execute

What is memory address of the 1st instruction in a program ? Address 0 24


Fetch - Execute

What causes the program counter to point to the first instruction of a program ? Power on, Reset and Watch Dog timer overflow 25
Stack

What is the purpose of the Stack ? to hold return addresses 26


Stack

How many levels of stack are available ? 8 27 Stack Does the Interrupt function use the stack a) True b) False It doesYour answer has been saved. 28
Interrupts

Which SFR's need to be set / reset to use the external interrupt - list them and their condition. // enable external interrupts, reset external interrupt flag, enable global interrupts ANSELH = 0 ; // extra code for this device to enable port B digital inputs - specifically the interrupt

TRISB0 = 1 ; // the external interrupt button is on Port B bit zero RBPU = 0 ; // enable PORTB pull ups INTEDG = 0 ; INTE = 1 ; INTF = 0 ; GIE = 1 ; 29
Global volatile

Write the declaration for a global volatile variable letter volatile char letter ; 30
RISC devices

State three features commonly found in RISC microprocessors Harvard architecture Single cycle Instructions Reduced Instruction set.