Presentation is loading. Please wait.

Presentation is loading. Please wait.

Microcontrollers BME 201. Overview Microcontrollers Notation Registers Timer Concepts Equations.

Similar presentations


Presentation on theme: "Microcontrollers BME 201. Overview Microcontrollers Notation Registers Timer Concepts Equations."— Presentation transcript:

1 Microcontrollers BME 201

2 Overview Microcontrollers Notation Registers Timer Concepts Equations

3 Microcontrollers Made of millions of electrical components A little computer http://upload.wikimedia.org/wikipedia/commons/4/4c/PIC_microcontrollers.jpg

4 Programming High-Level Language Assembly Language Machine Language Easy-to-understand abstract language 0 s or 1 s Hard to understand Defined by manufacturer a = b + cAdd a, b, c0110110110110111

5 Instruction Fetch and Execute 1.Fetch the instruction 2.Figure out what it is 3.Load the operands 4.Do the operation 5.Store the results (if necessary)

6 Notation Decimal (base 10): 0 – 9 1234 = (1x10 3 )+(2x10 2 )+(3x10 1 )+(4x10 0 )

7 Notation Binary (base 2): 0 or 1 0b0110 = (0x2 3 )+(1x2 2 )+(1x2 1 )+(0x2 0 ) = 0 + 4 + 2 + 0 = 6 k

8 Notation Hexadecimal (base 16): 0 – 9, A – F A = 10 B = 11 … 0x5A0F = (5x16 3 )+(10x16 2 )+(0x16 1 )+(15x16 2 ) = 23055 a

9 Notation Page 49 of Handbook 0b00101011 0x2 B BinaryHex 00000 00011 00102 00113 01004 01015 01106 01117 BinaryHex 10008 10019 1010A 1011B 1100C 1101D 1110E 1111F

10 Data Types Char – Single character: ‘a’, ‘f’, ‘\n’ Int – Whole number: 8, 124, -873 Double/Float – Decimal Number: 4.6, -2.7 Array – Collection of similar data: [1, -4, 3] String – ‘String’ of characters: “Hello World!”

11 Registers

12 Timer

13 Bit-Size 8-bit Counts 0 to (2 8 – 1) 0x00, 0x01, 0x02, … 0xFD, 0xFE, 0xFF 16-bit Counts 0 to (2 16 – 1) 0x0000, 0x0001, 0x0002, … 0xFFFD, 0xFFFE, 0xFFFF

14 Overflow 0x00 + 1 = 0x01 0x01 + 1 = 0x02 … 0x0F + 1 = 0x10 0x10 + 1 = 0x11 … 0xFE + 1 = 0xFF 0xFF + 1 = ?

15 Incrementing Counter Counter increments every instruction executed Each instruction executes in 4 clock cycle

16 Prescale Scales the increment rate 1:2, 1:4, 1:8, 1:32, 1:64, 1:128, 1:256

17 Start Bytes Start at a specific value 8-bit 0x00 TMR0L 16-bit 0x0000 TMR0H|TMR0 L

18 Timer Equation 1.Calculate timer increment 1.Determine bit-size 2.Calculate prescale 3.Calculate X (start bytes)

19 Registers T0CON TMR0H TMR0L Overflow: TMR0IF


Download ppt "Microcontrollers BME 201. Overview Microcontrollers Notation Registers Timer Concepts Equations."

Similar presentations


Ads by Google