35
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 <90s8535.h> #include <delay.h> 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; } }

ES Final Doc

Embed Size (px)

DESCRIPTION

Msc-cs journal Embedded Systems

Citation preview

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