CHW 469 : Embedded Systems

Size: px
Start display at page:

Download "CHW 469 : Embedded Systems"

Transcription

1 CHW 469 : Embedded Systems Instructor: Dr. Ahmed Shalaby

2 I/O Ports in AVR The AVR microcontroller and embedded systems using assembly and c

3 Topics AVR pin out The structure of I/O pins I/O programming Bit manipulating

4 ATmega6/mega32 pinout. Vital Pins:. Power VCC Ground 2. Crystal XTAL XTAL2 3. Reset 2. I/O pins PORTA, PORTB, PORTC, and PORTD 3. Internal ADC pins AREF, AGND, AVCC +5 V +5 V 4 PIN DIP (XCK/T) PB (T) PB (INT2/AIN) PB2 (OC/AIN) PB3 (SS) PB4 (MOSI) PB5 (MISO) PB6 (SCK) PB MEGA PA (ADC) PA (ADC) PA2 (ADC2) PA3 (ADC3) PA4 (ADC4) PA5 (ADC5) PA6 (ADC6) PA7 (ADC7) RESET VCC GND AREF AGND AVCC +5 V XTAL2 XTAL (RXD) PD (TXD) PD (INT) PD2 (INT) PD3 (OCB) PD4 (OCA) PD5 (ICP) PD PC7 (TOSC2) PC6 (TOSC) PC5 (TDI) PC4 (TDO) PC3 (TMS) PC2 (TCK) PC (SDA) PC (SCL) PD7 (OC2)

5 The structure of IO pins Mega32/Mega6 (XCK/T) PB (T) PB (INT2/AIN) PB2 (OC/AIN) PB3 (SS) PB4 (MOSI) PB5 (MISO) PB6 (SCK) PB7 RESET VCC GND XTAL2 XTAL (RXD) PD (TXD) PD (INT) PD2 (INT) PD3 (OCB) PD4 (OCA) PD5 (ICP) PD DDRB PORTB PINB DDRx.n DDRA PORTA PINA PORTx.n PINx.n PA (ADC) PA (ADC) PA2 (ADC2) PA3 (ADC3) PA4 (ADC4) PA5 (ADC5) PA6 (ADC6) PA7 (ADC7) AREF AGND AVCC PC7 (TOSC2) PC6 (TOSC) PC5 (TDI) PC4 (TDO) PC3 (TMS) PC2 (TCK) PC (SDA) PC (SCL) PD7 (OC2)

6 The structure of IO pins Mega32/Mega6 (XCK/T) PB (T) PB (INT2/AIN) PB2 (OC/AIN) PB3 (SS) PB4 DDRx: (MOSI) PB5 PORTx: (MISO) PB6 PINx: (SCK) PB7 RESET VCC GND XTAL2 XTAL (RXD) PD (TXD) PD (INT) PD2 (INT) PD3 (OCB) PD4 (OCA) PD5 (ICP) PD DDRB PORTB PINB DDRA PORTA PINA Px7 Px6 Px5 Px4 Px3 Px2 Px Px DDRx.n PORTx.n PINx.n PA (ADC) PA (ADC) PA2 (ADC2) PA3 (ADC3) PA4 (ADC4) PA5 (ADC5) PA6 (ADC6) PA7 (ADC7) AREF AGND AVCC PC7 (TOSC2) PC6 (TOSC) PC5 (TDI) PC4 (TDO) PC3 (TMS) PC2 (TCK) PC (SDA) PC (SCL) PD7 (OC2)

7 The structure of IO pins Mega32/Mega6 (XCK/T) PB (T) PB (INT2/AIN) PB2 (OC/AIN) PB3 (SS) PB4 DDRx: (MOSI) PB5 PORTx: (MISO) PB6 PINx: (SCK) PB7 RESET VCC GND XTAL2 XTAL (RXD) PD (TXD) PD (INT) PD2 (INT) PD3 (OCB) PD4 (OCA) PD5 (ICP) PD DDRB PORTB PINB DDRA PORTA PINA Px7 Px6 Px5 Px4 Px3 Px2 Px Px DDRx.n PORTx.n PINx.n PA (ADC) PA (ADC) PA2 (ADC2) PA3 (ADC3) PA4 (ADC4) PA5 (ADC5) PA6 (ADC6) PA7 (ADC7) AREF AGND AVCC PC7 (TOSC2) PC6 (TOSC) PC5 (TDI) PC4 (TDO) PORTx PC3 (TMS) PC2 (TCK) DDRx PC (SDA) PC (SCL) PD7 (OC2) high impedance pull-up Out Out

8 Example Write a program that makes all the pins of PORTA one. (XCK/T) PB DDRA: PORTA:.INCLUDE M32DEF.INC LDI R2,xFF ;R2 = (binary) OUT PORTA,R2 ;PORTA = R2 OUT DDRA,R2 ;DDRA = R2 (T) PB (INT2/AIN) PB2 (OC/AIN) PB3 (SS) PB4 (MOSI) PB5 (MISO) PB6 (SCK) PB7 RESET VCC GND XTAL2 XTAL (RXD) PD (TXD) PD (INT) PD2 (INT) PD3 (OCB) PD4 (OCA) PD5 (ICP) PD6 Mega32/Mega6 PINB DDRB PORTB PINA DDRA PORTA PORTC DDRC PINC PA (ADC) PA (ADC) PA2 (ADC2) PA3 (ADC3) PA4 (ADC4) PA5 (ADC5) PA6 (ADC6) PA7 (ADC7) AREF AGND AVCC PC7 (TOSC2) PC6 (TOSC) PC5 (TDI) PC4 (TDO) PC3 (TMS) PC2 (TCK) PC (SDA) PC (SCL) PD7 (OC2) PORTx DDRx high impedance Out pull-up Out

9 Example 2 The following code will toggle all 8 bits of Port B forever with some time delay between on and off states: LDI R6,xFF ;R6 = xff = b OUT DDRB,R6 ;make Port B an output port ( ) L: LDI R6,x55 ;R6 = x55 = b OUT PORTB,R6 ;put x55 on port B pins CALL DELAY LDI R6,xAA ;R6 = xaa = b OUT PORTB,R6 ;put xaa on port B pins CALL DELAY RJMP L

10 Example 3 A 7-segment is connected to PORTA. Display on the 7-segment. DDRC : PORTC:.INCLUDE M32DEF.INC LDI R2,x6 ;R2 = (binary) OUT PORTC,R2 ;PORTC = R2 LDI R2,xFF ;R2 = (binary) OUT DDRC,R2 ;DDRC = R2 L: RJMP L ATmega32 PORTx PORTC DDRx high impedance Out pull-up Out 2

11 Example 4 A 7-segment is connected to PORTA. Display 3 on the 7-segment. DDR: PORTC:.INCLUDE M32DEF.INC LDI R2,x4F ;R2 = (binary) OUT PORTC,R2 ;PORTC = R2 LDI R2,xFF ;R2 = (binary) OUT DDRC,R2 ;DDRC = R2 L: RJMP L ATmega32 PORTx PORTC DDRx high impedance Out pull-up Out 2

12 Example 5: Input The following code gets the data present at the pins of port C and sends it to port B indefinitely, after adding the value 5 to it:.include "M32DEF.INC" LDI R6,x ;R6 = (binary) OUT DDRC,R6 ;make Port C an input port LDI R6,xFF ;R6 = (binary) OUT DDRB,R6 ;make Port B an output port( for Out) L2: IN R6,PINC ;read data from Port C and put in R6 LDI R7,5 ADD R6,R7 ;add 5 to it OUT PORTB,R6 ;send it to Port B RJMP L2 ;continue forever

13 Pull-up resistor vcc PORTx.n = Close = Open pin n of port x PINx.n Outside the AVR chip Inside the AVR chip

14 The structure of I/O pins P PUD RDx Q D DDRxn Q CLK DATA BUS WR DDRxn Pxn Sleep DDRx.n PORTx.n PINx.n SYNCHRONIZER Q RESET RRx OUTPUT D PORTxn Q CLK INPUT RESET WR PORTxn N D L Q Q D Q PINxn Q RPx RESET RESET CLK I/O

15 Example 6 Write a program that continuously sends out to Port C the alternating values of x55 and xaa..include "M32DEF.INC" LDI R6,xFF ;R6 = (binary) OUT DDRC,R6 ;make Port C an output port L: LDI R6,x55 ;R6 = x55 OUT PORTC,R6 ;put x55 on Port C pins LDI R6,xAA ;R6 = xaa OUT PORTC,R6 ;put xaa on Port C pins RJMP L

16 The structure of IO pins PORTx DDRx high impedance pull-up Out Out P PUD RDx Q D DDRxn Q CLK DATA BUS WR DDRxn RESET RRx Pxn Sleep Q D PORTxn Q CLK WR PORTxn SYNCHRONIZER RESET N D L Q Q D Q PINxn Q RPx RESET RESET CLK I/O

