Chapter 3 Bit Addressable Area By DeccanRobots
What is Bit Addressable Area? FFh 2Fh 20h 00h Data Memory General purpose Memory Area Bit Addressable Memory Registers Memory Area from 20H to 2FH is Bit addressable Area.
What is Bit Addressable Area? FFh This memory area can be accessed as a byte as well as a bit. 2Fh 20h 00h Data Memory Part of Bit addressable Memory area shown here 13 04 03 02 09 01 00 25h 24h 23h 22h 21h 20h
What is Bit Addressable Area? FFh e.g. MOV 20h,#55h will copy 55h value to 20h Memory Area. This is Byte level access Part of Bit addressable Memory area shown here 2Fh 20h 00h Data Memory 13 04 03 02 09 01 00 25h 24h 23h 22h 21h 20h
What is Bit Addressable Area? FFh e.g. SETB 00h will copy Binary 1 value to Bit address 00. This is Bit level access Part of Bit addressable Memory area shown here 2Fh 20h 00h Data Memory 13 04 03 02 09 01 00 25h 24h 23h 22h 21h 20h
What is Bit Addressable Area? This bit is named as 01h This bit is named as 00h This bit is named as 02h This bit is named as 0Dh which is 13 th Bit in bit addressable area 13 04 03 02 09 01 00 25h 24h 23h 22h 21h 20h
What is Bit Addressable Area? Question for you: SETB 20h code will copy Binary 1 at which Location? 13 04 03 02 09 01 00 25h 24h 23h 22h 21h 20h
What is Bit Addressable Area? SETB command is used to copy Binary 1 at address provided in command SETB 12h will copy Binary 1 at 12h location in Bit addressable area
What is Bit Addressable Area? CLR command is used to copy Binary 0 at address provided in command CLR 12h will copy Binary 0 at 12h location in Bit addressable area
What is Bit Addressable Area? Similarly All ports P0, P1, P2, P3 are bit addressable. In other words we can access all 8 bits(1 Byte) of any port at a time or we can access single bit individually.
What is Bit Addressable Area? MOV P2,#55h will change all 8 bits of P2 SETB P2.3 will make 3 rd Bit of P2 ( Pin number 24 of Controller to 1 state) CLR P2.0 will make 0 th Bit of P2 ( Pin number 21 of Controller to 0 state)
What is Bit Addressable Area? Hence we understand that section of data memory can be accessed as Byte and as Bit too. Each bit has its own address like 00h, 01h, 02h etc. SETB or CLR command can be used to modify values of any Bit.
What is Bit Addressable Area? MOV 00h,#00h CLR 00h Are you able to make difference between these two commands?
What is Bit Addressable Area? MOV 00h,#00h CLR 00h Are you able to make difference between these two commands? Remember: CLR Command is always used for a BIT. Hence CLR 00h command will copy Binary 0 to bit addressable area s 00h location
What is Bit Addressable Area? Remember: CLR Command is always used for a BIT. Hence CLR 00h 25h command will copy Binary 0 to bit addressable area s 00h location 13 04 03 02 09 01 00 24h 23h 22h 21h 20h
What is Bit Addressable Area? MOV 00h,#00h Will copy value 00h To memory location 00h i.e. R0 0 0 0 0 0 0 0 0 FFh 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 02h 01h 00h
What is Bit Addressable Area? MOV 00h,#00h CLR 00h Are you able to make difference between these two commands?
Second Application: Toggle LED using Micro Switch Use one Micro switch and 1 LED provided on Interfacing board. Initially LED will be OFF Press Switch once to make it ON Press it again to make it OFF Press it again to make it ON This will continue.
Toggle LED using Micro Switch Refer Application 1.2 from Book Refer Circuit diagram Make connection accordingly and send program to 89S52. LED Micro Switch
Toggle LED using Micro Switch SETB P2.0 Loop: JB P1.0, Loop CPL P2.0 Debounce: JNB P1.0, Debounce SJMP Loop Code is Explained on Next Slide Make LED OFF Wait till Switch is not pressed Change State of LED Wait till Switch is fully released
Toggle LED using Micro Switch SETB P2.0 Loop: Label JB P1.0, Loop Make LED OFF JB Command is used to jump to label specified if bit is 1 Here if P1.0 is 1 then program will jump to Loop. In other words, if switch is not pressed, P1.0 will remain to 1 state, and program will remain in Loop
Toggle LED using Micro Switch SETB P2.0 Loop: JB P1.0, Loop CPL P2.0 Make LED OFF JB Command is used to jump to label specified if bit is 1 Label Complement P2.0 CPL is complement, which will change state of P2.0 to 0 if it is 1 OR will make it 1 if it is 0
Toggle LED using Micro Switch SETB P2.0 Loop: JB P1.0, Loop CPL P2.0 Debounce: JNB P1.0, Debounce SJMP Loop JNB command is used to Jump to label if bit is 0. If bit is 1 then it will continue program to next line Program will jump to Loop
Toggle LED using Micro Switch Commands you have learnt till now: MOV SETB CLR CPL JB JNB SJMP
What is SFR? Special Function Register These are 1 byte or 2 bytes memory locations. SFR is not part of data memory. Microcontroller has a separate memory area allocated for all SFRs.
What is SFR? E.g. P0, P1, P2 and P3 (All ports) are SFRs. Another SFR commonly used in BIT operations is PSW. Address of P0 is 80h Address of P1 is 90h Address of P2 is A0h Address of P3 is B0h Address of PSW is D0h
What is SFR? Hence following code will have same effect because A0 is address of P2 MOV 0A0h,#55h Make sure to OR MOV P2,#55h add 0 (Zero) before hex value, if hex value is starting with a character
What is SFR? PSW Register 7 th bit CARRY FLAG Known as C 0 th bit D0 It is used to store result of most of the Boolean Operations
What is SFR? 7 th Bit of PSW is Known as C C is used in many commands to store operation done over bit.
Back to Bits.. ANL C,bit-address ANL C,03h This command will AND value of C with value of address 03h. Move to next slide to understand it in detail.
Back to Bits.. Logical Operation SETB C CLR 03h ANL C, 03h Location C=1 Location 03h=0 1 AND 0 = 0 Result of this operation is always stored in Left Operand. Here it will be stored in C Finally value of C will be 0
Logical Operation for Bits Similarly: E.g. ORL C,bit-address CPL bit-address CLR bit-address CPL C CLR C ORL C,03h CPL 03h CLR 03h CPL C CLR C
Logical Operation for Bits Next Instruction is: e.g. SETB C CLR 03h ANL C,/03h ANL C,/bit-address Slash ( / ) indicate complement AND operation between C and Complemented value of 03h will be executed. Value of 03h is never changed.
Logical Operation for Bits Similarly: ORL C,/bit-address
Logical Operation for Bits Commands you have learnt till now: MOV SETB CLR CPL JB JNB SJMP ANL ORL
How to Practice More? To practice more, write code in 8051IDE, assemble your program and use F11 key to execute in steps on computer. Use PORT, Registers window to check results and changes in values. These windows can be opened from Menu View-Registers or View-Ports in 8051IDE as shown in next slide.
How to Practice More?
End of Chapter 3 This is END of 3 rd Chapter Open 4 th Chapter to interface Stepper Motors and DC Motors.