You are on page 1of 3

APSC 1299

Test 1

Use of a calculator and your lab notebook is permitted. Pin-out diagram on last page.

1.

[6] Consider a new data type, the smallchar, which can hold 7 bits. (a) What is the largest integer that an unsigned smallchar can hold? (b) What is the largest positive integer that a signed smallchar can hold? (c) What is the most negative integer that a signed smallchar can hold?

2.

[6] Consider the following table. You input the given values of variable x where x is of type unsigned smallchar. What decimal values will the PIC assign to these numbers? What are the binary values of these numbers? unsigned smallchar x = 180 100 200 Binary Actual decimal

3.

[6] Consider the following table. You input the given the values of variable y where y is of type signed smallchar. What decimal values will the PIC assign to these numbers? What are the binary values of these numbers? signed smallchar y = 10 100 200 Binary Actual decimal

4.

[6] Consider the following table. You input the given values of variable z where z is of type signed smallchar. What decimal values will the PIC assign to these numbers? signed smallchar z = 0b110 0110 0b011 0010 0b110 1001 Correct decimal

5.

[8] The following snippet of code is used with your PIC and LCD. Determine the decimal value of the variable c unsigned char a = 0x82; unsigned char b = 0423; unsigned char c; c = (a ^ b) >> 2;

6.

[6] Convert the unsigned int variables to the formats given in the table below. Dont directly use your calculator to do the conversions. Show work. binary 0b0110 0101 1101 0011 073102 0xACDF octal hex

7.

[9] What is the approximate voltage at the indicated points in the circuits below? What is the approximate current in the circuits? Show work.
+5 V +5 V +5 V

200 A 100 B 100 D C 270 F E

8.

[20] For an MCU running at 32 MHz, you want an output pin to blink an LED (see diagram on right) on for 0.12007 seconds and then off for 0.0341 seconds. Write a small complete source file to accomplish this using delays.h functions. Assume you have your regular functions in the Functions folder.

PIC18F4525

VDD LED

27

You might also like