17 Input (Tri-state vs. pull up) P PUD RDx Pull-up Resistor Q D DDRxn Q CLK WR DDRxn DATA BUS RESET RRx Pxn Sleep Q D PORTxn Q RESET CLK WR PORTxn SYNCHRONIZER D Q D Q N L PINxn Q Q RESET RESET CLK I/O RPx The while the represents how the content of PORTx register affects the pull-up resistor; shows how a data can be read from a pin

18 Example 7 4 PIN DIP Write a program that reads from port A and writes it to port B..INCLUDE M32DEF.INC LDI R2,x OUT DDRA,R2 ;DDRA = R2 ;R2 = (binary) LDI R2,xFF ;R2 = (binary) OUT DDRB,R2 ;DDRB = R2 L: IN R2,PINA ;R2 = PINA (XCK/T) PB (T) PB (INT2/AIN) PB2 (OC/AIN) PB3 (SS) PB4 (MOSI) PB5 (MISO) PB6 (SCK) PB7 RESET VCC GND XTAL2 XTAL (RXD) PD (TXD) PD (INT) PD2 (INT) PD3 (OCB) PD4 (OCA) PD5 (ICP) PD MEGA PA (ADC) PA (ADC) PA2 (ADC2) PA3 (ADC3) PA4 (ADC4) PA5 (ADC5) PA6 (ADC6) PA7 (ADC7) AREF AGND AVCC PC7 (TOSC2) PC6 (TOSC) PC5 (TDI) PC4 (TDO) PC3 (TMS) PC2 (TCK) PC (SDA) PC (SCL) PD7 (OC2) OUT PORTB,R2 ;PORTB = R2 RJMP L PORTx DDRx high impedance pull-up Out Out

19 I/O bit manipulation programming

20 SBI and CBI instructions SBI (Set Bit in IO register) SBI ioreg, bit ;ioreg.bit = Examples: SBI PORTD, ;PORTD. = SBI DDRC,5 ;DDRC.5 = CBI (Clear Bit in IO register) CBI ioreg, bit ;ioreg.bit = Examples: CBI PORTD, ;PORTD. = CBI DDRC,5 ;DDRC.5 =

21 Example Write a program that toggles PORTA.4 continuously..include M32DEF.INC SBI DDRA,4 L: SBI PORTA,4 CBI PORTA,4 RJMP L

22 Example An LED is connected to each pin of Port D. Write a program to turn on each LED from pin D to pin D7. Call a delay module before turning on the next LED..INCLUDE "M32DEF.INC" LDI R2, xff OUT DDRD, R2 ;make PORTD an output port SBI PORTD, ;set bit PD CALL DELAY ;delay before next one SBI PORTD, ;turn on PD CALL DELAY ;delay before next one SBI PORTD,2 ;turn on PD2 CALL DELAY SBI PORTD,3 CALL DELAY SBI PORTD,4 CALL DELAY SBI PORTD,5 CALL DELAY SBI PORTD,6 CALL DELAY SBI PORTD,7 CALL DELAY

23 SBIC and SBIS SBIC (Skip if Bit in IO register Cleared) SBIC ioreg, bit ; if (ioreg.bit = ) skip next instruction Example: SBIC PORTD, ;skip next instruction if PORTD.= INC LDI R2 R9,x23 SBIS (Skip if Bit in IO register Set) SBIS ioreg, bit ; if (ioreg.bit = ) skip next instruction Example: SBIS PORTD, ;skip next instruction if PORTD.= INC LDI R2 R9,x23

24 Example Write a program to perform the following: (a) Keep monitoring the PB2 bit until it becomes HIGH; (b) When PB2 becomes HIGH, write value $45 to Port C, and also send a HIGH-to-LOW pulse to PD3..INCLUDE "M32DEF.INC" CBI DDRB, 2 SBI PORTB,2 LDI R6, xff OUT DDRC, R6 SBI DDRD, 3 AGAIN: SBIS PINB, 2 RJMP AGAIN LDI R6, x45 OUT PORTC, R6 SBI PORTD, 3 CBI PORTD, 3 HERE: RJMP HERE ;make PB2 an input ;make Port C an output port ;make PD3 an output ;Skip if Bit PB2 is HIGH ;keep checking if LOW ;write x45 to port C ;set bit PD3 (H-to-L) ;clear bit PD3

25 Example A switch is connected to pin PB and an LED to pin PB7. Write a program to get the status of SW and send it to the LED. 4.7k Switch VCC PB AVR PB7 27 LED.INCLUDE "M32DEF.INC" CBI DDRB, SBI DDRB,7 AGAIN: SBIC PINB, RJMP OVER CBI PORTB,7 RJMP AGAIN OVER: SBI PORTB,7 RJMP AGAIN ;make PB an input ;make PB7 an output ;skip next if PB is clear ;(JMP is OK too) ;we can use JMP too ;we can use JMP too

26 Arithmetic and Logic Chapter 5 The AVR microcontroller and embedded systems using assembly and c

27 Objectives The concept of signed numbers and 2 complement Addition and subtraction instructions Carry and overflow Logical instruction and masking Compare instruction and branching Shift, Rotate and Data serialization BCD, Packed BCD and ASCII conversion.

28 34 =? =? 34 = (99-34) + Some ideas 34 9 =? = 34 + (99-9)+ -

29 =? = + =A = + A =

30 ADD instructions ADD Rd,Rr ;Rd = Rd + Rr ( Direct or immediate are not supported)

31 ADD instructions ADD Rd,Rr ;Rd = Rd + Rr ( Direct or immediate are not supported)

32 ADC instructions

33 SUB instruction SUB Rd,Rr ;Rd = Rd - Rr ( immediate are not supported) SUB Rd,Rr ; Rd = Rd K

34 SBC instruction SBC Rd,Rr ;Rd = Rd Rr-C ( immediate are not supported) SBIc Rd,Rr ;Rd = Rd K-C (H) - 96 (H) CC (H)

35 Multiplication and Division

36 Logic Instructions AND Rd,Rr ;Rd = Rd AND Rr OR Rd,Rr ;Rd = Rd OR Rr EOR Rd,Rr ;Rd = Rd XOR Rr ( immediate are not supported) COM Rd,Rr ;Rd = Complement of Rd ( Rd) NEG Rd,Rr ;Rd = 2 Complement of Rd ( Rd) AND is used to clear an specific bit/s of a byte OR is used to set an specific bit/s of a byte

37 Setting and Clearing bits AND Rd,Rr ;Rd = Rd AND Rr OR Rd,Rr ;Rd = Rd OR Rr EOR Rd,Rr ;Rd = Rd XOR Rr ( immediate are not supported) COM Rd,Rr ;Rd = Complement of Rd ( Rd) NEG Rd,Rr ;Rd = 2 Complement of Rd ( Rd) AND is used to clear an specific bit/s of a byte OR is used to set an specific bit/s of a byte AND OR

38 Branch and CP Instructions CP Rd,Rr ;Rd Rr (only flags are set) BRVC is used to branch when overflow is clear to zero BRVS is used to branch when overflow is set to one

39 ROR instruction ROR Rd ;Rd (only flags are set) In ROR, as bits are rotated from left to right, the carry flag enters the MSB and the LSB exits to the carry flag. In other words, in ROR the C is moved to the MSB, and the LSB is moved to the C. See what happens to after running 3 ROR instructions: CLC ;make C = (carry is ) LDI R2, x26 ;R2 = ROR R2 ;R2 = C = ROR R2 ;R2 = C = ROR R2 ;R2 = C =

40 ROL instruction ROR Rd ;Rd (only flags are set) ROL. In ROL, as bits are shifted from right to left, the carry flag enters the LSB and the MSB exits to the carry flag. In other words, in ROL the C is moved to the LSB, and the MSB is moved to the C. SEC ;make C = (carry is ) LDI R2,x5 ;R2 = ROL R2 ;R2 = C = ROL R2 ;R2 = C = ROL R2 ;R2 = C = ROL R2 ;R2 = C =

41 LSL instruction LSL Rd ;logical shift left In LSL, as bits are shifted from right to left, enters the LSB and the MSB exits to the carry flag. In other words, in LSL is moved to the LSB, and the MSB is moved to the C. this instruction multiplies content of the register by 2 assuming that after LSL the carry flag is not set. In the next code you can see what happens to after running 3 LSL instructions. CLC ;make C = (carry is ) LDI R2, x26 ;R2 = (38) c = LSL R2 ;R2 = (74) C = LSL R2 ;R2 = (48) C = LSL R2 ;R2 = (98) C = as C= and content of R2 ;is not multiplied by 2

42 ROR Rd ;Rd (only flags are set) In LSR, as bits are shifted from left to right, enters the MSB and the LSB exits to the carry flag. In other words, in LSR is moved to the MSB, and the LSB is moved to the C. this instruction divides content of the register by 2 and carry flag contains the remainder of division. In the next code you can see what happens to after running 3 LSL instructions. LDI R2,x26 ;R2 = (38) LSR R2 ;R2 = (9) C = LSR R2 ;R2 = (9) C = LSR R2 ;R2 = (4) C =

