DOOR ALARM project in Atmega32 using ATMEL STUDIO 7 Assembly

Since 1996, Atmel has been developing the AVR family of microcontrollers. These are 8-bit RISC single-chip microcontrollers with modified Harvard architecture. Among the AVR microcontroller types are the ATmega series, which has attributes such an expanded instruction set, a large peripheral set, a 28–100 pin package, and 4-256 KB of program memory. These unique capabilities help engineers, enthusiasts, and students in creating creative AVR projects.

Let us understand door alarm system in Atemga through a program in assembly language.

Firstly, we will include a header file.

CODE:

.INCLUDE “M32DEF.INC”

If you do not know how to include it, you can check by clicking here.

LDI R16,HIGH(RAMEND)
 OUT SPH,R16
 LDI R16,LOW(RAMEND)
 OUT SPL,R16                          // INITIALIZING  THE STACK

First, we will initialize the stack.

For initializing the stack, we OUT the High(RAMEND) on the SPH and we OUT the Low(RAMEND) on the SPL. Here SPH means Stack Pointer High and SPL means Stack Pointer Low. It means that we have specified the space for the stack in RAM.

SBI DDRC,5                               // PC5=OUTPUT configured
CBI DDRB,3                              // PB3=INPUT

In the above step we configured pin5 of the port C of the data direction register as the output. By using the SBI command, we sent the signal of 1 to pin5 and configured it as output.

Then we configured pin3 of port B as input by using the CBI command.

Now the input will be connected to pin3 of port B and output which is buzzer will be connected to pin5 of the port C.

LOOP:
SBIC PINB,3                             // IF PB3 =0 THEN SKIP NEXT INSTR.
RJMP LOOP                              // PORTD=1
JMP LOOP1

Here, SBIC command means if pin3 of port B is equal to 0 then skip the next instruction and execute the JMP LOOP1 command.

LOOP1:
  SBI PORTC,5                             //pc5=1 ==high
  CBI PORTC,5                           //pc5=0 == low
  RJMP LOOP

And by using the SBI command we sent the high pulse to the pin5 of the port C. here high pulse means 1. And in the very next command we sent 0 value to pin5 of the port C. then it will jump to the loop command.

Now we will build and debug our solution and check the output step by step.

Firstly, we can see the stack has been initialized.

DEBUG:

Below you can see pin 5 of the port c has been set for output. Similarly, pin3 of port B has been configured as input.   

Below you can see the value is one on the port C because we have to send the high impulse first and then we will send the low impulse.

Below we sent the low impulse that’s the values are 0 on the pin 5 of the port.

In the last step, we will burn (run) the code, double-click on the circuit window, and go to the program file option. And then go to the location where you have saved your Atmel Studio.

You will see your file, click on that file, and go to the debug option, then open the hex file. Then go back to Atmel Studio and run the window.

Below you can see the circuit.

Now we will set the value to 1 and see that the buzzer is still off because according to our program this will not work. When we send the 1 value it will show 0 result. 

Now when we open the switch you can see the value is going from high to low and the door is open and it is blinking slowly.

Conclusion

In summary, the ATMEL STUDIO 7 Assembly-based DOOR ALARM project on the Atmega32 is a praiseworthy endeavor. The selection of the Atmega32 shows practical use in the real world, while the usage of Assembly language exhibits a thorough mastery of low-level programming. The door alarm system is a straightforward yet efficient way to increase security, and the project as a whole offers microcontroller programming enthusiasts a priceless opportunity to learn.

For Complete Trial Watch the Video:  DOOR ALARM project in Atmega32 using ATMEL STUDIO 7 Assembly

For more blogs explore the website: https://ninjatech.live/

Leave a Comment

Your email address will not be published. Required fields are marked *