ECE Lecture 1 1 Binary number system Department of Electrical and Computer Engineering The Ohio State University ECE 2560
ECE Lecture 1 2 Today Number systems To and from base 10 Addition Subtraction (made easy) Multiplication THIS LECTURE IS REVIEW MATERIAL
We live in a base 10 world Why base 10? Could have been base 5 or base 20. We can thank Ug! the caveman. In base 10 we have 10 symbols In any number base system you have n symbols Base 2 – 0 1 Base Base 16 – A B C D E F ECE Lecture 1 3
Other number bases Number system base Base 10 § § § § § § § § § § § § § Base 2 § § § § § § § § § § ECE Lecture 1 4
Base 5 and Base 8 Base 5 (would have digits 0 to 4) § § § § § § § § § § § § § Base 8 (octal) § § § § § § § § § § § § § ECE Lecture 1 5
To and from base Base 10 to binary (base 2) Number in Base = ? Procedure (Integer division) Divide by 2 19/2 = 9 r1 9/2 = 4 r 1 4/2 = 2 r 0 2/2 = 1 r 0 1/ 2 = 0 r 1 So the binary of is (In general for any number base you divide by the number system base and use the remainders) More examples? ECE Lecture 1 6
Another How about = ? Again divine by 2 each time So have More Examples? ECE Lecture 1 7
Base 2 to base 10 In first example have In binary the digits have the following weight Value 10 =a 4 *2 4 +a 3 *2 3 +a 2 *2 2 +a 1 *2 1 +a 0 *2 0 Value 10 =a 4 *16+a 3 *8+a 2 *4+a 1 *2+a 0 *1 So here = 1*16 +0*8 +0*4 +1*2 +1*1 = 19 ECE Lecture 1 8
2 nd example Had (written msb to lsb) Value of positions is (lsb to msb) 1,2,4,8,16,32,64,128,256,512,… The powers of 2 Value of the number above = = 139 ECE Lecture 1 9
Binary addition Follow the same rules as base 10 carries -> (7) (11) (18) More examples? ECE Lecture 1 10
Binary subtraction Set the problem And we need to borrow – step 1 ECE Lecture 1 11
Binary subraction The next steps work through to To allow answer to be done ECE Lecture 1 12
Binary multiplication Just like multiplication in base 10 More examples? ECE Lecture 1 13
2’s complement For 4 bits can represent values -8 to 7 In general can represent -2 n-1 n 2 n ECE Lecture 1 14
Arithmetic with 2’s complement Add 5 and -3 ECE Lecture 1 15
Finding the 2’s complement To generate the 2’s complement of n Say n is 3 3 in binary (4 bits) is 0011 Procedure 1) Take the 1’s complement, then add 1 1’s complement – complement all bits 0011 = ) Starting at the lsb (rightmost) bit Keep the 1 st 1 and then complement the rest of the bits. Can easily see on previous example. ECE Lecture 1 16
Subtraction via 2’s complement 14 – 6 (need 5 bits to represent in 2’s complement form) – or (i.e (-6)) and a carry out of 1 value is 8 ECE Lecture 1 17
Operating in 2’s complement In general can represent -2 n-1 n 2 n So with 4 bits can represent values of -8 n +7 So with 8 bits can represent values of -128 n +127 So with 16 bits can represent values of n ECE Lecture 1 18
A look at the MSP430 The chip – The MSP430F2003 ECE Lecture 1 19
The pins Vcc and Vss – Power and Ground being supplied to the chip. The data sheet specifies the tolerance on the voltage supply. P1.0-P1.7,P2.6,P2.7 are for digital input, grouped into 2 digital ports, P1 and P2 TACLK, TA0, TA1 are associated with the Timer_A. More details to come. ECE Lecture 1 20
The Pins (2) A0-, A0+ up to A4- and A4+ are inputs to the analog-to-digital converter. There are 4 channels and each has it own + and – input. Another pin, VREF is the reference voltage for the converter. ACLK and SMCLK are outputs of clock signals and can be used to supply external devices with a clock. XIN and XOUT are the connections for a crystal. RST’ – is the active low reset signal (could also be designated _RST or /RST) ECE Lecture 1 21
The Pins (3) NMI – the nonmaskable interrupt. Interrupts allow an external device to assert a value on this pin (a low) that causes the processor to halt operation after completion of the current instruction and ‘service’ the interrupt. When service is complete a software instruction allows resumption of normal operation. There are no maskable interrupts ECE Lecture 1 22
The Pins (4) TCK, TMS, TCLK, TD1, TD0 and TEST form the full JTAG interface used to program and debug the device. SBWTDIO and SBWTCK provide the Spy- By-Wire interface which is an alternative to JTAG and uses only the 2 pins. NOTE: each of the pins serves multiple purposes. The actual mode for each pin will vary across application and within a given application the use can be multiplexed. ECE Lecture 1 23
ECE Lecture 1 24 Assignment Read Chapter 1 and 2 READ FOR UNDERSTANDING Bring your questions to class Assignments will be due 2 classes after assigned to the drop box on Carmen. No paper submissions – all are electronic. Next time – the internal structure of the MSP 430 and start assembler coding Go to ti.com – order launchpad – get Code Composer Studio Quiz next Monday at start of class. Go to wikipedia.com and read on von Neuman architecture. Write a 1 page summary and submit to drop box, HW1