A2 After MID
A2 After MID
A2 After MID
EEE342
Assignment # 02
Registration
Number FA20-BEE-033
Subject MP
Q2:
Write a program for the Atmel AVR ATMega32 microcontroller which
continuously read the logic values on portB and write them to portC.
#include <avr/io.h>
#define F_CPU 16000000UL
#include <util/delay.h>
int main()
{ unsigned char
temp;
DDRB = 0x00;
DDRC = 0xFF;
while
(1)
{
temp = PINB;
PORTC = temp;
} return
0;
}
Qno3: Write description of each statement
Description
&x AND x
*p Pointer
char x = 3;
x is a character having value “3”
(int) x
CODE:
#include <avr/io.h>
#define F_CPU 16000000UL
#include <util/delay.h>
int
main()
{
DDRB =
0b11111111; int
ADD=0; int i=1;
while(i<11)
{
PORTB=ADD+i;
_delay_ms(1000);
i=i+1;
}
}
Q 5:
what is meant by Debouncing of switch and what are the method for removing
debouncing in switch( software as well as hardware).write code for removing Debouncing
for a circuit in with Switch is connected with Pin 2.
Electrical contact in mechanical push button switches often make and break contact several
times when the button is 1st pushed. A debouncing circuit removes the ripples in the signal and
provide a clean transition at its output.
Method of Debouncing:
There are three commonly used methd to remove debouncing.
• Hardware Debouncing
• RC Debouncing
• Switch Debouncing IC
CODE:
.INCLUDE "M32DEF.INC"
CBI DDRB,0;
AGAIN: SBIC PINB,0;
RJMP OVER;
LDI R16,0;
RJMP AGAIN;