43 ASR Instruction ROR Rd ;Rd (only flags are set) ASR means arithmetic shift right. ASR instruction can divide signed number by 2. In LSR, as bits are shifted from left to right, MSB is held constant and the LSB exits to the carry flag. In other words MSB is not changed but is copied to D6, D6 is moved to D5, D5 is moved to D4 and so on. In the next code you can see what happens to after running 5 ASL instructions. LDI R2, D6 ;R2 = (-48) c = LSL R2 ;R2 = (-24) C = LSL R2 ;R2 = (-2) C = LSL R2 ;R2 = (-6) C = LSL R2 ;R2 = (-3) C = LSL R2 ;R2 = (-) C =

44 BCD, Packed BCD and ASCII conversion. ASCII BCD Codes Packed BCD BCD Codes BCD BCD ASCII and BCD Codes for Digits 9

45 Packed BCD to ASCII conversion To convert packed BCD to ASCII: you must first convert it to unpacked BCD. Then the unpacked BCD is tagged with (3H). Packed BCD = Un packed BCD =, ACSII =,

46 Advanced Assembly Chapter 6 The AVR microcontroller and embedded systems using assembly and c

47 Topics Assembler directives Addressing modes Macro EEPROM memory Checksum

48 Some Assembler directives Example + LDI R2,5+3 ;LDI R2,8 - LDI R3,9-3 ;LDI R3,6 * LDI R25,5*7 ;LDI R25,35 / LDI R9,8/2 ;LDI R9,4 Example & LDI R2,x5&x ;LDI R2,x LDI R25,x5 x ;LDI R25,x5 ^ LDI R23,x5^x ;LDI R23,x4 Example << LDI R6, x<< ;LDI R6,x2 >> LDI R6, x8 >>2 ;LDI R6,x2

49 HIGH and LOW LDI LDI R2, LOW(x234) R2, HIGH(x234) LDI R2, $34 LDI R2, $2 $234 HIGH LOW LDI R2, LOW(-2) LDI R2, $FF LDI R2, HIGH(-2) LDI R2, $38-2 = $FF38 HIGH LOW

50 Single Register Addressing Mode Single Register Addressing Mode INC Rd INC R9 DEC Rd DEC R23 ;R23 = R23 2 bits Op. Code 4 bits Rd GPRs d 3

51 Immediate Addressing Mode (Single register with immediate) 4 bits Op. Code 8 bits Immediate 4 bits Rd GPRs LDI Rd,K LDI R9,25 SUBI Rd,K SUBI R23,5 ;R23 = R23 5 d 3 ANDI Rd,K ANDI R2,x5

52 Two-register addressing mode 6 bits Op. Code 5 bits Rr 5 bits Rd GPRs d r ADD Rd,Rr ADD R26,R23 SUB Rd,Rr LDI R2,R 3

53 Direct addressing mode LDS Rd,address LDS R9,x33 STS address,rs STS x95,r Op. Code Rr/Rd Data Address 6 5 Data Space Note: RAMEND has been used to represent the highest location in data space. RAMEND

54 I/O direct addressing mode OUT address, Rs OUT x7,r6 IN Rs,address IN R9,x9 5 Op. Code Rr/Rd 5 A I/O Memory A 63

55 Register indirect addressing mode LD Rd,X Data Space LD R24,X 5 X, Y, OR Z - REGISTER LD R9,Y LD R2,Z ST X,Rd ST X,R8 ST Y,R2 Note: RAMEND has been used to represent the highest location in data space. RAMEND 5 XH XL X register : 7 7 R27 R26 5 YH YL Y register : 7 7 R29 R28 5 ZH ZL Z register : 7 7 R3 R3

56 Example Write a program to copy the value $55 into memory locations $4 to $44 LDI R9,x5 ;R9 = 5 (R9 for counter) LDI R6,x55 ;load R6 with value x55 (value to be copied) LDI YL,x4 ;load the LDI low byte YL,LOW(x4) of Y with value x4 LDI YH,x ;load the LDI high YH,HIGH(x4) byte of Y with value x L: ST Y,R6 ;copy R6 to memory location x4 INC YL ;increment the low byte of Y DEC R9 ;decrement the counter BRNE L ;loop until counter = zero

57 Auto-increment and Auto decrement Register indirect addressing with Post-increment LD Rd, X+ 5 X, Y, OR Z - REGISTER Data Space LD R2,X+ ST X+, Rs ST X+, R8 + RAMEND Register indirect addressing with Pre-decrement LD Rd, -X 5 X, Y, OR Z - REGISTER Data Space LD R9,-X ST X,R3 - + RAMEND

58 Example Write a program to copy the value $55 into memory locations $4 to $444 LDI R9,x5 ;R9 = 5 (R9 for counter) LDI R6,x55 ;load R6 with value x55 (value to be copied) LDI YL,LOW($4) ;load the low byte of Y with value x4 LDI YH,HIGH($4) ;load the high byte of Y with value x L: ST Y+,R6 ;copy R6 to memory location Y DEC R9 ;decrement the counter BRNE L ;loop until counter = zero

59 Register indirect with displacement STD Z+q,Rr ;store Rr into location Z+q STD Z+5,R2 ;store R2 in location Z+5 LDD Rd, Z+q ;load from Z+q into Rd LDD R2, Z+8 ;load from Z+8 into R2 5 Y OR Z - REGISTER Data Space + 5 Op. 5 Rr/Rd 6 5 q RAMEND

60 Storing fixed data in flash memory DATA:.DB 28 ;DECIMAL(C in hex) DATA2:.DB b ;BINARY (35 in hex) DATA3:.DB x39 ;HEX DATA4:.DB 'Y' ;single ASCII char DATA6:.DB "Hello ALI";ASCII string

61 Storing fixed data in flash memory LPM Rd, Z LPM R5, Z Example: LDI R3,x8 LDI R3, LPM R8,Z ;read from the low byte of loc x4 LPM Rd, Z+ LPM R2,Z Program Memory 5 LSB Z - REGISTER FLASHEND

62 Storing fixed data in flash memory LPM Rd, Z LPM R5, Z Example: LDI R3,x8 LDI R3, Low High Address $ $ $ LPM R8,Z ;read from the low byte of loc x4 LPM Rd, Z+ LPM R2,Z Program Memory 5 LSB Z - REGISTER 5 5 Low High Address $2 $3 8 7 $ $4 $5 $2 $6 $7 $3 $8 $9 $4 $A $B $5 FLASHEND.... $FFFC $FFFD $7FFE $FFFE $FFFF $7FFF

63 Example Analyze the following program; then rewrite it using LPM R2,Z+.ORG $ ;burn into ROM starting at LDI R2,xFF OUT DDRB,R2 ;make PB an output LDI ZL, LOW(MYDATA<<) ;ZL = look-up table low-byte addr LDI ZH,HIGH(MYDATA<<) ;ZH = A look-up table high-byte addr LPM R2,Z LPM R2,Z+ OUT PORTB,R2 ;send it OUT to Port BPORTB,R2 INC ZL ;R3 = pointing to next byte (A) LPM R2,Z ;load R2 LPMwith 'S' R2,Z+ char pointed to by Z OUT PORTB,R2 ;send it OUT to Port BPORTB,R2 INC ZL ;R3 = 2 pointing to next (A2) LPM R2,Z ;load R2 with 'A' char pointed to by Z OUT PORTB,R2 ;send it to Port B HERE: RJMP HERE ;stay here forever ;data is burned into code(program) space starting at $5.ORG $5 MYDATA:.DB "USA"

64 Example Assume that ROM space starting at $5 contains the message The Promise of World Peace. Write a program to bring it into CPU one byte at a time and place the bytes in RAM locations starting at $4..ORG ;burn into ROM starting at LDI ZL, LOW(MYDATA<<) ;R3 = low-byte addr LDI ZH, HIGH(MYDATA<<) ;R3 = A, high-byte addr LDI XL, LOW(x4) ;R26 = 4, low-byte RAM address LDI XH, HIGH(x4) ;R27 =, high-byte RAM address AGAIN: LPM R6, Z+ ;read the table, then increment Z CPI R6, ;compare R6 with BREQ END ;exit if end of string ST X+, R6 ;store R6 in RAM and inc X RJMP AGAIN END: RJMP END.ORG x5 ;data burned starting at x5 MYDATA:.DB "The Promise of World Peace",

65 Macro.MACRO INITSTACK LDI R6,HIGH(RAMEND) OUT SPH,R6 LDI R6,LOW(RAMEND) OUT SPL,R6.ENDMACRO INITSTACK

66 Macro.MACRO LOADIO LOADIO DDRB,xFF LOADIO PORTB,x55

