0% found this document useful (0 votes)
30 views13 pages

Data Transfer Instructions

The document discusses data transfer instructions and I/O ports for the Atmega8 microcontroller. It describes how to use the sbi, cbi, sbic, and sbis instructions to manipulate individual pins on ports B-D. It also explains how to use loops to generate delays and toggle port pins. The I/O ports each have a port register, data direction register, and pin register to control input and output.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views13 pages

Data Transfer Instructions

The document discusses data transfer instructions and I/O ports for the Atmega8 microcontroller. It describes how to use the sbi, cbi, sbic, and sbis instructions to manipulate individual pins on ports B-D. It also explains how to use loops to generate delays and toggle port pins. The I/O ports each have a port register, data direction register, and pin register to control input and output.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Data Transfer Instructions

Data Transfer Instructions


Data Transfer

R1
LPM LDS
R0

SPM R2 STS

R31

DATA MEMORY

PROGRAM MEMORY
Bit and Bit Test Instructions
NOTE >>
sbi and cbi don't operate on all I/O registers.

The same is true for sbic/sbis.

These can only be used for "classic" I/O Ports and other
peripheral registers with addresses from 0 to 31 (0x00 to
0x1F).
Assembler directives
The directives are not translated directly into opcodes. Instead, they are used to
adjust the location of the program in memory,

Define macros

Initialize memory

Giving symbolyc names to registers

Setting symbols equal to the expressions

Set program origin ……..etc


VMLAB
avrasm
For Loops
ldi r16, 0 ;clear the register
loop: out PORTB, r16 ;write register to port b
inc r16 ;inc the counter
cpi r16, 10 ;compare with 10
brne loop ;if less than 10 loop

ldi r16, 0
loop1: inc r16 ;this code differs slightly
out PortB, r16 ;find it
cpi r16, 10
brne loop1
Generating delay using loops
IO PORTS
Atmega8 is having total 3 i/o ports B-D

All the ports are bi/directional

PORTB ,PORTD are 8bit and PORTC is 7 bit

The AVR I/O Ports are pretty simple to understand. They have a Port register, a
Data Direction register and a Pin register. These are part of every I/O port in every
AVR.
PORT IO REGISTERS

PINB (8bit)

PORTB (8bit)

DDRB (8bit)
Port Diagram
IO instructions
The simplest I/O instructions are in and out.

in : reads the value of an I/O Port into a register.Example: in r16, PinB

out : writes the value of a register to an I/O Port

You might also like