Embedded and Real Time Systems Assignment 03, Assignments of Embedded Systems

Embedded and Real Time Systems Assignment 03

Typology: Assignments

2020/2021

Uploaded on 01/13/2021

unknown user
unknown user 🇵🇰

3 documents

1 / 9

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
12/11/2019 E&RTS
Assignment 4
Submitted By: -
Syed Saqib Iqbal (16-SE-37)
Submitted to: -
Mam Huma Ayub
University Of Engineering and Technology Taxila
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

Download Embedded and Real Time Systems Assignment 03 and more Assignments Embedded Systems in PDF only on Docsity!

12/11/2019 E&RTS

Assignment 4

Submitted By: -

Syed Saqib Iqbal ( 16 - SE- 37 )

Submitted to: -

Mam Huma Ayub

University Of Engineering and Technology Taxila

Question 1: -

Write a C program to toggle bit 3 and bit 7 of PORTB and output of code must

be shown in proteus simulation using LEDs at pin 3 and 7 of PORTB.

Code: - #include <avr/io.h> int main(void) { /* Replace with your application code */ DDRB=0xFF; while (1) { PORTB=PORTB | 0b10001000; PORTB=PORTB & 0b01110111; } return 0; } OUTPUT: -

return 0; } OUTPUT: - Proteus Simulation: -

Question 3: -

Write a program to convert ASCII digits of ‘2’ and ‘9’ to packed BCD and display

them on PORTA.

Code: -

#include <avr/io.h> int main(void) { /* Replace with your application code */ unsigned char bcdbyte; unsigned char w='2'; unsigned char z='9'; DDRA=0xFF; w=w & 0x0F; w=w<<4; z=z & 0x0F; bcdbyte=w | z; PORTA=bcdbyte; return 0; } OUTPUT: -

Question 5: -

Write a C program to send your First and Last name to EEPROM.

Code: -

#include <avr/io.h> int main(void) { /* Replace with your application code */ while (EECR & (1<<EEWE)); EEDR= 'Ukasha Javed'; EECR |= (1<<EEMWE); EECR |= (1<<EEWE); return 0; }

OUTPUT: -

Question 6: -

Write a C program to take an input from PORTC bit 5 and send it PORTD bit 2.

Code: -

#include <avr/io.h> int main(void) { /* Replace with your application code */ DDRB=DDRB & 0b11011111; DDRD=DDRD | 0b00000100; while (1) { if ( PINB & 0b00100000) PORTD =PORTD | 0b00000100; else PORTD=PORTD & 0b0111111; } return 0; }

OUTPUT : -