67 EEPROM EEPROM is a place to store data. It is not deleted when power is off ATmega32 has 24 bytes of EEPROM In AVR 3 registers are dedicated to EEPROM EEARH:EEARL EEDR EECR Bit EEARH EEARL Bit 5 - EEAR7 7 EEPROM Address Register 4 5 EEARH EEARL - EEAR EEAR EEAR4 4 - EEAR3 3 - EEAR2 2 9 EEAR9 EEAR 8 EEAR8 EEAR EECR EEDR EEPROM 23

68 EEPROM EEPROM is a place EEPROM to Data store Register data. It is not deleted when power is off ATmega32 has 24 bytes of EEPROM In AVR 3 registers are dedicated to EEPROM EEARH:EEARL EEDR EECR Bit EEARH EEARL Bit 5 - EEAR7 7 EEPROM Address Register 4 5 EEARH EEARL - EEAR EEAR EEAR4 4 - EEAR3 3 - EEAR2 2 9 EEAR9 EEAR 8 EEAR8 EEAR EECR EEDR EEPROM 23

69 EEPROM EEPROM is a place EEPROM to Data store Register data. It is not deleted when power is EEPROM off Control Register ATmega32 has 24 bytes of EEPROM In AVR 3 registers are dedicated to EEPROM EEARH:EEARL EEDR EECR Bit EEARH EEARL Bit 5 - EEAR7 7 EEPROM Address Register 4 5 EEARH EEARL - EEAR EEAR EEAR4 4 - EEAR3 3 - EEAR2 2 9 EEAR9 EEAR 8 EEAR8 EEAR EECR EEDR EEPROM 23

70 Reading from EEPROM. Wait until EEWE becomes zero. 2. Write new EEPROM address to EEAR (optional) 3. Set EERE to one. 4. Read EEPROM data from EEDR.

71 Writing into EEPROM. Wait until EEWE becomes zero. 2. Write new EEPROM address to EEAR (optional). 3. Write new EEPROM data to EEDR (optional). 4. Set EEMWE bit to one. 5. Within four clock cycles after setting EEMWE, set EEWE to one.

72 Writing into EEPROM. Wait until EEWE becomes zero. 2. Write new EEPROM address to EEAR (optional). 3. Write new EEPROM data to EEDR (optional). 4. Set EEMWE bit to one. 5. Within four clock cycles after setting EEMWE, set EEWE to one.

73 Checksum To detect data corruption Calculating checksum byte: Add the bytes together and drop the carries Take the 2 s complement of the total sum Testing checksum Add the bytes together and drop the carries Add the checksum byte to the sum If the result is not zero, data is corrupted

74 Example Find the checksum byte for the followings: $25, $62, $3F, $52 Solution: $25 + $62 + $3F + $52 $ 8 Checksum byte = 2 s complement of $8 = $E8

75 Example The checksum byte is $E8. Test checksum for the following data: Solution: $25, $62, $3F, $52 $25 + $62 + $3F + $52 + $E8 $ not corrupted

Objectives. I/O Ports in AVR. Topics. ATmega16/mega32 pinout. AVR pin out The structure of I/O pins I/O programming Bit manipulating 22/09/2017

Objectives. I/O Ports in AVR. Topics. ATmega16/mega32 pinout. AVR pin out The structure of I/O pins I/O programming Bit manipulating 22/09/2017 Objectives The AVR microcontroller and embedded systems using assembly and c I/O Ports in AVR List all the ports of the AVR microcontroller Describe the dual role of the AVR pins Code assembly language

More information

Programming Microcontroller Assembly and C

Programming Microcontroller Assembly and C Programming Microcontroller Assembly and C Course Number CLO : 2 Week : 5-7 : TTH2D3 CLO#2 Student have the knowledge to create basic programming for microcontroller [C3] Understand how to program in Assembly

More information

Review on Lecture-1. ICT 6641: Advanced Embedded System. Lecture 2 Branch, Call and Delay Loops, AVR I/O port programming

Review on Lecture-1. ICT 6641: Advanced Embedded System. Lecture 2 Branch, Call and Delay Loops, AVR I/O port programming ICT 6641: Advanced Embedded System Lecture 2 Branch, Call and Delay Loops, AVR I/O port programming Prof. S. M. Lutful Kabir Session: April, 2011 Review on Lecture-1 Three parts of a computer : CPU, Memory

More information

EE 308: Microcontrollers

EE 308: Microcontrollers EE 308: Microcontrollers Review Part I Aly El-Osery Electrical Engineering Department New Mexico Institute of Mining and Technology Socorro, New Mexico, USA February 15, 2018 Aly El-Osery (NMT) EE 308:

More information

By: Dr. Hamed Saghaei

By: Dr. Hamed Saghaei By: Dr. Hamed Saghaei The AVR RISC Microcontroller supports powerful and efficient addressing modes for access to the program memory (Flash) and data memory (SRAM). This section describes the different

More information

COMP2121: Microprocessors and Interfacing. I/O Devices (I)

COMP2121: Microprocessors and Interfacing. I/O Devices (I) COMP2121: Microprocessors and Interfacing I/O Devices (I) http://www.cse.unsw.edu.au/~cs2121 Lecturer: Hui Wu Session 2, 2017 1 Overview I/O Ports AVR Ports 2 2 What is I/O? I/O is Input or Output (Input/Output).

More information

AVR ISA & AVR Programming (I) Lecturer: Sri Parameswaran Notes by: Annie Guo

AVR ISA & AVR Programming (I) Lecturer: Sri Parameswaran Notes by: Annie Guo AVR ISA & AVR Programming (I) Lecturer: Sri Parameswaran Notes by: Annie Guo 1 Lecture Overview AVR ISA AVR Instructions & Programming (I) Basic construct implementation 2 Atmel AVR 8-bit RISC architecture

More information

University of Kashan Faculty of Electrical and Computer Engineering Department of Computer Engineering. Lecture note 2

University of Kashan Faculty of Electrical and Computer Engineering Department of Computer Engineering. Lecture note 2 University of Kashan Faculty of Electrical and Computer Engineering Department of Computer Engineering Lecture note 2 Memory and IO Interfacing to & An Introduction to AVR Microcontrollers Hossein Sabaghian-Bidgoli

More information

CMPE C Programming & Embedded Systems. Discussion I (Version 2.0) August 31, 2014

CMPE C Programming & Embedded Systems. Discussion I (Version 2.0) August 31, 2014 CMPE 311 - C Programming & Embedded Systems Discussion I (Version 2.0) August 31, 2014 Version History Version 2.1 - (August 31, 2015) - Addition Pin Connections Section and Document Verification. Version

More information

AVR ISA & AVR Programming (I) Lecturer: Sri Parameswaran Notes by: Annie Guo

AVR ISA & AVR Programming (I) Lecturer: Sri Parameswaran Notes by: Annie Guo AVR ISA & AVR Programming (I) Lecturer: Sri Parameswaran Notes by: Annie Guo 1 Lecture Overview AVR ISA AVR Instructions & Programming (I) Basic construct implementation 2 Atmel AVR 8-bit RISC architecture

More information

AT90S Bit Microcontroller with 1K bytes Downloadable Flash AT90S1200. Features. Description. Pin Configuration

AT90S Bit Microcontroller with 1K bytes Downloadable Flash AT90S1200. Features. Description. Pin Configuration Features Utilizes the AVR Enhanced RISC Architecture 89 Powerful Instructions - Most Single Clock Cycle Execution 1K bytes of In-System Reprogrammable Downloadable Flash - SPI Serial Interface for Program

More information

AVR ISA & AVR Programming (I)

AVR ISA & AVR Programming (I) AVR ISA & AVR Programming (I) Lecturer: Sri Parameswaran Notes by: Annie Guo Week 1 1 Lecture Overview AVR ISA AVR Instructions & Programming (I) Basic construct implementation Week 1 2 1 Atmel AVR 8-bit

More information

8-bit Microcontroller with 8K Bytes Programmable Flash AT90C8534. Preliminary

8-bit Microcontroller with 8K Bytes Programmable Flash AT90C8534. Preliminary Features Utilizes the AVR RISC Architecture AVR High-performance and Low-power RISC Architecture 118 Powerful Instructions Most Single Clock Cycle Execution 32 x 8 General-purpose Working Registers Up

More information

Module 2: Introduction to AVR ATmega 32 Architecture

Module 2: Introduction to AVR ATmega 32 Architecture Module 2: Introduction to AVR ATmega 32 Architecture Definition of computer architecture processor operation CISC vs RISC von Neumann vs Harvard architecture AVR introduction AVR architecture Architecture

More information

8-bit Microcontroller with 8K Bytes In-System Programmable Flash. ATmega8515 ATmega8515L. Features

