0% found this document useful (0 votes)
27 views12 pages

Data Transfer Instructions

This document provides instructions for data transfer and bit operations in AVR microcontrollers. It discusses using macros to make code more readable, examples of for and while loops for I/O ports, and details the I/O registers PORTB, DDRB, and PINB. It also describes the in and out instructions for reading and writing to I/O ports and notes that port settings must be done before using these instructions.

Uploaded by

NamanKhatri
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)
27 views12 pages

Data Transfer Instructions

This document provides instructions for data transfer and bit operations in AVR microcontrollers. It discusses using macros to make code more readable, examples of for and while loops for I/O ports, and details the I/O registers PORTB, DDRB, and PINB. It also describes the in and out instructions for reading and writing to I/O ports and notes that port settings must be done before using these instructions.

Uploaded by

NamanKhatri
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/ 12

DATA TRANSFER INSTRUCTIONS

Some more instruction

BIT AND BIT-TEST INSTRUCTIONS

macros

Macros are a good way to make code more readable, for


example if it contains code that is often reused or if a lot of 16-bit
calculations are done.
Macros in AVR assembler can be defined everywhere in the
code as long as they're not used at a location before the macro
definition
.macro stack
ldi r16, 0x10
out SPH, r16
ldi r16, 0xff
out SPL, r1
.endmacro

;
;
;
;

for loops?
ldi r16, 0
loop:out PortB, r16
inc r16
cpi r16, 10
brne loop
ldi r16, 0
loop1:inc r16
out PortB, r16
cpi r16, 10
brne loop1

;clear the register


;write regioster to port b
;inc the counter
;compare with 10
;if less than 10 loop
;this code differs slightly
;find it

another assignment>>

make code for WHILE (true) { } ;

and DO { }WHILE(true)

i/o ports
Atmega8 is having total 3 i/o ports B-D

All the ports are bi/directional

Port B ,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.

I/o REGISTERS

PINB(8bit)

PORTB (8bit)

DDRB(8bit)

i/o 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

but before this something is to be done??

some settings.

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).

......

thats all .........

Port diagram

You might also like