Here is the code for SBIS and SBIC Command in Atmega32 using ATMEL STUDIO 7 Assembly.The instructions sbis and sbic allow you to “skip” an instruction based on a condition in an I/O Register. As with sbi and cbi, these instructions only work with the first 32 I/O Registers.
sbis and sbic are useful for checking a condition on an external pin. For example, a loop which waits until PINB0 is cleared by (e.g. by a button) could be written as:
wait: sbic PINB,PINB0 ; skip if PINB0 is low
rjmp wait ; repeat loop
Let us understand it through a program in assembly language.
Firstly, we will include a header file.
.INCLUDE “M32DEF.INC”
If you do not know how to include it, you can check by clicking here.
.ORG 0X00 // INITIAL LOCTATION
Here we gave the initial position to our program which means we are starting our program from this location.
Then we will make the loop first.
LOOP:
SBIS PINB,2
SBIS command uses the special function registers.
The above command means that skip the next instruction if pin 2 of port B is set or equal to 1.
RJMP JUMP
LDI R16,0X10
So, it will skip the command of the RJM and come to the LDI command. And load the value 10 in the general purpose register R16.
Now we will build our solution and then debug it by selecting the build and debug options from the menu bar respectively.
As we can see the value on port B is 0 so it will not skip the next command. It will skip the next command only if the value is 1.
As the next command will not be skipped so it will execute the RJMP command and there as it says load the value 20 in the general purpose register.
Now when we run the SBIC command, it will have the value 0 so it will skip the next command and load the 10 value.
Conclusion
Using ATMEL STUDIO 7 Assembly, we have ventured into the realm of SBIS and SBIC instructions in Atmega32. Consider these instructions as unique instruments that assist the microcontroller in making judgments based on pin state.
These commands enable our microcontroller to scan the bits on its pins to see whether anything significant is occurring, much like a detective looking for hints. We discovered how to program the microcontroller to respond to a hint (a particular bit being set or cleared). It would be akin to granting our technological companion autonomous decision-making abilities.
For Complete Trial Watch the Video: SBIS and SBIC Command in Atmega32 using ATMEL STUDIO 7 Assembly
For more blogs explore the website: https://ninjatech.live/