8-bit Microcontroller with 8K Bytes In-System Programmable Flash. ATmega8515 ATmega8515L. Features Features High-performance, Low-power AVR 8-bit Microcontroller RISC Architecture 130 Powerful Instructions Most Single Clock Cycle Execution 32 x 8 General Purpose Working Registers Fully Static Operation

More information

8-Bit Microcontroller with 1K bytes In-System Programmable Flash AT90S1200. Features. Description. Pin Configuration

8-Bit Microcontroller with 1K bytes In-System Programmable Flash AT90S1200. Features. Description. Pin Configuration Features AVR - High Performance and Low Power RISC Architecture 89 Powerful Instructions - Most Single Clock Cycle Execution 1K bytes of In-System Reprogrammable Flash SPI Serial Interface for Program

More information

DESIGN NOTE #032. AVR Boot Loader. Introduction. Overview AUTHOR: MARIANO BARRÓN RUIZ KEYWORDS: BOOT LOADER, SPM, SELF-PROGRAMMING

DESIGN NOTE #032. AVR Boot Loader. Introduction. Overview AUTHOR: MARIANO BARRÓN RUIZ KEYWORDS: BOOT LOADER, SPM, SELF-PROGRAMMING DESIGN NOTE AUTHOR: #032 MARIANO BARRÓN RUIZ ISPBARUM@SB.EHU.ES KEYWORDS: BOOT LOADER, SPM, SELF-PROGRAMMING This document is originally distributed by AVRfreaks.net, and may be distributed, reproduced,

More information

Buses and Parallel Input/Output

Buses and Parallel Input/Output Buses and Parallel Input/Output Lecturer: Sri Parameswaran Notes by: Annie Guo Week7 1 Lecture Overview Buses Computer buses I/O Addressing Memory mapped I/O Separate I/O Parallel input/output AVR examples

More information

Assembly AVR Boot loader

Assembly AVR Boot loader Assembly AVR Boot loader Mariano Barrón Ruiz ispbarum@sb.ehu.es Introduction This document presents a software written in assembly for self-programming all AVR microcontrollers with Boot Loader Flash Section.

More information

8-bit Microcontroller with 1K Byte of In-System Programmable Flash AT90S1200

8-bit Microcontroller with 1K Byte of In-System Programmable Flash AT90S1200 Features Utilizes the AVR RISC Architecture AVR High-performance and Low-power RISC Architecture 89 Powerful Instructions Most Single Clock Cycle Execution 32 x 8 General-purpose Working Registers Up to

More information

;Compiler Options.NOLIST.INCLUDE "C:\Program Files (x86)\atmel\avr Tools\AvrAssembler2\Appnotes\m8515def.inc"

;Compiler Options.NOLIST.INCLUDE C:\Program Files (x86)\atmel\avr Tools\AvrAssembler2\Appnotes\m8515def.inc ;* CharTest.asm ;* ;* Created: 28/06/2017 9:37 p.m. ;* Author: ob1 ;ST7820 128 x 64 graphics mode character display 8 lines x 21 characters ;Modification and redistribution under provisions of GNU general

More information

Gates and flip-flops: glue logic, simple FSMs, registers Two-level PLDs: FSMs, muxes, decoders. Programmable logic devices (CSE370, CSE467)

Gates and flip-flops: glue logic, simple FSMs, registers Two-level PLDs: FSMs, muxes, decoders. Programmable logic devices (CSE370, CSE467) Computational hardware Digital logic (CSE370) Gates and flip-flops: glue logic, simple FSMs, registers Two-level PLDs: FSMs, muxes, decoders Programmable logic devices (CSE370, CSE467) Field-programmable

More information

8-bit Microcontroller with 2K Bytes of In-System Programmable Flash. ATtiny22 ATtiny22L. Preliminary. Features. Description

8-bit Microcontroller with 2K Bytes of In-System Programmable Flash. ATtiny22 ATtiny22L. Preliminary. Features. Description Features Utilizes the AVR RISC Architecture AVR - High-performance and Low-power RISC Architecture 118 Powerful Instructions - Most Single Clock Cycle Execution 32 x 8 General Purpose Working Registers

More information

READING SOURCE MATERIAL

READING SOURCE MATERIAL 1 P a g e General-Purpose Input/Output READING The AVR Microcontroller and Embedded Systems using Assembly and C) by Muhammad Ali Mazidi, Sarmad Naimi, and Sepehr Naimi Chapter 4: AVR I/O Port Programming

More information

8-Bit Microcontroller with 2K Bytes of In-System Programmable Flash. AT90S2323 AT90LS2323 AT90S2343 AT90LS2343 Preliminary AT90S/LS2323.

8-Bit Microcontroller with 2K Bytes of In-System Programmable Flash. AT90S2323 AT90LS2323 AT90S2343 AT90LS2343 Preliminary AT90S/LS2323. Features Utilizes the AVR Enhanced RISC Architecture AVR - High Performance and Low Power RISC Architecture 118 Powerful Instructions - Most Single Clock Cycle Execution 2K bytes of In-System Programmable

More information

8-bit Microcontroller with 4K Bytes of In-System Programmable Flash AT90S4433 AT90LS4433. Features. Not Recommend for New Designs. Use ATmega8.

8-bit Microcontroller with 4K Bytes of In-System Programmable Flash AT90S4433 AT90LS4433. Features. Not Recommend for New Designs. Use ATmega8. Features High-performance and Low-power AVR 8-bit RISC Architecture 118 Powerful Instructions Most Single Cycle Execution 32 x 8 General Purpose Working Registers Up to 8 MIPS Throughput at 8 MHz Data

More information

8-bit Microcontroller with 2K Bytes Flash. ATtiny26 ATtiny26L

8-bit Microcontroller with 2K Bytes Flash. ATtiny26 ATtiny26L Features High-performance, Low-power AVR 8-bit Microcontroller RISC Architecture 118 Powerful Instructions Most Single Clock Cycle Execution 32 x 8 General Purpose Working Registers Fully Static Operation

More information

Logic Instructions and Programs READING

Logic Instructions and Programs READING 1 P a g e Logic Instructions and Programs READING The AVR Microcontroller and Embedded Systems using Assembly and C) by Muhammad Ali Mazidi, Sarmad Naimi, and Sepehr Naimi Chapter 5: Arithmetic, Logic

More information

ECED 3204 Microprocessor Midterm Reference Solution

ECED 3204 Microprocessor Midterm Reference Solution ECED 3204 Microprocessor Midterm Reference Solution Date: October 26 2017 Time: 7:00pm-9:00pm Room: B225, B227, B229 Student name ID 1) Problem one has following two sub problems: a. Write an instruction

More information

AVR. 2. (Assembler directives ) 3. ( Instruction field) 5. (Comment field) 1. (Label field) Assembler. 4. ก (Operands field) (AVR Assembly Language)

AVR. 2. (Assembler directives ) 3. ( Instruction field) 5. (Comment field) 1. (Label field) Assembler. 4. ก (Operands field) (AVR Assembly Language) 3 AVR (AVR Assembly Language). ก ก ก /* * AVRAssembler1.asm * * Created: 9/7/2554 9:40:18 * Author: xp */.org 0 rjmp RESET ;Reset Handle rjmp RESET rjmp RESET RESET: ldi r16, 0b11111111 ;load register

More information

APPENDIX B AVR INSTRUCTIONS EXPLAINED OVERVIEW

APPENDIX B AVR INSTRUCTIONS EXPLAINED OVERVIEW APPENDIX B AVR INSTRUCTIONS EXPLAINED OVERVIEW In this appendix, we describe each intruction of the ATmega328. In many cases, a simple code example is given to clarify the instruction. Instructions are

More information

CN310 Microprocessor Systems Design

CN310 Microprocessor Systems Design CN310 Microprocessor Systems Design Instruction Set (AVR) Nawin Somyat Department of Electrical and Computer Engineering Thammasat University Outline Course Contents 1 Introduction 2 Simple Computer 3

More information

ATmega128 Assembly Language Programming

ATmega128 Assembly Language Programming 마이크로프로세서응용 7 ATmega128 Assembly Language Programming Assembly Language g Field Delimiter Field structure a space or colon after a label a space after the operation code a comma between operands in the

More information

8-bit Microcontroller with 16K Bytes In-System Programmable Flash. ATmega169V ATmega169. Features. Notice: Not recommended in new designs.

8-bit Microcontroller with 16K Bytes In-System Programmable Flash. ATmega169V ATmega169. Features. Notice: Not recommended in new designs. Features High Performance, Low Power AVR 8-Bit Microcontroller Advanced RISC Architecture 130 Powerful Instructions Most Single Clock Cycle Execution 32 x 8 General Purpose Working Registers Fully Static

More information

AVR. (AVR Assembly Language) Assembler . ก ก

AVR. (AVR Assembly Language) Assembler . ก ก AVR (AVR Assembly Language). ก ก Assembler 2 1 ก /* * AVRAssembler1.asm * * Created: 9/7/2554 9:40:18 * Author: xp */.org 0 rjmp RESET ;Reset Handle rjmp RESET rjmp RESET RESET: ldi r16, 0b11111111 ;load

