Download docx - ES Final Doc

Transcript

Practical 1

Toggle Port LED

Write a program in Assembly/C programming language to alternately ON/OFF LEDs connected to two different ports. Draw appropriate circuit diagram to demonstrate the above problem.

Code:

#include #include

void main(void){DDRA=0xff;PORTA=0xff;DDRB=0xff;PORTB=0x00;//Unmasking the interrupt#asm("sei");while (1){ delay_ms(2000); PORTA=PORTA^0xff;PORTB=PORTB^0xff; }}

Output:

Practical 2

Simulate Binary Counter at Port

Write a program in Assembly/C programming language to simulate binary counter on LEDs. Draw appropriate circuit diagram to demonstrate the above problem.

Code:

#include #include

//Global variable unsigned char led_status=0x01;

void main(void){DDRB=0xff;PORTB=led_status;//Unmasking the interrupt#asm("sei");while (1){ PORTB=led_status; if(led_status==0x80)led_status=0x01;else led_status