KEMBAR78
Mpi Lab: Handling Individual Bits On Atmega 32 | PDF
0% found this document useful (0 votes)
104 views3 pages

Mpi Lab: Handling Individual Bits On Atmega 32

This document summarizes a lab assignment involving programming an Atmega 32 microcontroller on Proteus. The objectives were to learn basics of Proteus, introduce the Atmega 32 processor, and learn Atmel studio. The task was to program the Atmega 32 such that port B reads a door input on pin 1 and lights an LED connected to pin 7 when the input is high. The code defines the ports and pins, sets port C pin 7 as output, checks the value of pin B1, and sets port C high or low accordingly to control the LED. The result was successful lighting of the LED in response to the door input.

Uploaded by

Burhan Ahmed
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)
104 views3 pages

Mpi Lab: Handling Individual Bits On Atmega 32

This document summarizes a lab assignment involving programming an Atmega 32 microcontroller on Proteus. The objectives were to learn basics of Proteus, introduce the Atmega 32 processor, and learn Atmel studio. The task was to program the Atmega 32 such that port B reads a door input on pin 1 and lights an LED connected to pin 7 when the input is high. The code defines the ports and pins, sets port C pin 7 as output, checks the value of pin B1, and sets port C high or low accordingly to control the LED. The result was successful lighting of the LED in response to the door input.

Uploaded by

Burhan Ahmed
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/ 3

MPI LAB

LAB 2
Handling individual bits on Atmega 32

Name : Burhan Ahmed Satti


Enrollment No. : 01-134172-065
Class : BSCS 4-A
Subject : MPI Lab
Lab Assistant : Muhammad Atif

Objectives
•Learning basics of Proteus
•Introduction to Atmega 32 processor
•Learning basics of Atmel studio

Tools Used
•Proteus 8.0
•Atmel Studio 7.0
BSCS 4-A Burhan Ahmed Satti 01-134172-065

Task No. 2.1


Program the Atmega 32 processor on Proteus, such that Port B takes door input on pin 1 and
lights up the LED connected to the 7th pin.
Solution
/**
* \file
*
* \brief Empty user application template
*
*/

/**
* \mainpage User Application template doxygen documentation
*
* \par Empty user application template
*
* Bare minimum empty user application template
*
* \par Content
*
* -# Include the ASF header files (through asf.h)
* -# "Insert system clock initialization code here" comment
* -# Minimal main function that starts with a call to board_init()
* -# "Insert application code here" comment
*
*/

/*
* Include header files for all drivers that have been imported from
* Atmel Software Framework (ASF).
*/
/*
* Support and FAQ: visit <a href="https://www.microchip.com/support/">Microchip Support</a>
*/
#include <asf.h>

int main (void)


{
/* Insert system clock initialization code here (sysclk_init()). */

board_init();

/* Insert application code here, after the board has been initialized. */

DDRB &= (0<<1);


DDRC |= (1<<7);
PORTC = 0x00;

while (1)
{
if(PINB == 0x02)
PORTC = 0x80;
else
PORTC = 0x00;
}
return 1;
}

HCI Lab Page 2 of 3


BSCS 4-A Burhan Ahmed Satti 01-134172-065

Result

Conclusion
The 7th pin lights up whenever there is input on 2nd port.

HCI Lab Page 3 of 3

You might also like