More information

8-Bit Microcontroller with 2K bytes Downloadable Flash. AT90S2313 Preliminary. Features. Description. Pin Configuration

8-Bit Microcontroller with 2K bytes Downloadable Flash. AT90S2313 Preliminary. Features. Description. Pin Configuration Features Utilizes the AVR Enhanced RISC Architecture AVR - High Performance and Low Power RISC Architecture 120 Powerful Instructions - Most Single Clock Cycle Execution 2K bytes of In-System Reprogrammable

More information

8-bit Microcontroller with 8K Bytes In-System Programmable Flash AT90S8515

8-bit Microcontroller with 8K Bytes In-System Programmable Flash AT90S8515 Features Utilizes the AVR RISC Architecture AVR High-performance and Low-power RISC Architecture 118 Powerful Instructions Most Single Clock Cycle Execution 32 x 8 General-purpose Working Registers Up

More information

8-Bit MCU with Downloadable Flash. Application Note AVR100. AVR100: Accessing the EEPROM. Features. Introduction. Random Write - Subroutine EEWrite

8-Bit MCU with Downloadable Flash. Application Note AVR100. AVR100: Accessing the EEPROM. Features. Introduction. Random Write - Subroutine EEWrite AVR100: Accessing the EEPROM Features Random Read/Write Sequential Read/Write Runable Test/Example Program Introduction This application note contains routines for access of the EEPROM memory in the AVR

More information

8-bit Microcontroller with 2/4/8K Bytes In-System Programmable Flash. ATtiny261/V ATtiny461/V ATtiny861/V. Preliminary

8-bit Microcontroller with 2/4/8K Bytes In-System Programmable Flash. ATtiny261/V ATtiny461/V ATtiny861/V. Preliminary Features High Performance, Low Power AVR 8-Bit Microcontroller Advanced RISC Architecture 123 Powerful Instructions Most Single Clock Cycle Execution 32 x 8 General Purpose Working Registers Fully Static

More information

Arduino Diecimila Pinouts 697B B8D-A50A-61944C26074F

Arduino Diecimila Pinouts 697B B8D-A50A-61944C26074F mightwerk Resources for creators and innovators outs 697B1380-9797-4B8D-A50A-61944C26074F Introduction... 1 4-pin Expansion Header out... 2 6-pin ICSP Header out... 3 Map from to... 4 Map from ATmega328

More information

AT90S Bit Microcontroller with 8K bytes Downloadable Flash. AT90S8515 Preliminary. Features. Description. Pin Configurations

AT90S Bit Microcontroller with 8K bytes Downloadable Flash. AT90S8515 Preliminary. Features. Description. Pin Configurations Features Utilizes the AVR Enhanced RISC Architecture 120 Powerful Instructions - Most Single Clock Cycle Execution 8K bytes of In-System Reprogrammable Downloadable Flash - SPI Serial Interface for Program

More information

Robosoft Systems in association with JNCE presents. Swarm Robotics

Robosoft Systems in association with JNCE presents. Swarm Robotics Robosoft Systems in association with JNCE presents Swarm Robotics What is a Robot Wall-E Asimo ABB Superior Moti ABB FlexPicker What is Swarm Robotics RoboCup ~ 07 Lets Prepare for the Robotics Age The

More information

8-bit Microcontroller with 4K/8K bytes In-System Programmable Flash AT90S4414 AT90S8515. Features. Pin Configurations

8-bit Microcontroller with 4K/8K bytes In-System Programmable Flash AT90S4414 AT90S8515. Features. Pin Configurations Features Utilizes the AVR RISC Architecture AVR - High-performance and Low-power RISC Architecture 118 Powerful Instructions - Most Single Clock Cycle Execution 32 x 8 General Purpose Working Registers

More information

Topic 11: Interrupts ISMAIL ARIFFIN FKE UTM SKUDAI JOHOR

Topic 11: Interrupts ISMAIL ARIFFIN FKE UTM SKUDAI JOHOR Topic 11: Interrupts ISMAIL ARIFFIN FKE UTM SKUDAI JOHOR Objectives To become familiar with interrupts on the AVR Maskable and non-maskable Initialization Triggers To develop interrupt service routines

More information

APPENDIX A FOR SKEE3732 LABORATORY 1 SHEET

APPENDIX A FOR SKEE3732 LABORATORY 1 SHEET APPENDIX A FOR SKEE3732 LABORATORY 1 SHEET Other documents that are referred within this document are located at the link https://www.dropbox.com/sh/s16jri4eol3agl5/aaazn_w3p7fodjs-wi-xcenqa?dl=0 The ATmega32/ATmega2A

More information

COMP2121: Microprocessors and Interfacing. I/O Devices (II)

COMP2121: Microprocessors and Interfacing. I/O Devices (II) COMP2121: Microprocessors and Interfacing I/O Devices (II) http://www.cse.unsw.edu.au/~cs2121 Lecturer: Hui Wu Session 2, 2017 1 Overview Keyboard LCD (Liquid Crystal Display) 2 2 Input Switches (1/2)

More information

Embedded Systems and Software. LCD Displays

Embedded Systems and Software. LCD Displays Embedded Systems and Software LCD Displays Slide 1 Some Hardware Considerations Assume we want to drive an LED from a port. The AVRs can either source or sink current. Below is a configuration for sourcing.

More information

Chapter 4: Atmel s AVR 8-bit Microcontroller Part 1 Assembly Programming

Chapter 4: Atmel s AVR 8-bit Microcontroller Part 1 Assembly Programming Chapter 4: Atmel s AVR 8-bit Microcontroller Part 1 Assembly Programming Prof. Ben Lee Oregon State University School of Electrical Engineering and Computer Science Chapter Goals Understand how to program

More information

Microcontroller VU

Microcontroller VU 182.694 Microcontroller VU Martin Perner SS 2017 Featuring Today: A Deep Look into the Processor Core Getting Code onto the Microcontroller Chip Weekly Training Objective This week 1.2 Board test 2.1.1

More information

Input/Output Devices. Lecturer: Sri Parameswaran Notes by: Annie Guo

Input/Output Devices. Lecturer: Sri Parameswaran Notes by: Annie Guo Input/Output Devices Lecturer: Sri Parameswaran Notes by: Annie Guo 1 Lecture Overview Input devices Input switches Basics of switches Keypads Output devices LCD 2 Input Switches Most basic binary input

More information

8-bit Microcontroller with 2K Bytes of In-System Programmable Flash AT90S2323 AT90LS2323 AT90S2343 AT90S/LS2323. Features.

8-bit Microcontroller with 2K Bytes of In-System Programmable Flash AT90S2323 AT90LS2323 AT90S2343 AT90S/LS2323. Features. Features Utilizes the AVR RISC Architecture AVR - High-performance and Low-power RISC Architecture 118 Powerful Instructions - Most Single Clock Cycle Execution 32 x 8 General Purpose Working Registers

More information

8-bit Microcontroller with 2/4/8K Bytes In-System Programmable Flash. ATtiny261 ATtiny461 ATtiny861. Automotive

8-bit Microcontroller with 2/4/8K Bytes In-System Programmable Flash. ATtiny261 ATtiny461 ATtiny861. Automotive Features High Performance, Low Power AVR 8-Bit Microcontroller Advanced RISC Architecture 123 Powerful Instructions Most Single Clock Cycle Execution 32 x 8 General Purpose Working Registers Fully Static

More information

8-bit Microcontroller with 2K Bytes of In-System Programmable Flash AT90S2313

8-bit Microcontroller with 2K Bytes of In-System Programmable Flash AT90S2313 Features Utilizes the AVR RISC Architecture AVR High-performance and Low-power RISC Architecture 118 Powerful Instructions Most Single Clock Cycle Execution 32x8GeneralPurposeWorkingRegisters Up to 10

More information

FIFTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLOGY-MARCH 2014 EMBEDDED SYSTEMS (Common for CT,CM) [Time: 3 hours] (Maximum marks : 100)

FIFTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLOGY-MARCH 2014 EMBEDDED SYSTEMS (Common for CT,CM) [Time: 3 hours] (Maximum marks : 100) (Revision-10) FIFTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLOGY-MARCH 2014 EMBEDDED SYSTEMS (Common for CT,CM) [Time: 3 hours] (Maximum marks : 100) PART-A (Maximum marks : 10) I. Answer all

More information

AVR Microcontroller with Core Independent Peripherals and PicoPower technology

AVR Microcontroller with Core Independent Peripherals and PicoPower technology AVR Microcontroller with Core Independent Peripherals and PicoPower technology Introduction The picopower ATmega324PB is a low-power CMOS 8-bit microcontroller based on the AVR enhanced RISC architecture.

More information

8-bit Microcontroller with 1K Byte Flash. ATtiny11. ATtiny12

