WWW Mikroe Com Chapters View 69 Chapter 6 Examples
WWW Mikroe Com Chapters View 69 Chapter 6 Examples
WWW Mikroe Com Chapters View 69 Chapter 6 Examples
Solutions
Store
Distributors
Libstock
C ontact Us
Ente r k e ywords
Chapter 6 : Examples
6.1 Basic connecting of the microcontroller 6.2 Additional components 6.3 Examples
Introduction
The purpose of this chapter is to provide basic information about microcontrollers that one needs to know in order to be able to use them successfully in practice. This is why this chapter doesn't contain any super interesting program or device schematic with amazing solutions. Instead, the following examples are better proof that program writing is neither a privilege nor a talent issue, but the ability of simply putting puzzle pieces together using directives. Rest assured that design and development of devices mainly consists of the following method test-correct-repeat. Of course, the more you are in it, the more complicated it becomes since the puzzle pieces are put together by both children and first-class architects...
The Easy8051 v6 is compatible w ith 14-, 16-, 20-, 28-, 40-pin PLCC44 and PLCC32 MCUs. It comes w ith an AT89S8253. The board has a USB 2.0 programmer and many peripherals such as COG, port expander, MENU and 4x4 keypads etc. [more info]
pdfcrowd.com
mikroProg for 8051 is supported w ith mikroC, mikroBasic and mikroPascal compilers for 8051. You may also use mikroProg for 8051 as a standalone programming tool. [more info]
As seen in the figure above, in order to enable the microcontroller to operate properly it is necessary to provide:
The 8051 core combined w ith modern modules is popular in the past. With m ikroBasic you can quickly develop your projects. [more info]
Power supply
Even though this microcontroller can operate at different power supply voltages, why to test Murphys low?! A 5V DC is most commonly used. The circuit, shown in the figure, uses a cheap integrated three-terminal positive regulator LM7805, and provides high-quality voltage stability and quite enough current to enable the microcontroller and peripheral electronics to operate normally (enough current in this case means 1Amp).
pdfcrowd.com
Reset signal
In order that the mucrocontroller can operate properly, a logic 0 (0V) must be applied to the reset pin RS. The push button connecting the reset pin RS to power supply VCC is not necessary. However, it is almost always provided because it enables the microcontroller safe return to normal operating conditions if something goes wrong. 5V is brought to this pin, the microcontroller is reset and program starts execution from the beginning.
Clock signal
Even though the microcontroller has a built-in oscillator, it cannot operate without two external capacitors and quartz crystal which stabilize its operation and determines its frequency (operating speed of the microcontroller). Of course, it is not always possible to apply this solution so that there are always alternative ones. One of them is to provide clock signal from a special source through invertor. See the figure on the left.
pdfcrowd.com
act together to cause bounce. The result is a rapidly pulsed electrical current instead of a clean transition from zero to full current. It mostly occurs due to vibrations, slight rough spots and dirt between contacts. This effect is usually unnoticeable when using these components in everyday life because the bounce happens too quickly. In other words, the whole this process does not last long (a few micro- or miliseconds), but it is long enough to be registered by the microcontroller. When using only a pushbutton as a pulse counter, errors occur in almost 100% of cases! The simplest solution to this problem is to connect a simple RC circuit to suppress quick voltage changes. Since the bounce period is not defined, the values of components are not precisely determined. In most cases, it is recomended to use the values shown in figure below.
If complete stability is needed then radical measures should be taken. The output of the circuit, shown in figure (RS flip-flop), will change its logic state only after detecting the first pulse triggered by contact bounce. This solution is expensive (SPDT switch), but effecient, the problem is definitely solved. Since the capacitor is not used, very short pulses can also be registered in this way. In addition to these hardware solutions, there is also a simple software solution. When a program tests the state of an input pin and detects a change, the check should be done one more time after a certain delay. If the change is confirmed, it means that a switch or push button has changed its position. The advantages of such solution are obvious: it is free of charge, effects of noises are eliminated and it can be applied to the poorer quality contacts as well. Disadvantage is the same as when using RC filter, i.e. pulses shorter than program delay cannot be registered.
Optocoupler
An optocoupler is a device commonly used to galvanically separate microcontrollers electronics from any potentially dangerous current or voltage in its surroundings. Optocouplers usually have one, two or four light sources (LED diodes) on their input while on their output, opposite to diodes, there is the same number of elements sensitive to light (phototransistors, photothyristors or photo-triacs). The point is that an optocoupler uses a
pdfcrowd.com
short optical transmission path to transfer a signal between the elements of circuit, while keeping them electrically isolated. This isolation makes sense only if diodes and photo-sensitive elements are separately powered. In this way, the microcontroller and expensive additional electronics are completely protected from high voltage and noises which are the most common cause of destroying, damaging or unstable operation of electronic devices in practice. The most frequently used optocouplers are those with phototransistors on their outputs. When using the optocoupler with internal base-to-pin 6 connection (there are also optocouplers without it), the base can be left unconnected. An optional connection which lessens the effects of noises by eliminating very short pulses is presented by the broken line in the figure.
Relay
A relays is an electrical switch that opens and closes under control of another electrical circuit. It is therefore connected to ouput pins of the microcontroller and used to turn on/off high-power devices such as motors, transformers, heaters, bulbs, antenna systems etc. These are almost always placed away from the board sensitive components. There are various types of relays but all of them operate in the same way. When a current flows through the coil, the relay is operated by an electromagnet to open or close one or many sets of contacts. Similar to optocouplers, there is no galvanic connection (electrical contact) between input and output circuits. Relays usually demand both higher voltage and current to start operation, but there are also miniature ones which can be activated by a low current directly obtained from a microcontroller pin. The figure shows the solution specific to the 8051 microcontroller. A darlington transistor is used here to activate relays because of its high current gain. This is not in accordance with rules, but is necessary in the event that logic one activation is applied since the output current is then very low (pin acts as an input).
pdfcrowd.com
In order to prevent the appearance of self-induction high voltage, caused by a sudden stop of current flow through the coil, an inverted polarized diode is connected in parallel to the coil. The purpose of this diode is to cut off the voltage peak.
pdfcrowd.com
this reason, a conductor must be connected in parallel to an LED. In order to determine value of this conductor, it is necessary to know diodes voltage drop in forward direction, which depends on what material a diode is made from and what colour it is. Typical values of the most frequently used diodes are shown in table below. As seen, there are three main types of LEDs. Standard ones get ful brightness at current of 20mA. Low Current diodes get ful brightness at ten times lower current while Super Bright diodes produce more intensive light than Standard ones.
T Y P I C A L C URRENT I D ( M A ) 30 20 20 2 10 2 20 20 25
M A X I M A L C URRENT I F ( M A ) 50 30 30 30 30 20 30 30 35
V O L T A G E DRO P UD ( V ) 1.4 1.7 1.85 1.7 2.0 2.1 2.1 4.5 4.4
Since the 8051 microcontroller can provide only low output current and since its pins are configured as outputs when voltage provided on them is 0V, direct connecting to LEDs is performed as shown in figure on the right (Low current LED, cathode is connected to the output pin).
pdfcrowd.com
LED displays
Basically, an LED display is nothing more than several LEDs moulded in the same plastic case. There are many types of displays composed of several dozens of built in diodes which can display different symbols. Most commonly used is a so called 7-segment display. It is composed of 8 LEDs, 7 segments are arranged as a rectangle for symbol displaying and there is an additional segment for decimal point displaying. In order to simplify connecting, anodes and catodes of all diodes are connected to the common pin so that there are common anode displays and common catode displays, respectively. Segments are marked with the latters from A to G, plus dp, as shown in the figure on the left. On connecting, each diode is treated separtely, which means that each must have its own current limiting resistor.
Displays connected to the microcontroller usually occupy a large number of valuable I/O pins, which can be a big problem especially if it is needed to display multy digit numbers. The problem is more than obvious if, for example, it is needed to display two 6-digit numbers (a simple calculation shows that 96 output pins are needed in this case). The solution to this problem is called MULTIPLEXING. This is how an optical illusion based on the same operating principle as a film camera is made. Only one digit is active at a time, but they change their state so quickly making impression that all digits of a number are simultaneously active.
pdfcrowd.com
Here is an explanation on the figure above. First a byte representing units is applied on a microcontroller port and a transistor T1 is activated at the same time. After a while, the transistor T1 is turned off, a byte representing tens is applied on a port and a transistor T2 is activated. This process is being cyclically repeated at high speed for all digits and corresponding transistors. The fact that the microcontroller is just a kind of miniature computer designed to understand only the language of zeros and ones is fully expressed when displaying any digit. Namely, the microcontroller doesn't know what units, tens or hundreds are, nor what ten digits we are used to look like. Therefore, each number to be displayed must be prepared in the following way: First of all, a multy digit number must be split into units, tens etc. in a particular subroutine. Then each of these digits must be stored in special bytes. Digits get familiar format by performing masking. In other words, a binary format of each digit is replaced by a different
pdfcrowd.com
combination of bits in a simple subroutine. For example, the digit 8 (0000 1000) is replaced by the binary number 0111 111 in order to activate all LEDs displaying digit 8. The only diode remaining inactive in this case is reserved for the decimal point. If a microcontroller port is connected to the display in such a way that bit 0 activates segment a, bit 1 activates segment b, bit 2 segment c etc., then the table below shows the mask for each digit.
DI G I T S T O DI S P L A Y
DI S P L A Y S EG M ENT S
pdfcrowd.com
dp 0 1 2 3 4 5 6 7 8 9 1 1 1 1 1 1 1 1 1 1
a 0 0 0 0 1 0 0 0 0 0
b 0 0 0 0 0 1 1 0 0 0
c 0 1 1 0 0 0 0 0 0 0
d 0 1 0 0 1 0 0 1 0 0
e 0 1 0 1 1 1 0 1 0 1
f 0 1 1 1 0 0 0 1 0 0
g 1 1 0 0 0 0 0 1 0 0
In addition to digits from 0 to 9, some letters of alphabet - A, C, E, J, F, U, H, L, b, c, d, o, r, t - can also be displayed by performing appropriate masking. If the event that common chatode displays are used all units in the table should be replaced by zeros and vice versa. Additionally, NPN transistors should be used as drivers as well.
LCD Pins
There are pins along one side of a small printed board. These are used for connecting to the microcontroller. There are in total of 14 pins marked with numbers (16 if it has backlight). Their function is described in the table bellow:
pdfcrowd.com
P I N NUM BER 1 2 3 4
L OGI C ST A T E 0 1 0 1 0 1 From 1 to 0 0/1 0/1 0/1 0/1 0/1 0/1 0/1 0/1
DES C RI P T I O N 0V +5V 0 - Vdd D0 D7 are interpreted as commands D0 D7 are interpreted as data Write data (from controller to LC D) Read data (from LC D to controller) Access to LC D disabled Normal operating Data/commands are transferred to LC D Bit 0 LSB Bit 1 Bit 2 Bit 3 Bit 4 Bit 5 Bit 6 Bit 7 MSB
C ontrol of operating
R/W
7 8 9 Data / commands 10 11 12 13 14
D0 D1 D2 D3 D4 D5 D6 D7
LCD screen
An LCD screen consists of two lines each containing 16 characters. Each character consists of 5x8 or 5x11 dot matrix. This book covers the most commonly used display, i.e. the 5x8 character display. Display contrast depends on the power supply voltage and whether messages are displayed in one or two lines. For this reason, varying voltage 0-Vdd is applied on the pin marked as Vee. Trimmer potentiometer is usually used for that purpose. Some LCD displays have built-in backlight (blue or green LEDs). When used during operation, a current limiting resistor should be serially connected to one of the pins for backlight power supply
pdfcrowd.com
(similar to LEDs).
If there are no characters displayed or if all of them are dimmed when the display is on, the first thing that should be done is to check the potentiometer for contrast regulation. Is it properly adjusted? The same applies if the mode of operation has been changed (writing in one or two lines).
LCD Memory
The LCD display contains three memory blocks:
DDRAM Display Data RAM; CGRAM Character Generator RAM; and CGROM Character Generator ROM. DDRAM Memory
DDRAM memory is used for storing characters to be displayed. The size of this memory is sufficient for storing 80 characters. Some
pdfcrowd.com
It works quite simply: it is sufficient to configure the display so as to increment addresses automatically (shift right) and set the starting address for the message that should be displayed (for example 00 hex). After that, all characters sent through lines D0-D7 will be displayed in the message format we are used to- from left to right. In this case, displaying starts from the first field of the first line since the address is 00 hex. If more than 16 characters are sent, then all of them will be memorized, but only the first sixteen characters will be visible. In order to display the rest of them, a shift command should be used. Virtually, everything looks as if the LCD display is a window which moves left-right over memory locations containing different characters. This is how the effect of message moving on the screen is made. If the cursor is on, it appears at the location which is currently addressed. In other words, when a character appears at the cursor position, it will automatically move to the next addressed location. Since this is a sort of RAM memory, data can be written to and read from it, but its contents is irretrievably lost when the power goes off.
CGROM Memory
CGROM memory contains the default chracter map with all characters that can be displayed on the screen. Each character is assigned to one memory location.
pdfcrowd.com
pdfcrowd.com
The addresses of CGROM memory locations match the characters of ASCII. If the program being currently executed encounters a command send character P to port, then the binary value 0101 0000 appears on the port. This value is the ASCII equivalent to the character P. It is then written to LCD, which results in displaying the symbol from 0101 0000 location of CGROM. In other words, the character P is displayed. This applies to all letters of alphabet (capitals and small), but not to numbers. As seen on the previous map, addresses of all digits are pushed forward by 48 relative to their values (digit 0 address is 48, digit 1 address is 49, digit 2 address is 50 etc.). Accordingly, in order to display digits correctly, each of them needs to be added a decimal number 48 prior to be sent to LCD. From their inception till today, computers can recognize only numbers, but not letters. It means that all data a computer swaps with a peripheral device has a binary format, even though the same is recognized by the man as letters (keyboard is an excellent example). Every character matches the unique combination of zeroes and ones. ASCII is character encoding based on the English alphabet. ASCII code specifies correspondance between standard character symbols and their numerical equivalents. CGRAM memory Apart from standard characters, the LCD display can also display symbols defined by the user itself. It can be any symbol in the size of 5x8 pixels. RAM memory called CGRAM in the size of 64 bytes enables it. Memory registers are 8 bits wide, but only 5 lower bits are used. Logic one (1) in every register represents a dimmed dot, while 8 locations grouped together represent one character. It is best illustrated in figure below:
pdfcrowd.com
Symbols are usually defined at the beginnig of the program by simply writing zeros and ones to registers of CGRAM memory so that they form desired shapes. In order to display them it is sufficient to specify their address. Pay attention to the first coloumn in the CGROM map of characters. It doesn't contain RAM memory addresses, but symbols being discussed here. In this example, display 0 means - display , display 1 means - display etc.
pdfcrowd.com
displays it. The DDRAM address specifies the location on which the character is to be displayed. This address is defined before the character is transferred or the address of previously transferred character is automatically incremented. RS = 0 - Bits D0 - D7 are commands which determine the display mode. The commands recognized by the LCD are given in the table below:
C O M M A ND C lear display C ursor home Entry mode set Display on/off control C ursor/Display Shift Function set Set C GRAM address Set DDRAM address Read BUSY flag (BF) Write to C GRAM or DDRAM Read from C GRAM or DDRAM RS 0 0 0 0 0 0 0 0 0 1 1 RW 0 0 0 0 0 0 0 0 1 0 1 D7 0 0 0 0 0 0 0 1 BF D7 D7 D6 D6 D5 D5 D6 0 0 0 0 0 0 1 D5 0 0 0 0 0 1 D4 0 0 0 0 1 DL D3 0 0 0 1 D/C N D2 0 0 1 D R/L F D1 0 1 I/D U x x D0 1 x S B x x EX EC UT I O N T I M E 1.64mS 1.64mS 40uS 40uS 40uS 40uS 40uS 40uS D1 D1 D0 D0 40uS 40uS
I/D 1 = Increment (by 1) 0 = Decrement (by 1) S 1 = Display shift on 0 = Display shift off D 1 = Display on 0 = Display off U 1 = Cursor on 0 = Cursor off B 1 = Cursor blink on 0 = Cursor blink off
R/L 1 = Shift right 0 = Shift left DL 1 = 8-bit interface 0 = 4-bit interface N 1 = Display in two lines 0 = Display in one line F 1 = Character format 5x10 dots 0 = Character format 5x7 dots D/C 1 = Display shift 0 = Cursor shift
pdfcrowd.com
LCD Connection
Depending on how many lines are used for connecting the LCD to the microcontroller, there are 8-bit and 4-bit LCD modes. The appropriate mode is selected at the beginning of the operation. This process is called initialization. 8-bit LCD mode uses outputs D0-D7 to transfer data in the way explained on the previous page. The main purpose of 4-bit LED mode is to save valuable I/O pins of the microcontroller. Only 4 higher bits (D4-D7) are used for communication, while other may be left unconnected. Each data is sent to the LCD in two steps: four higher bits are sent first (normally through the lines D4-D7), then four lower bits. Initialization enables the LCD to link and interpret received bits correctly. Data is rarely read from the LCD (it is mainly transferred from the microcontroller to LCD) so that it is often possible to save an extra I/O pin by simple connecting R/W pin to ground. Such saving has its price. Messages will be normally displayed, but it will not be possible to read the busy flag since it is not possible to read the display either.
pdfcrowd.com
Fortunately, there is a simple solution. After sending a character or a command it is important to give the LCD enough time to do its job. Owing to the fact that execution of the slowest command lasts for approximately 1.64mS, it will be sufficient to wait approximately 2mS for LCD.
LCD Initialization
The LCD is automatically cleared when powered up. It lasts for approximately 15mS. After that, the display is ready for operation. The mode of operation is set by default. It means that:
pdfcrowd.com
3. Display/Cursor on/off
D = 0 Display off U = 0 Cursor off B = 0 Cursor blink off
4. Character entry
ID = 1 Displayed addresses are automatically incremented by 1 S = 0 Display shift off
Automatic reset is in most cases performed without any problems. In most cases, but not always! If for any reason the power supply voltage does not reach ful value within 10mS, the display will start to perform completely unpredictably. If the voltage supply unit is not able to meet this condition or if it is needed to provide completely safe operation, the process of initialization is applied. Initialization, among other things, causes a new reset enabling display to operate normally. Refer to the figure below for the procedure on 8-bit initialization:
pdfcrowd.com
pdfcrowd.com
It is not a mistake! In this algorithm, the same value is transferred three times in a row. In case of 4-bit initialization, the procedure is as follows:
pdfcrowd.com
6.3 Examples
The schematic below is used in the several following examples:
pdfcrowd.com
Apart from components necessary for the operation of the microcontroller such as oscillator with capacitors and the simplest reset circuit, there are also several LEDs and one push button. These are used to indicate the operation of the program. All LEDs are polarized in such a way that they are activated by driving a microcontroller pin low (logic 0).
LED Blinking
pdfcrowd.com
The purpose of this example is not to demonstrate the operation of LEDs, but the operating speed of the microcontroller. Simply put, in order to enable LED blinking to be visible, it is necessary to provide sufficient amount of time to pass between on/off states of LEDs. In this example time delay is provided by executing a subroutine called Delay. It is a triple loop in which the program remains for approximately 0.5 seconds and decrements values stored in registers R0, R1 or R2. After returning from the subroutine, the pin state is inverted and the same procedure is repeated...
;************************************************************************ ;* PROGRAM NAME : Delay.ASM ;* DESCRIPTION: Program turns on/off LED on the pin P1.0 ;* Software delay is used (Delay). ;************************************************************************ ;BASIC DIRECTIVES $MOD53 $TITLE(DELAY.ASM) $PAGEWIDTH(132) $DEBUG $OBJECT $NOPAGING ;STACK DSEG STACK_START: ;RESET VECTORS CSEG JMP ORG XRESET: MOV MOV LOOP: CPL LCALL SJMP P1.0 Delay LOOP ;Pin P1.0 state is inverted ;Time delay AT DS 03FH 040H
;Reset vector
pdfcrowd.com
Delay: F02: F01: MOV MOV MOV DJNZ DJNZ DJNZ R2,#20 R1,#50 R0,#230 R0,$ R1,F01 R2,F02 ;500 ms time delay ;25 ms
END
;End of program
;************************************************************************ ;* PROGRAM NAME : WatchDog.ASM ;* DESCRIPTION : After watch-dog reset, program increments number in ;* register R3 and shows it on port P1 in binary format. ;************************************************************************ ;BASIC DIRECTIVES $MOD53 $TITLE(WATCHDOG.ASM) $PAGEWIDTH(132) $DEBUG $OBJECT $NOPAGING WMCON WDTEN PERIOD DATA EQU EQU 96H 00000001B 11000000B
pdfcrowd.com
;RESET
AT XRESET
0 ; Reset vector
100H WMCON,#PERIOD WMCON,#WDTEN A,R3 P1,A R3 LAB ; Define Watch-dog period ; Watch-dog timer is enabled ; R3 is moved to port 1 ; Register R3 is incremented by 1 ; Wait for watch-dog reset ; End of program
XRESET:
LAB:
SJMP END
Timer T0 in mode 1
This program spends most of its time in an endless loop waiting for timer T0 to count up a full cycle. When it happens, an interrupt is generated, routine TIM0_ISR is executed and logic zero (0) on port P1 is shifted right by one bit. This is another way of demonstrating the operating speed of the microcontroller since each shift means that counter T0 has counted up 2 16 pulses!
;************************************************************************ ;* PROGRAM NAME : Tim0Mod1.ASM ;* DESCRIPTION: Program rotates "0" on port 1. Timer T0 in mode 1 is ;* used ;************************************************************************ ;BASIC DIRECTIVES $MOD53 $TITLE(TIM0MOD1.ASM) $PAGEWIDTH(132)
pdfcrowd.com
$DEBUG $OBJECT $NOPAGING ;DECLARATION OF VARIABLES ;STACK DSEG STACK_START: ;RESET VECTORS CSEG JMP ORG JMP ORG XRESET: MOV MOV MOV MOV SETB MOV CLR LOOP1: SJMP TIM0_ISR: AT DS 03FH 040H
AT 0 XRESET 00BH TIM0_ISR 100H SP,#STACK_START TMOD,#01H A,#0FFH P1,#0FFH TR0 IE,#082H C LOOP1 RRC MOV RETI A P1,A
; Reset vector
; Remain here ; Rotate accumulator A through Carry flag ; Contents of accumulator A is moved to PORT1 ; Return from interrupt ; End of program
END
pdfcrowd.com
;************************************************************************ ;* PROGRAM NAME : Split.ASM ;* DESCRIPTION: Timer TL0 rotates bit on port P1, while TL1 determines ;* the rotation direction. Both timers operate in mode ;* 3. Logic zero (0) on output P3.2 disables rotation on port P1. ;************************************************************************ ;BASIC DIRECTIVES $MOD53 $TITLE(SPLIT.ASM) $PAGEWIDTH(132) $DEBUG $OBJECT $NOPAGING ;DECLARATION OF VARIABLES BSEG AT 0
pdfcrowd.com
DSEG STACK_START: ;RESET VECTORS CSEG JMP ORG JMP ORG JMP ORG XRESET: MOV MOV MOV MOV MOV SETB SETB MOV CLR CLR LOOP1: SJMP
AT DS
03FH 040H
AT 0 XRESET 00BH TIM0_ISR 01BH TIM1_ISR 100H SP,#STACK_START TMOD,#00001011B A,#0FFH P1,#0FFH R0,#30D TR0 TR1 IE,#08AH C DIRECTION LOOP1
; Reset vector
; TL0 is turned on ; TL1 is turned on ; Interrupt enabled ; Rotate to the right ; Remain here
R0,LAB3 DIRECTION,LAB1 A
; Slow down rotation by 256 times ; Rotate contents of Accumulator to the right through ; Carry flag
LAB1:
SJMP RLC
LAB2 A
pdfcrowd.com
LAB2: LAB3:
MOV RETI
P1,A
; Slow down direction of rotation by 256 times ; When time expires, change rotation direction
; End of program
;************************************************************************ ;* PROGRAM NAME : Tim0Tim1.ASM ;* DESCRIPTION: Timer TO rotates bit on port P1 while Timer1 ;* changes rotation direction. Both timers are configured to operate in mode 1. ;************************************************************************ ;BASIC DIRECTIVES $MOD53 $TITLE(TIM0TIM1.ASM) $PAGEWIDTH(132) $DEBUG $OBJECT $NOPAGING ;DECLARATION OF VARIABLES
pdfcrowd.com
BSEG
AT
;DECLARATION OF BIT-VARIABLES SEMAPHORE: DIRECTION ;STACK DSEG STACK_START: AT DS 03FH 040H DBIT BIT 8 SEMAPHORE
;RESET VECTORS CSEG AT 0 JMP XRESET ORG JMP ORG JMP ORG 00BH TIM0_ISR 01BH TIM1_ISR 100H
XRESET: MOV MOV MOV MOV MOV SETB SETB MOV CLR CLR LOOP1: SJMP
SP,#STACK_START TMOD,#11H A,#0FFH P1,#0FFH R0,#30D TR0 TR1 IE,#08AH C DIRECTION LOOP1
; ; ; ;
R0 is initialized TIMER0 is turned on TIMER1 is turned on Timer0 and Timer1 Interrupt enabled
pdfcrowd.com
DIRECTION,LAB1 ; Rotate contents of accumulator to the right through ; Carry flag LAB2 A P1,A ; ; ; ; Rotate contents of Accumulator to the left through Carry flag Contents of Accumulator is moved to port P1 Return from interrupt
LAB1: LAB2:
; End of program
Using Timer T2
This example describes the use of Timer T2 configured to operate in Auto-Reload mode. In this very case, LEDs are connected to port P3 while the push button used for forced timer reset (T2EX) is connected to the P1.1 pin. Program execution is similar to the previous examples. When timer ends counting, an interrupt is enabled and subroutine TIM2_ISR is executed, thus rotating a logic zero (0) in accumulator and moving the contents of accumulator to the P3 pin. At last, flags which caused an interrupt are cleared and program returns to the loop LOOP1 where it remains until a new interrupt request arrives... If push button T2EX is pressed, timer is temporarily reset. This push button resets timer, while push button RESET resets the microcontroller.
pdfcrowd.com
;************************************************************************ ;* PROGRAM NAME : Timer2.ASM ;* DESCRIPTION: Program rotates log. "0" on port P3. Timer2 determines ;* the speed of rotation and operates in auto-reload mode ;************************************************************************ ;BASIC DIRECTIVES $MOD53 $TITLE(TIMER2.ASM) $PAGEWIDTH(132) $DEBUG
pdfcrowd.com
$OBJECT $NOPAGING ;DEFINITION OF VARIABLES T2MOD ;STACK DSEG STACK_START: ;RESET VECTORS CSEG JMP ORG JMP ORG XRESET: MOV MOV MOV MOV MOV CLR SETB SETB MOV CLR LOOP1: SJMP AT DS 03FH 040H DATA 0C9H
SP,#STACK_START A,#0FFH P3,#0FFH RCAP2L,#0FH RCAP2L,#01H CAP2 EXEN2 TR2 IE,#0A0H C LOOP1 RRC MOV CLR CLR A P3,A TF2 EXF2
; Prepare 16-bit auto-reload mode ; ; ; ; Enable 16-bit auto-reload mod Pin P1.1 reset is enabled Enable Timer T2 Interrupt is enabled
; Remain here ; ; ; ; ; Rotate contents of Accumulator to the right through Carry flag Move the contents of Accumulator A to PORT3 Clear timer T2 flag TF2 Clear timer T2 flag EXF2
TIM2_ISR:
pdfcrowd.com
RETI END
pdfcrowd.com
;************************************************************************ ;* PROGRAM NAME : Int.ASM ;* DESCRIPTION : Program counts interrupts INT0 generated by appearance of high-to-low ;* transition signal on pin P3.2 Result appears on port P0. Interrupts INT1 are also ;* counted up at the same time. They are generated byappearing high-to-low transition ;* signal on pin P3. The result appears on port P1. ;************************************************************************ ;BASIC DIRECTIVES
pdfcrowd.com
$MOD53 $TITLE(INT.ASM) $PAGEWIDTH(132) $DEBUG $OBJECT $NOPAGING ;RESET VECTORS CSEG JMP AT 0 XRESET
; Reset vector ; Interrupt routine address for INT0 ; Interrupt routine address for INT1
ORG 003H JMP Isr_Int0 ORG 013H JMP Isr_Int1 ORG XRESET: MOV TCON,#00000101B 100H
; ; ; ; ; ;
Interrupt INT0 is generated by appearing high-to-low transition signal on pin P3.2 Interrupt INT0 is generated by appearing high-to-low transition signal on pin P3.3 Interrupt enabled Counter starting value
pdfcrowd.com
; End of program
pdfcrowd.com
pdfcrowd.com
Since the microcontroller does not know how we write number 3, a small subroutine called Disp is used (the microcontroller writes this number as 0000 0011). This subroutine enables all decimal digits (0-9) to be displayed (masked). The principle of operation is simple. A number to be displayed is added to the current address and program jump is executed. Different numbers require different jump length. Precisely determined combination of zeroes and ones appears on each of these new locations (digit 1 mask, digit 2 mask...digit 9 mask). When this combination is transferred to the port, the display shows desired digit.
;************************************************************************ ;* PROGRAM NAME : 7Seg1.ASM ;* DESCRIPTION: Program displays number "3" on 7-segment LED display ;************************************************************************ ;BASIC DIRECTIVES $MOD53 $TITLE(7SEG1.ASM) $PAGEWIDTH(132) $DEBUG $OBJECT $NOPAGING ;STACK DSEG STACK_START: ;RESET VECTORS CSEG JMP ORG XRESET: MOV MOV MOV AT DS 03FH 040H
; Reset vector
; Define Stack pointer ; Turn off all segments on displays ; Activate display D4
pdfcrowd.com
; Subroutine for displaying digits A A,@A+PC 3FH 06H 5BH 4FH 66H 6DH 7DH 07H 7FH 6FH ; ; ; ; ; ; ; ; ; ; ; Digit 0 mask Digit 1 mask Digit 2 mask Digit 3 mask Digit 4 mask Digit 5 mask Digit 6 mask Digit 7 mask Digit 8 mask Digit 9 mask End of program
1. R3 is copied to Accumulator and subroutine for masking digits Disp is executed; 2. Accumulator is copied to the port and displayed; 3. The contents of the R3 register is incremented; 4. It is checked whether 10 cycles are counted or not. If it is, register R3 is reset in order to enable counting to start from 0; and 5. Instruction labeled as L2 within subroutine is executed.
pdfcrowd.com
;* DESCRIPTION: Program writes numbers 0-9 on 7-segment LED display ;************************************************************************ ;BASIC DIRECTIVES $MOD53 $TITLE(7SEG2.ASM) $PAGEWIDTH(132) $DEBUG $OBJECT $NOPAGING ;STACK DSEG STACK_START: ;RESET VECTORS CSEG JMP ORG XRESET: MOV MOV MOV MOV AT DS 03FH 040H
; Reset vector
; ; ; ;
Define Stack pointer Counter initial value Turn off all display segments Activate display D4
LOOP: MOV LCALL MOV INC CJNE MOV L2: MOV R2,#20 ; 500 mS time delay A,R3 Disp P1,A R3 R3,#10,L2 R3,#0 ; Perform appropriate masking for number in ; Accumulator ; Increment number in register by 1 ; Check whether the number 10 is in R3 ; If it is, reset counter
pdfcrowd.com
F02: F01:
; 25 mS
Disp: INC MOVC RET DB DB DB DB DB DB DB DB DB DB END A A,@A+PC 3FH 06H 5BH 4FH 66H 6DH 7DH 07H 7FH 6FH
; ; ; ; ; ; ; ; ; ;
Digit Digit Digit Digit Digit Digit Digit Digit Digit Digit
0 1 2 3 4 5 6 7 8 9
mask mask mask mask mask mask mask mask mask mask
; End of program
;************************************************************************ ;* PROGRAM NAME: 7Seg3.ASM ;* DESCRIPTION: Program displays number "23" on 7-segment LED display ;************************************************************************
pdfcrowd.com
;BASIC DIRECTIVES $MOD53 $TITLE(7SEG3.ASM) $PAGEWIDTH(132) $DEBUG $OBJECT $NOPAGING ;STACK DSEG STACK_START: ;RESET VECTORS CSEG JMP ORG MOV MOV MOV MOV LCALL MOV MOV MOV MOV LCALL MOV SJMP AT DS 03FH 040H
AT XRESET
0 ; Reset vector
XRESET: LOOP:
100H SP,#STACK_START P1,#0 P3,#20h A,#03 Disp P1,A P1,#0 P3,#10h A,#02 Disp P1,A LOOP
; Define Stack pointer ; ; ; ; ; ; ; ; ; ; ; Turn off all display segments Activate display D4 Write digit 3 on display D4 Find appropriate mask for that digit Put the mask on the port Turn off all dislay segments Activate display D3 Write digit 2 on display D3 Find mask for that digit Put the mask on the port Return to the label LOOP
; Digit 0 mask
pdfcrowd.com
DB DB DB DB DB DB DB DB DB END
; ; ; ; ; ; ; ; ;
1 2 3 4 5 6 7 8 9
; End of program
;************************************************************************ ;* PROGRAM NAME : 7Seg5.ASM ;* DESCRIPTION : Program displays number"1234" on 7-segment LED display ;************************************************************************ ;BASIC DIRECTIVES $MOD53 $TITLE(7SEG5.ASM) $PAGEWIDTH(132) $DEBUG $OBJECT $NOPAGING ;STACK DSEG STACK_START: AT DS 03FH 040H
pdfcrowd.com
;RESET VECTORS CSEG JMP ORG XRESET: LOOP: MOV MOV MOV MOV LCALL MOV MOV MOV MOV LCALL MOV MOV MOV MOV LCALL MOV MOV MOV MOV LCALL MOV SJMP
AT 0 XRESET 100H SP,#STACK_START P1,#0 P3,#20h A,#04 Disp P1,A P1,#0 P3,#10h A,#03 Disp P1,A P1,#0 P3,#08h A,#02 Disp P1,A P1,#0 P3,#04h A,#01 Disp P1,A LOOP
; Reset vector
; Define Stack pointer ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; Turn off all display segments Activate display D4 Write digit 4 on display D4 Find mask for that digit Put the mask on the port Turn off all display segments Activate display D3 Write digit 3 on display D3 Find mask for that digit Put the mask on the port Turn off all display segments Activate display D2 Write digit 2 on display D2 Find mask for that digit Put the mask on the port Turn off all display segments Activate display D1 Write digit 1 on display D1 Find mask for that digit Put the mask on the port Return to the lable LOOP
pdfcrowd.com
DB DB DB DB DB DB DB
; ; ; ; ; ; ;
3 4 5 6 7 8 9
;************************************************************************ ;* PROGRAM NAME : 7Seg4.ASM ;* DESCRIPTION: Program displays numbers 0-99 on 7-segment LED displays ;************************************************************************ ;BASIC DIRECTIVES $MOD53 $TITLE(7SEG4.ASM) $PAGEWIDTH(132) $DEBUG $OBJECT $NOPAGING ;STACK DSEG STACK_START: AT DS 03FH 040H
Are you a developer? Try out the HTML to PDF API
pdfcrowd.com
;RESET VECTORS CSEG JMP ORG XRESET: MOV MOV MOV MOV INC CJNE MOV MOV INC CJNE MOV INC CJNE MOV
AT XRESET 100H
0 ; Reset vector
SP,#STACK_START R2,#0 R3,#0 R4,#0 R4 R4,#20d,LAB1 R4,#0 P1,#0 R2 R2,#10d,LAB1 R2,#0 R3 R3,#10d,LAB1 R3,#0
LOOP:
;Wait for display to be "refreshed" for 100 times ;before incrementing the counter ; Turn off all display segments ; Increment Register containing units by 1 ; Reset units ; Increment Register with tens by 1 ; ; Reset tens
LAB1: MOV MOV LCALL MOV LCALL MOV MOV MOV LCALL MOV LCALL SJMP Delay: P3,#20h A,R2 Disp P1,A Delay P1,#0 P3,#10h A,R3 Disp P1,A Delay LOOP ; ; ; ; ; ; ; ; ; ; ; Activate display D4 Copy Register containing units to A Call mask for that digit Write units on display D4 25ms delay Turn off all display segments Activate display D3 Copy Register contaning tens to A Call mask for that digit Write tens on display D3 25ms delay
pdfcrowd.com
F01:
; 5 ms delay
Disp: INC MOVC RET DB DB DB DB DB DB DB DB DB DB END A A,@A+PC 3FH 06H 5BH 4FH 66H 6DH 7DH 07H 7FH 6FH
; ; ; ; ; ; ; ; ; ;
Digit Digit Digit Digit Digit Digit Digit Digit Digit Digit
0 1 2 3 4 5 6 7 8 9
mask mask mask mask mask mask mask mask mask mask
; End of program
Handling EEPROM
This program writes data to on-chip EEPROM memory. In this case, the data is a hexadecimal number 23 which is to be written to the location with address 00. To make sure that this number is correctly written, the same location of EEPROM is read 10mS later in order to compare these two numbers. If they match, F will be displayed. Otherwise, E will be displayed on the LED display (Error).
;************************************************************************ ;* PROGRAM NAME: EEProm1.ASM ;* DESCRIPTION: Programming EEPROM at address 0000hex and displaying message ;* on LED display. ;************************************************************************
pdfcrowd.com
;BASIC DIRECTIVES $MOD53 $TITLE(EEPROM1.ASM) $PAGEWIDTH(132) $DEBUG $OBJECT $NOPAGING WMCON EEMEN EEMWE TEMP THE END ERROR ;STACK DSEG STACK_START: ;RESET VECTORS CSEG JMP ORG XRESET: MOV MOV MOV ORL ORL MOV MOV MOVX CALL AT DS 03FH 040H DATA EQU EQU DATA EQU EQU 96H 00001000B 00010000B 030H 071H 033H
; Access to internal EEPROM is enabled ; Write to EEPROM is enabled ; Define Auxiliary register ; Display "F" ; Display "E"
AT 0 XRESET 100H IE,#00 SP,#STACK_START DPTR,#0000H WMCON,#EEMEN WMCON,#EEMWE TEMP,#23H A,TEMP @DPTR,A DELAY
; Reset vector
; ; ; ; ; ; ;
Choose location address in EEPROM Access to EEPROM is enabled Write to EEPROM is enabled Number written to EEPROM is moved to register TEMP and Accumulator Write byte to EEPROM 10ms delay
pdfcrowd.com
MOVX CJNE MOV MOV XRL XRL SJMP MOV MOV SJMP MOV MOV NOP DJNZ DJNZ DJNZ RET END
A,@DPTR A,TEMP,ERROR A,#KRAJ P1,A WMCON,#EEMWE WMCON,#EEMEN LOOP1 A,#ERROR P1,A LOOP2 A,#0AH R3,A B,LOOP4 B,LOOP5 R3,LOOP3
; Read the same location and compare to TEMP, ; If they don't match, jump to label ERROR ; Display F (correct) ; Write to EEPROM is disabled ; Access to EEPROM is disabled ; Remain here ; Display E (error)
; Delay
; End of program
pdfcrowd.com
;************************************************************************ ;* PROGRAM NAME : UartR.ASM ;* DESCRIPTION: Each data received from PC via UART appears on the port ;* P1. ;* ;************************************************************************ ;BASIC DIRECTIVES
pdfcrowd.com
$MOD53 $TITLE(UARTR.ASM) $PAGEWIDTH(132) $DEBUG $OBJECT $NOPAGING ;STACK DSEG STACK_START: ;RESET VECTORS CSEG JMP ORG JMP ORG XRESET: MOV MOV MOV MOV MOV MOV CLR CLR SETB LOOP: IR_SER: SJMP JNB MOV MOV CLR AT DS 03FH 040H
AT 0 XRESET 023H IR_SER 100H IE,#00 SP,#STACK_START TMOD,#20H TH1,#0FDH SCON,#50H IE,#10010000B TI RI TR1 LOOP RI,OUTPUT A,SBUF P1,A RI
; ; ; ; ; ; ; ; ; ;
All interrupts are disabled Initialization of Stack pointer Timer1 in mode2 9600 baud rate at the frequency of 11.0592MHz Receiving enabled, 8-bit UART UART interrupt enabled Clear transmit flag Clear receive flag Start Timer1
; Remain here ; If any data is received, ; move it to the port ; P1 ; Clear receive flag
pdfcrowd.com
OUTPUT
;************************************************************************ ;* PROGRAM NAME : UartS.ASM ;* DESCRIPTION: Sends values 0-255 to PC. ;************************************************************************ ;BASIC DIRECTIVES $MOD53 $TITLE(UARTS.ASM) $PAGEWIDTH(132) $DEBUG $OBJECT $NOPAGING ;STACK DSEG STACK_START: ;RESET VECTORS CSEG JMP ORG XRESET: MOV MOV MOV AT DS 03FH 040H
; Reset vector
pdfcrowd.com
MOV MOV CLR CLR MOV SETB START: LOOP1: MOV JNB CLR INC CJNE
; ; ; ; ; ; ; ; ; ; ; ;
9600 baud rate at the frequency of 11.0592MHz 8-bit UART Clear transmit bit Clear receive flag Reset caunter Start Timer 1 Move number from counter to a PC Wait here until byte transmission is complete Clear transmit bit Increment the counter value by 1
; If 255 bytes are not sent return to the ; label START ; Remain here ; End of program
LOOP:
SJMP END
LOOP
pdfcrowd.com
************************************************************************* ;* PROGRAM NAME : Lcd.ASM ;* DESCRIPRTION : Program for testing LCD display. 4-bit communication ;* is used. Program does not check BUSY flag but uses program delay ;* between 2 commands. PORT1 is used for connection ;* to the microcontroller. ;************************************************************************ ;BASIC DIRECTIVES $MOD53 $TITLE(LCD.ASM) $PAGEWIDTH(132) $DEBUG
pdfcrowd.com
$OBJECT $NOPAGING ;Stack DSEG Stack_Start: Start_address AT DS EQU 0E0h 020h 0000h ;Reset vectors CSEG ORG JMP ORG MOV MOV Inic: CALL AT 0 Start_address Inic Start_address+100h IE,#00 SP,#Stack_Start LCD_inic ; All interrupts are disabled
; Initialize LCD
;************************************************* ;* MAIN PROGRAM ;************************************************* START: MOV CALL MOV CALL MOV CALL MOV CALL MOV CALL MOV CALL A,#80h LCD_status A,#'M' LCD_putc A,#'i' LCD_putc A,#'k' LCD_putc A,#'r' LCD_putc A,#'o' LCD_putc ; ; ; ; ; Next character will appear on the first location in the first line of LCD display. Display character M. Call subroutine for character transmission. Display character i.
pdfcrowd.com
MOV CALL MOV CALL MOV CALL MOV CALL MOV CALL MOV CALL MOV CALL MOV CALL MOV CALL MOV CALL MOV CALL MOV CALL MOV CALL MOV CALL MOV CALL MOV CALL MOV CALL MOV CALL
A,#'e' LCD_putc A,#'l' LCD_putc A,#'e' LCD_putc A,#'k' LCD_putc A,#'t' LCD_putc A,#'r' LCD_putc A,#'o' LCD_putc A,#'n' LCD_putc A,#'i' LCD_putc A,#'k' LCD_putc A,#'a' LCD_putc A,#0c0h LCD_status A,#'R' LCD_putc A,#'a' LCD_putc A,#'z' LCD_putc A,#'v' LCD_putc A,#'o' LCD_putc A,#'j' LCD_putc
; Display character e. ; Display character l. ; Display character e. ; Display character k. ; Display character t. ; Display character r. ; Display character o. ; Display character n. ; Display character i. ; Display character k. ; Display character a.
; ; ; ; ;
Next character will appear on the first location in the second line of LCD display. Display character R. Call subroutine for character transmission. Display character a.
pdfcrowd.com
MOV CALL MOV CALL MOV CALL MOV CALL MOV CALL MOV CALL MOV CALL MOV CALL MOV CALL MOV CALL MOV CALL MOV MOV CALL MOV CALL JMP
A,#'n' LCD_putc A,#'i' LCD_putc A,#' ' LCD_putc A,#'s' LCD_putc A,#'i' LCD_putc A,#'s' LCD_putc A,#'t' LCD_putc A,#'e' LCD_putc A,#'m' LCD_putc A,#'i' LCD_putc R0,#20d Delay_10ms DPTR,#LCD_DB A,#6d LCD_inic_status R0,#10d Delay_10ms START
; Display character n. ; Display character i. ; Display character . ; Display character s. ; Display character i. ; Display character s. ; Display character t. ; Display character e. ; Display character m. ; Display character i.
;********************************************* ;* Subroutine for wait time (T= r0 x 10ms) ;********************************************* Delay_10ms: MOV MOV MOV R5,00h R6,#100d R7,#100d ; 1+(1+(1+2*r7+2)*r6+2)*r5 approximately ; (if r7>10) ; 2*r5*r6*r7
pdfcrowd.com
;************************************************************************************** ;* SUBROUTINE: LCD_inic ;* DESCRIPTION: Subroutine for LCD initialization. ;* ;* (is used with 4-bit interface, under condition that pins DB4-7 on LCD ;* are connected to pins PX.4-7 on microcontrollers ports, i.e. four higher ;* bits on the port are used). ;* ;* NOTE: It is necessary to define port pins for controlling LCD operation: ;* LCD_enable, LCD_read_write, LCD_reg_select,similar to port for connection to LCD. ;* It is also necessary to define addresses for the first character in each ;* line. ;************************************************************************************** LCD_enable LCD_read_write LCD_reg_select LCD_port Busy LCD_Start_I_red BIT BIT BIT SET BIT EQU P1.3 P1.1 P1.2 P1 P1.7 00h 40h ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; Bit for activating pin Bit for activating pin Bit for activating pin Port for connection to Port pin on which Busy E on LCD. RW on LCD. RS on LCD. LCD. flag appears.
LCD_Start_II_red EQU
Address of the first message character in the first line of LCD display. Address of the first message character in the second line of LCD display. 0 1 2 3 4 5 6 -8b, 2/1 lines, 5x10/5x7 format -4b, 2/1 lines, 5x10/5x7 format -Display/cursor shift, right/left -Display ON, cursor OFF, cursor blink off -Increment mode, display shift off -Display/cursor home -Clear display
LCD_DB:
DB DB DB DB DB DB DB
pdfcrowd.com
DB LCD_inic: MOV MOV CALL MOV CALL MOV lcall MOV CALL MOV CALL MOV CALL MOV CALL MOV CALL RET LCD_inic_status_8:
00001000b
DPTR,#LCD_DB A,#00d LCD_inic_status_8 A,#00d LCD_inic_status_8 A,#00d LCD_inic_status_8 A,#1d LCD_inic_status_8 A,#1d LCD_inic_status A,#3d LCD_inic_status A,#6d LCD_inic_status A,#4d LCD_inic_status ; ; ; ; Triple initialization in 8-bit mode is performed at the beginning (in case of slow increment of power supply when the power supply is on
;****************************************** PUSH MOVC CLR CLR MOV B A,@A+DPTR LCD_reg_select LCD_read_write B,LCD_port
; RS=0 - Write command ; R/W=0 - Write data on LCD ; Lower 4 bits from LCD port are memorized
pdfcrowd.com
B,#11110000b A,#00001111b A,B LCD_port,A LCD_enable LCD_enable ; Time delay in case of improper reset ; during initialization ; Data is moved from A to LCD port ; high-to-low transition signal ; is generated on the LCD's EN pin
MOV B,#255d DJNZ B,$ DJNZ B,$ DJNZ B,$ POP B RET
LCD_inic_status: ;**************************************************************************** MOVC A,@A+DPTR CALL LCD_status RET ;**************************************************************************** ;* SUBROUTINE: LCD_status ;* DESCRIPTION: Subroutine for defining LCD status. ;**************************************************************************** LCD_status: PUSH MOV DJNZ DJNZ DJNZ CLR CALL SWAP B B,#255d B,$ B,$ B,$ LCD_reg_select LCD_port_out A
pdfcrowd.com
;**************************************************************************** ;* SUBROUTINE: LCD_putc ;* DESCRIPTION: Sending character to be displayed on LCD. ;**************************************************************************** LCD_putc: PUSH MOV DJNZ SETB CALL SWAP DJNZ SETB CALL POP RET B B,#255d B,$ LCD_reg_select LCD_port_out A B,$ LCD_reg_select LCD_port_out B
;**************************************************************************** ;* SUBROUTINE: LCD_port_out ;* DESCRIPTION: Sending commands or characters on LCD display ;**************************************************************************** LCD_port_out: PUSH PUSH ACC B
Are you a developer? Try out the HTML to PDF API
pdfcrowd.com
MOV ORL ORL ANL MOV SETB CLR POP POP RET END
; Data is copied from A to LCD port ; high-to-low transition signal ; is generated on the LCD's EN pin
; End of program
;************************************************************************ ;* SUBROUTINE NAME : BinDec.ASM ;* DESCRIPTION : Content of accumulator is converted into three decimal digits ;************************************************************************ BINDEC: MOV DIV MOV MOV DIV B,#10d AB R3,B B,#10d AB ; ; ; ; ; Store decimal number 10 in B A:B. Remainder remains in B Move units to register R3 Store decimal number 10 in B A:B. Remainder remains in B
pdfcrowd.com
; ; ; ; ;
Move tens to register R2 Store decimal number 10 in B A:B. Remainder remains in B Move hundreds to accumulator Return to the main program
previous chapter | table of contents | next chapter
Follow us on
PIC32 Solution
PIC 32 De ve lopm e nt Boards PIC 32 C om pile rs PIC 32 Program m e rs/De bugge rs PIC 32 Kits
dsPIC Solution
dsPIC De ve lopm e nt Boards dsPIC C om pile rs dsPIC Program m e rs/De bugge rs dsPIC Kits dsPIC Book s
Add-on boards
C lick Boards m ik rom e dia shie lds C om m unication boards Storage boards R e al Tim e C lock boards Display boards Me asure m e nt boards Audio & Voice boards Powe r Supply boards GPS boards GSM/GPR S boards
Additional Software
Visual TFT Visual GLC D Pack age Manage r GLC D Font C re ator
8051 Solution
8051 De ve lopm e nt Boards 8051 C om pile rs 8051 Program m e rs/De bugge rs 8051 Book s 8051 Kits
AVR Solution
AVR De ve lopm e nt Boards AVR C om pile rs AVR Program m e rs/De bugge rs AVR Kits
ARM Solution
AR M De ve lopm e nt Boards AR M C om pile rs AR M Program m e rs/De bugge rs AR M Kits
Support
Forum
m ik roBUS
Le ts m ak e
Pre ss
Product Archive
About Us
C opyright 1998 - 2013. MikroElektronika. All rights reserved. All trade and/or services marks mentioned are the property of their respective owners.
pdfcrowd.com