8-bit Microcontroller with 1K Byte Flash. ATtiny11. ATtiny12 Features Utilizes the AVR RISC Architecture High-performance and Low-power 8-bit RISC Architecture 90 Powerful Instructions Most Single Clock Cycle Execution 32 x 8 General Purpose Working Registers Up

More information

8-bit Atmel Microcontroller with 8/16K Bytes In-System Programmable Flash AT90PWM81 AT90PWM161

8-bit Atmel Microcontroller with 8/16K Bytes In-System Programmable Flash AT90PWM81 AT90PWM161 Features High performance, low power Atmel AVR 8-bit Microcontroller Advanced RISC architecture 131 powerful instructions - most single clock cycle execution 32 8 general purpose working registers Fully

More information

8-bit Instruction Set

8-bit Instruction Set Instruction Set Nomenclature Status Register (SREG) SREG: Status Register C: Carry Flag Z: Zero Flag N: Negative Flag V: Two s complement overflow indicator S: N V, For signed tests H: Half Carry Flag

More information

8-bit Instruction Set

8-bit Instruction Set Instruction Set Nomenclature Status Register (SREG) SREG: Status Register C: Carry Flag Z: Zero Flag N: Negative Flag V: Two s complement overflow indicator S: N V, For signed tests H: Half Carry Flag

More information

8-bit Microcontroller with 64K/128K Bytes In-System Programmable Flash. ATmega603 ATmega603L ATmega103 ATmega103L. Preliminary.

8-bit Microcontroller with 64K/128K Bytes In-System Programmable Flash. ATmega603 ATmega603L ATmega103 ATmega103L. Preliminary. Features Utilizes the AVR RISC Architecture AVR - High-performance and Low-power RISC Architecture 120/121 Powerful Instructions - Most Single Clock Cycle Execution 32 x 8 General Purpose Working Registers

More information

Lecture 14. Ali Karimpour Associate Professor Ferdowsi University of Mashhad

Lecture 14. Ali Karimpour Associate Professor Ferdowsi University of Mashhad Lecture 14 AUTOMATIC CONTROL SYSTEMS Ali Karimpour Associate Professor Ferdowsi University of Mashhad Lecture 4 The AVR Microcontroller Introduction to AVR CISC (Complex Instruction Set Computer) Put as

More information

8-bit Microcontroller with 2K Bytes of In-System Programmable Flash. ATtiny22L. Preliminary

8-bit Microcontroller with 2K Bytes of In-System Programmable Flash. ATtiny22L. Preliminary Features Utilizes the AVR RISC Architecture AVR - High-performance and Low-power RISC Architecture 118 Powerful Instructions - Most Single Clock Cycle Execution 32 x 8 General Purpose Working Registers

More information

8-bit Microcontroller with 40K Bytes In-System Programmable Flash. ATmega406. Preliminary

8-bit Microcontroller with 40K Bytes In-System Programmable Flash. ATmega406. Preliminary Features High Performance, Low Power AVR 8-bit Microcontroller Advanced RISC Architecture 24 Powerful Instructions - Most Single Clock Cycle Execution 32 x 8 General Purpose Working Registers Fully Static

More information

Module 8: Atmega32 Stack & Subroutine. Stack Pointer Subroutine Call function

Module 8: Atmega32 Stack & Subroutine. Stack Pointer Subroutine Call function Module 8: Atmega32 Stack & Subroutine Stack Pointer Subroutine Call function Stack Stack o Stack is a section of RAM used by the CPU to store information temporarily (i.e. data or address). o The CPU needs

More information

VCC PB2 (SCK/ADC1/T0/PCINT2) PB1 (MISO/AIN1/OC0B/INT0/PCINT1) PB0 (MOSI/AIN0/OC0A/PCINT0)

VCC PB2 (SCK/ADC1/T0/PCINT2) PB1 (MISO/AIN1/OC0B/INT0/PCINT1) PB0 (MOSI/AIN0/OC0A/PCINT0) Features High Performance, Low Power AVR 8-Bit Microcontroller Advanced RISC Architecture 120 Powerful Instructions Most Single Clock Cycle Execution 32 x 8 General Purpose Working Registers Fully Static

More information

AVR Logical and Bitwise Instructions

AVR Logical and Bitwise Instructions AVR Logical and Bitwise Instructions Assembly Language Programming SDSMT Dr. Randy C. Hoover Boolean Logic An algebraic system for Boolean data Set: {false, true) Operations: and, or, not The operations

More information

8-bit Microcontroller with 128K Bytes In-System Programmable Flash. ATmega103 ATmega103L

8-bit Microcontroller with 128K Bytes In-System Programmable Flash. ATmega103 ATmega103L Features Utilizes the AVR RISC Architecture AVR High-performance and Low-power RISC Architecture 121 Powerful Instructions Most Single Clock Cycle Execution 32 x 8 General Purpose Working Registers + Peripheral

More information

Speed and Size-Optimized Implementations of the PRESENT Cipher for Tiny AVR Devices

Speed and Size-Optimized Implementations of the PRESENT Cipher for Tiny AVR Devices Speed and Size-Optimized Implementations of the PRESENT Cipher for Tiny AVR Devices Kostas Papagiannopoulos Aram Verstegen July 11, 2013 Papagiannopoulos and Verstegen July 11, 2013 Speed and Size-Optimized

More information

EMB128. ere co., ltd.

EMB128. ere co., ltd. ATMEGA128 Embedded Board Main Features Atmega128 8-bit RISC CPU (AVR family) Serial EEPROM (I2C), 24LC256 Real Time Clock, DS1307 3V lithium battery keeping time and date 2 channels RS485 2 channels RS232

More information

ก AVR Microcontrollers

ก AVR Microcontrollers ก AVR Microcontrollers. ก ก AVR Microcontrollers Architecture 1 Instruction Execution Timing The Parallel Instruction Fetches and Instruction Executions Single Cycle ALU Operation AVR Microcontrollers

More information

ET-BASE AVR ATmega64/128

ET-BASE AVR ATmega64/128 ET-BASE AVR ATmega64/128 ET-BASE AVR ATmega64/128 which is a Board Microcontroller AVR family from ATMEL uses MCU No.ATmega64 and ATmega128 64PIN. Board ET-BASE AVR ATmega64/128 uses MCU s resources on

More information

Microprocessors & Interfacing

Microprocessors & Interfacing Lecture Overview Microprocessors & Interfacing Input/Output Devices Input devices Input switches Basics of switches Keypads Output devices LCD Lecturer : Dr. Annie Guo S2, 2008 COMP9032 Week8 1 S2, 2008

More information

2 Basic operations with AT90S1200 and TINY12

2 Basic operations with AT90S1200 and TINY12 2 Basic operations with AT90S1200 and TINY12 The best way to learn is through example and by doing things yourself. For the rest of the book we will cover example projects, many of which will be largely

More information

Introduction to Assembly language

Introduction to Assembly language Introduction to Assembly language 1 USING THE AVR MICROPROCESSOR Outline Introduction to Assembly Code The AVR Microprocessor Binary/Hex Numbers Breaking down an example microprocessor program AVR instructions

More information

COMP2121: Microprocessors and Interfacing. AVR Assembly Programming (I) Basic AVR Instructions

COMP2121: Microprocessors and Interfacing. AVR Assembly Programming (I) Basic AVR Instructions COMP2121: Microprocessors and Interfacing AVR Assembly Programming (I) Basic AVR Instructions http://www.cse.unsw.edu.au/~cs2121 Lecturer: Hui Wu Session 2, 2017 1 1 Contents Arithmetic and Logic Instructions

More information

CHAPTER 6 ARITHMETIC, LOGIC INSTRUCTIONS, AND PROGRAMS

CHAPTER 6 ARITHMETIC, LOGIC INSTRUCTIONS, AND PROGRAMS CHAPTER 6 ARITHMETIC, LOGIC INSTRUCTIONS, AND PROGRAMS Addition of Unsigned Numbers The instruction ADD is used to add two operands Destination operand is always in register A Source operand can be a register,

More information

Embedded programming, AVR intro

Embedded programming, AVR intro Applied mechatronics, Lab project Embedded programming, AVR intro Sven Gestegård Robertz Department of Computer Science, Lund University 2017 Outline 1 Low-level programming Bitwise operators Masking and

More information

AVR Instruction Set Encoding

AVR Instruction Set Encoding 1 P age AVR Instruction Set Encoding READING 1. "AVR Instruction Set" document doc856 "The Program and Data Addressing Modes." 2. In this lecture I will teach you how to translate your assembly code into

More information

8-bit Microcontroller with 2K Bytes of Flash. ATtiny28L ATtiny28V

8-bit Microcontroller with 2K Bytes of Flash. ATtiny28L ATtiny28V Features Utilizes the AVR RISC Architecture AVR High-performance and Low-power RISC Architecture 90 Powerful Instructions Most Single Clock Cycle Execution 32 x 8 General-purpose Working Registers Up to

More information

Introduction to Microcontrollers

Introduction to Microcontrollers Motorola M68HC11 Specs Assembly Programming Language BUFFALO Topics of Discussion Microcontrollers M68HC11 Package & Pinouts Accumulators Index Registers Special Registers Memory Map I/O Registers Instruction

More information

ATMega16 AVR AVR AVR DIP. (in-circiut programming) desktop MOSI MOSIT. AVRProg. header. (toggle)

ATMega16 AVR AVR AVR DIP. (in-circiut programming) desktop MOSI MOSIT. AVRProg. header. (toggle) ATMega16 AVR AVR ATMega16 AVR AVR AVR DIP (in-circiut programming) desktop MOSI GND SK MISO MOSIT Ω Dontronic SK MISO AVRProg AVR109 JTAGIEII STK500 AVR header AVRProg clock I/O (toggle) clock GND V ATMega16

More information

EE 109 Unit 4. Microcontrollers (Arduino) Overview

EE 109 Unit 4. Microcontrollers (Arduino) Overview 1 EE 109 Unit 4 Microcontrollers (Arduino) Overview 2 Using software to perform logic on individual (or groups) of bits BIT FIDDLING 3 Numbers in Other Bases in C/C++ Suppose we want to place the binary

More information

INTERFACING HARDWARE WITH MICROCONTROLLER

INTERFACING HARDWARE WITH MICROCONTROLLER INTERFACING HARDWARE WITH MICROCONTROLLER P.Raghavendra Prasad Final Yr EEE What is a Microcontroller? A microcontroller (or MCU) is acomputer-on-a-chip. It is a type of microprocessor emphasizing self-

More information

8-bit Microcontroller with 16K Bytes In-System Programmable Flash. ATmega163 ATmega163L. Advance Information

8-bit Microcontroller with 16K Bytes In-System Programmable Flash. ATmega163 ATmega163L. Advance Information Features High-performance, Low-power AVR 8-bit Microcontroller 3 Powerful Instructions - Most Single Clock Cycle Execution 32 x 8 General Purpose Working Registers Fully Static Operation Up to 8 MIPS Throughput

More information

8-bit Microcontroller with 16K Bytes In-System Programmable Flash. ATmega163 ATmega163L

8-bit Microcontroller with 16K Bytes In-System Programmable Flash. ATmega163 ATmega163L Features High-performance, Low-power AVR 8-bit Microcontroller 3 Powerful Instructions - Most Single Clock Cycle Execution 32 x 8 General Purpose Working Registers Fully Static Operation Up to 8 MIPS Throughput

More information

COSC 243. Instruction Sets And Addressing Modes. Lecture 7&8 Instruction Sets and Addressing Modes. COSC 243 (Computer Architecture)

COSC 243. Instruction Sets And Addressing Modes. Lecture 7&8 Instruction Sets and Addressing Modes. COSC 243 (Computer Architecture) COSC 243 Instruction Sets And Addressing Modes 1 Overview This Lecture Source Chapters 12 & 13 (10 th editition) Textbook uses x86 and ARM (we use 6502) Next 2 Lectures Assembly language programming 2

More information

8-bit Microcontroller with 2K Bytes Flash. ATtiny26 ATtiny26L. Preliminary. Features

8-bit Microcontroller with 2K Bytes Flash. ATtiny26 ATtiny26L. Preliminary. Features Features High-performance, Low-power AVR 8-bit Microcontroller RISC Architecture 118 Powerful Instructions Most Single Clock Cycle Execution 32 x 8 General Purpose Working Registers Fully Static Operation

More information

ECED3204: Microprocessor Part I--Introduction

ECED3204: Microprocessor Part I--Introduction ECED3204: Microprocessor Part I--Introduction Jason J. Gu Department of 1 Outline i. Computer ii. Processor iii. Embedded System iv. Memory v. Program Execution VI. VII. VIII. IX. AVR AVR Memory AVR CPU

More information

Microprocessors And Microcontrollers (Practical)

Microprocessors And Microcontrollers (Practical) Microprocessors And Microcontrollers (Practical) Semester : 4 th, 5 th (TL, ES) Course Code : ES256, ES313 By: Dr. Attiya Baqai Assistant Professor, Department of Electronics, MUET. 3 Introduction to Programming

More information

DatasheetDirect.com. Visit to get your free datasheets. This datasheet has been downloaded by

DatasheetDirect.com. Visit  to get your free datasheets. This datasheet has been downloaded by DatasheetDirect.com Your dedicated source for free downloadable datasheets. Over one million datasheets Optimized search function Rapid quote option Free unlimited downloads Visit www.datasheetdirect.com

More information

AVR MICROCONTROLLER ARCHITECTURTE

AVR MICROCONTROLLER ARCHITECTURTE AVR MICROCONTROLLER ARCHITECTURTE AVR MICROCONTROLLER AVR- Advanced Virtual RISC. The founders are Alf Egil Bogen Vegard Wollan RISC AVR architecture was conceived by two students at Norwegian Institute

More information

ATmega8A. Introduction. Features. 8-bit AVR Microcontroller DATASHEET COMPLETE

ATmega8A. Introduction. Features. 8-bit AVR Microcontroller DATASHEET COMPLETE 8-bit AVR Microcontroller ATmega8A DATASHEET COMPLETE Introduction The Atmel ATmega8A is a low-power CMOS 8-bit microcontroller based on the AVR enhanced RISC architecture. By executing powerful instructions

More information

U6DIL. AVR USB Module. Rev. 1.1 Documentation Rev. 18. Reusch Elektronik Reusch Elektronik, Dipl.-Ing. (FH) Rainer Reusch

U6DIL. AVR USB Module. Rev. 1.1 Documentation Rev. 18. Reusch Elektronik Reusch Elektronik, Dipl.-Ing. (FH) Rainer Reusch AVR USB Module Documentation Rev. 18 2011, Dipl.-Ing. (FH) Rainer Reusch www.reusch-elektronik.de http://products.reworld.eu/u6dil.htm File: _Manual Created: 2011-02-22 Changed: 2011-03-31 Table of Contents

More information

Mechatronics and Microcomputers. Stipendium Hungaricum 2018/2019 Autumn Semester Szilárd Aradi, PhD

Mechatronics and Microcomputers. Stipendium Hungaricum 2018/2019 Autumn Semester Szilárd Aradi, PhD Mechatronics and Microcomputers Stipendium Hungaricum 2018/2019 Autumn Semester Szilárd Aradi, PhD ATmega128 CPU Single-level pipelining Egyciklusú ALU működés Reg. reg., reg. konst. közötti műveletek

More information

ATmegaS128. Introduction. Features

ATmegaS128. Introduction. Features Rad-Tol 8-bit AVR Microcontroller, 3.3V, 8 MHz with 128 KB Flash, 4 KB EEPROM, 4 KB SRAM, 10-bit ADC, TWI, RTC, 16-bit PWM, USART, SPI and 16-bit Timer/Counter Introduction The ATmegaS128 is a low-power

More information

8-bit Microcontroller with 4K/8K Bytes In-System Programmable Flash

8-bit Microcontroller with 4K/8K Bytes In-System Programmable Flash Features High Performance, Low Power AVR 8-bit Microcontroller Advanced RISC Architecture 124 Powerful Instructions - Most Single Clock Cycle Execution 32 x 8 General Purpose Working Registers Fully Static

More information

3.3V regulator. JA H-bridge. Doc: page 1 of 7

3.3V regulator. JA H-bridge. Doc: page 1 of 7 Digilent Cerebot Board Reference Manual Revision: 11/17/2005 www.digilentinc.com 215 E Main Suite D Pullman, WA 99163 (509) 334 6306 Voice and Fax Overview The Digilent Cerebot Board is a useful tool for

More information

The Atmel ATmega168A Microcontroller

The Atmel ATmega168A Microcontroller Ming Hsieh Department of Electrical Engineering EE 459Lx - Embedded Systems Design Laboratory The Atmel ATmega168A Microcontroller by Allan G. Weber 1 Introduction The Atmel ATmega168A is one member of

More information

EE 308: Microcontrollers

EE 308: Microcontrollers EE 308: Microcontrollers Timers Aly El-Osery Electrical Engineering Department New Mexico Institute of Mining and Technology Socorro, New Mexico, USA April 2, 2018 Aly El-Osery (NMT) EE 308: Microcontrollers

More information

8-bit Microcontroller with 4/8K Bytes In-System Programmable Flash. ATtiny48/88. Preliminary

8-bit Microcontroller with 4/8K Bytes In-System Programmable Flash. ATtiny48/88. Preliminary Features High Performance, Low Power AVR 8-Bit Microcontroller Advanced RISC Architecture 23 Powerful Instructions Most Single Clock Cycle Execution 32 x 8 General Purpose Working Registers Fully Static

More information