EPIC-1: User Guide

Download as pdf or txt
Download as pdf or txt
You are on page 1of 56

mikroElektronika development systems

EPIC-1
Development systems

EPIC-1
User guide
September 2001.

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu


mikroElektronika development systems
EPIC-1
Development systems

CONTENTS

EPIC-1 development systems page 4

Examples:
Connecting LED diodes to PORTB microcontroller page 6
Port.asm page 7
Bank.inc page 8
Wait.inc page 8

Connecting buttons to microcontroller pins page 10


Button.asm page 11
Button.inc page 12

Connecting a mini-speaker to a microcontroller page 13


Beep.asm page 14
Beep.inc page 16

Connection of an input shift register to a microcontr. page 17


HC597.asm page 18
HC597.inc page 19

Connecting an LCD display to a microcontroller page 21


Lcd.asm page 22
Print.inc page 24
Lcd.inc page 25

Connecting a microcontroller to a PC via a RS232 line page 28


SCI.asm page 29
RS232.inc page 31

Connecting an AD converter to a microcontroller page 34


Ltc1286.asm page 35
Ltc1286.inc page 37
Lcdv16.inc page 39

Connecting a microcontroller to 7-seg. display


in muxltiplex mode. page 41
7-seg.asm page 42
7-seg.inc page 43

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu I


mikroElektronika development systems
EPIC-1
Development systems

Connection of an output shift register to a microcontr. page 46


HC595.asm page 47
HC595.inc page 48

Connecting relay on the microcontroller page 49


Relay.asm page 50

Input RA4 / TOCKI line optocouplering example page 51


Tmr0.asm page 52

Input RB0 / INT line optocouplering example page 53


Int0.asm page 54

PICPROG software for microcontroller programming page 55

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu II


mikroElektronika development systems
EPIC-1
Development systems

EPIC-1
development system
O ne of the biggest advantages of this development environment is
microcontroller programming within a system. More simply put,
microcontroller does not need to be taken out in order for it be programmed!
The programming is made a whole lot easier. It is enough to move the switches
into upper position, attach the serial cable and programming can begin. By It is enough to move the
returning the switch into a lower position, the system is reset, and a switches into upper
microcontroller starts executing a program. position, attach the serial
cable and programming
There are two connectors for a serial cable (SUBD9 connectors) on the can begin.
system, but there shouldn't be any confusion about this, the right one is used
for microcontroller programming, and the left one for establishing a serial
You can just read a sample
connection with the computer (when some application is programmed which into MPLAB, translate it
contains within itself a request for RS232 communication). and thus obtained HEX file
read into a microcontroller
Connector for RS232 communication is easiest to recognize in that behind it
you can find a MAX232 communication chip with four capacitors. System
supply is flexible so that both direct and alternating voltage from 9 to 15V can One more advantage of
this system is a large
be brought in. 15V is not the limit but one should be careful as with higher
number of ready samples
voltages a great dissipation can occur on a voltage regulator LM7805. for all peripherals it has

Since microcontroller PIC16F84 has only 18 pins (and of these 18 only 13 can
be used in any application) shift registers are used for more inputs and The most serious elements
outputs. There are two , one is input which increases the number of inputs to on the plate are surely 12-
8 more, and one output which increases the number of outputs also to 8 more. bit AD converter LTC1286
They are connected with a microcontroller via four lines found on the port A. with a reference of 5V. AD
converter is of serial type
Connector for 74HC595 output shift register is found in the place of jumper
so it takes only three pins
group JP2 at the last lattice to the left. This solution is very interesting because for communication with a
LED diodes can be switched to outputs from shift register, and port B can be microcontroller
freed for something else. Connector for input shift register 74HC597 is found
by the prototyping field in form of one eight-pin lattice so that any additions
(elements which are needed but are not found on the system) may easily be
implemented on the system.

By the mentioned prototyping field are found two IDC10 connectors (two
parallel lattices of five pins) where port A and port B lines are conducted
out.This is done to make it easier to work with additions outside the system.
You can just connect to a connector the female IDC10 connector using a
striped cable, and the entire port can be connected to some external plate.

For indication of program function the system uses several elements, first are
eight LED diodes which can be moved to output of shift register on port B

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu 4


mikroElektronika development systems
EPIC-1
Development systems

pins, but that can also be removed Above the optocoupler is found is done in just a few steps. By clicking
completely by taking all eight connector lattice for setting an LCD on FILE->OPEN_FILE we get a
jumpers from JP2 field. Beside these display. In order to hook up the new window where we select a HEX
there are two sevensegment digits in display we need to solder female file we wish to enter into a
multiplex mode that can successfully connector lattice to display contacts. microcontroller. When a file is
satisfy some numeric applications Thus prepared LCD is simply selected, switches on the
(sevensegment digits divide port B pressed into male lattice (with this development system are placed into
with diodes so that they need to be operation plate supply needs to be upper position, and by clicking on the
taken off if not used). Multiplexing is turned off). LCD display is very "PROGRAM CHIP" button
done with two transistors found on useful because it provides a lot of programming begins. The
RA0 and RA1 so that keys on these information to a programmer, and its programming flow can be followed in
pins can not be used together with lowered cost promises it will become a status line where at the end you get
digits. an integral part off development a message that programming is
systems of the future. Using finished. If an error occurs, the cause
Beeper on pin RA3 for sound signals potentiometer P2 we can adjust the is most likely a wrong COM port or
can also serve as a means of contrast of an LCD display. the system was not turned into a
indication. RA3 pin is shared by program mode (selection of
several components so it is necessary The most serious elements on the communication port is done by
to choose which one of them is to be plate are surely 12-bit AD converter clicking on the menu option SETUP-
used. If beeper is being used, you LTC1286 with a reference of 5V. AD >COM_PORT).
need to place jumper on JP1. The converter is of serial type so it takes
same pin as beeper uses relay, so for only three pins for communication All needed software is found on a
relay use a jumper has to be placed with a microcontroller. Input of AD CD that comes with the system
on JP5 and taken off JP1. Relay is converter is conducted out on screw (including MPLAB software for PIC
optocouplered, and its contacts connectors so it is not difficult to microcontroller programming). You
conducted out on screw connectors hook up some external signal that's can just read a sample into MPLAB,
(so they can be used more easily). being measured. In case we just wish translate it and thus obtained HEX
Since the idea with the relay was to to see how AD converter works we file read into a microcontroller using
show how optocouplering works in can simply switch the JP4 jumper to PicProg program. Aside from
the real world, in order to work relay two right pins, and the input of AD writing, MPLAB can also be used for
has to be supplied from the external converter is a potentiometer P1. Its program simulation which is
source. This is done the easiest with a rotation changes the supply at the especially useful when you are just
5V supply which is already found on input of AD converter from 0 to 5V. starting to work with
the plate (even though we don't have microcontrollers.
optocouplering in the real sense of One more advantage of this system is
the word it is enough for a try out). In a large number of ready samples for More information about EPIC-1 can
order to do this we need to connect all peripherals it has, from a starting be found on following Internet
the positive pole of supply on screw sample with blinking diodes, sound addresses:
connectors Cn4 to a positive pole of signal of various tones on the beeper, http://www.mikroelektronika.co.yu/
relay supply on screw connectors Cn5 input and ouput shift register to 12- moduli/modul25e.htm
and do the same for a negative pole. bit AD converter with a display of
Only so prepared relay can work! the result on an LCD display and You can take a system scheme in
There are two more optocouplers on serial communication with a Protel format, samples, PicProg
the plate, one for an interrupt input, computer, etc... program and short instructions off of
and the other for a timer input. these address.
Inputs for both optocouplers are Microcontroller programming is In case you have additional
conducted out on screw connectors done with Windows' program questions, feel free to call one of our
so that it is easy to bring in an "PicProg". The mentioned program editorial office:
external signal. is quite easy to use, and programming E-mail: office@mikroelektronika.co.yu

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu 5


mikroElektronika development systems
EPIC-1
Development systems

EXAMPLE LED: Connecting LEDs to port B

+5V

R10=10ΚΩ
1 18
RA2 RA1
2 17
RA3 RA0 4MHz
3 16
RA4/TOCKI OSC1
4 15
MCLR OSC2
5 PIC 14
+5V

Vss 16F84 Vdd


6 13 RL1=330Ω LD0
RB0/INT RB7
7 12 RL2=330Ω LD1
RB1 RB6
Reset

8 11 RL3=330Ω LD2
RB2 RB5
9 10 RL4=330Ω LD3
RB3 RB4

RL5=330Ω LD4

RL6=330Ω LD5

RL7=330Ω LD6

RL8=330Ω LD7

Jumpers setting

JP2 don't care if JP5 is open


LD0 RB0 RA3 can be connected on
JP1

LD1 RB1 beeper,if it is not used for


LD2 RB2
LD3 relay
RB3
LD4 RB4
LD5 RB5
JP6

In this example we can't use


LD6 RB6
LD7 RB7
input optocoupler, because
pin RB0 is used for LED
JP3
T0 RA0
T1 RA1 don't care if JP1 is open don't care
JP4
T2 RA2
T3 RA3 In this example we don't use
JP5
AD converter
RA3 can be connected on
Buttons are not used in this example.If
relay, if it is not already
we need buttons .
used for beeper

LED diodes can be moved from port B to output of shift register, but that can also be removed
completely by taking all eight jumpers from JP2 field.

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu 6


mikroElektronika development systems
EPIC-1
Development systems

ASM PORT.ASM

;***** Declaring and configuring a microcontroller *****

PROCESSOR 16f84
#include "p16f84.inc"

__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC

;***** Declaring variables *****

Cblock 0x0C ; Beginning of RAM


WCYCLE ; Belongs to 'WAITX' macro
PRESCwait
endc

;***** Structure of program memory *****

ORG 0x00 ; Reset vector


goto Main

ORG 0x04 ; Interrupt vector


goto Main ; No interrupt routine

#include "bank.inc" ; Assistant files


#include "wait.inc"

Main ; Beginning of the program

clrf WCYCLE
clrf PRESCwait

BANK1
movlw 0xff ; PORTA initialization
movwf TRISA ; TRISA <- 0xff
movlw 0x00 ; PORTB initialization
movwf TRISB ; TRISB <- 0x00
BANK0

Loop
movlw 0xf0
movwf PORTB ; PORTB <- 0xf0

WAIT .250

movlw 0x0f
movwf PORTB ; PORTB <- 0x0f

WAIT .250

goto Loop ; Repeat loop

End ; End of program

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu 7


mikroElektronika development systems
EPIC-1
Development systems

INC BANK.INC

;*****************************************************************
;
; Memory select macros for PIC 16XXX
; ==================================
;
;*****************************************************************

BANK0 macro
bcf STATUS,RP0 ; Select memory bank 0
endm

BANK1 macro
bsf STATUS,RP0 ; Select memory bank 1

INC WAIT.INC PAGE 1/2

;*****************************************************************
;
; Wait routines for PIC 16XXX
; ============================================
; Processor: Microchip PIC 16XXX
; Clock: 4.00 MHz XT
; Instruction cycle: 1 MIPS
;
; Prescaler values:
;
; b'00000000' == 1:2 ==> 0.512 ms
; b'00000001' == 1:4 ==> 1.02 ms
; b'00000111' == 1:256 ==> 65.3 ms
;
; Waittime = WCYCLE (= timeconst) * prescaler
;
; List of macros:
;
; "WAIT xxx" ; standard
; "WAITX xxx, xxx" ; extended with prescaler value
;
; In the main program you must have the next declaration:
; =======================================================
; Cblock 0x0C ; Beginning of RAM
; WCYCLE
; PRESCwait
; endc
;
;*****************************************************************

;***** Declaring constants *****

CONSTANT PRESCstd = b'00000001' ; standard prescaler value for TMR0

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu 8


mikroElektronika development systems
EPIC-1
Development systems

INC WAIT.INC PAGE 2/2

;***** Macros *****

WAIT macro timeconst_1


movlw timeconst_1
call WAITstd
endm

WAITX macro timeconst_2, PRESCext


movlw timeconst_2
movwf WCYCLE ; set the delay time period
movlw PRESCext ; write specific prescaler value
call WAIT_x
endm

;***** Subprograms *****

WAITstd movwf WCYCLE ; set the delay time period


movlw PRESCstd ; write specific prescaler value
WAIT_x clrf TMR0
BANK1
movwf OPTION_REG ; assing the prescaler to TMR0 timer
BANK0

WAITa bcf INTCON,T0IF ; erase TMR0 Overflow Flag


WAITb btfss INTCON,T0IF ; Check whether it is erased
; skip if it isn`t
goto WAITb ; Wait loop
decfsz WCYCLE,1 ; Repeat the loop if delay period
; has not run out
goto WAITa

RETURN

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu 9


mikroElektronika development systems
EPIC-1
Development systems

EXAMPLE BUTTONS: Connecting buttons to microcontroller pins

+5V

R8=10KΩ

R6=10KΩ
R9=10KΩ

R7=10KΩ
pull-up resistors

1 18
RA2 RA1
2 17
RA3 RA0 4MHz
T3 T2 T1 T0 3 16
RA4/TOCKI OSC1
+5V 4 15
R10=10K
MCLR OSC2
5 PIC 14 +5V
Vss 16F84 Vdd
6 13
RB0/INT RB7
Reset

7 12
RB1 RB6
8 11
RB2 RB5
9 10
RB3 RB4

Jumpers setting

JP2
LD0 RB0 RA3 can't be connected on JP4 don't care
JP1

don't care
LD1 RB1 beeper, because it is used In this example we don't use
Port B is free. LD2 RB2 for button T3 AD converter
LD3 RB3
LD4 RB4
LD5 RB5 don't care RA3 can't be connected on
JP6

LD6 RB6 In this example we don't use relay, because it is used for
LD7 RB7 input optocoupler JP5 button T3

Pins on port A Pins on port B


JP2 JP2
T0 RA0 T0 RB7
Buttons T0...3 can T1 RA1 T1 RB6
be connected on: T2 RA2 T2 RB5
T3 RA3 T3 RB4

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu 10


mikroElektronika development systems
EPIC-1
Development systems

ASM BUTTON.ASM

;***** Declaring and configuring a microcontroller *****

PROCESSOR 16f84
#include "p16f84.inc"

__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC

;***** Declaring variables *****

Cblock 0x0C ; Beginning of RAM


WCYCLE ; Belongs to 'WAITX' macro
PRESCwait
endc

;***** Structure of program memory *****

ORG 0x00 ; Reset vector


goto Main

ORG 0x04 ; Interrupt vector


goto Main ; No interrupt routine

#include "bank.inc" ; Assistant files


#include "button.inc"
#include "wait.inc"

Main ; Beginning of the program


BANK1
movlw 0xff ; PORTA initialization
movwf TRISA ; TRISA <- 0xff
movlw 0x00 ; PORTB initialization
movwf TRISB ; TRISB <- 0x00
BANK0

clrf PORTB ; PORTB <- 0x00

Loop
Button 0, PORTA, 2, .100, On ; Button 1
Button 0, PORTA, 3, .100, Off ; Button 2
goto Loop

On
bsf PORTB,7 ; Turn on LED
return

Off
bcf PORTB,7 ; Turn off LED
return
End ; End of program

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu 11


mikroElektronika development systems
EPIC-1
Development systems

INC BUTTON.INC

;**************************************************************************
;
; Debouching buttons
; ==================
;
; Writen by: Andric Dragan, 21.07.1999, mikroElektronika
;
; ==============
; Processor: Microchip PIC 16XXX
; Clock: 4.00 MHz XT
; Instruction cycle: 1 MIPS
;
;
; List of macros:
;
; "Button HiLo, Port, Bit, Delay, Adrress"
;
; In the main program you must have the next declaration:
; =======================================================
; Cblock 0x0C ; Beginning of RAM
; WCYCLE ; Belongs to 'WAITX' macro
; PRESCwait
; endc
;
;**************************************************************************

Button macro HiLo, Port, Bit, Delay, Adrress

Local Exit ; Local labels


Local Loop

if HiLo == 0 ; Is the key pressed ?


btfsc Port,Bit ; Is input line LOW ?
else
btfss Port,Bit ; Is input line HIGH ?
endif
goto Exit ; If key hasn`t been pressed
; exit the macro

WAIT Delay ; Delay for key debounce


Loop
if HiLo == 0
btfss Port,Bit ; Is the key released ?
else
btfsc Port,Bit
endif
goto Loop

WAIT Delay ; Delay for key debounce

call Adrress ; Call the service subprogram


Exit ; Exit the macro
endm ; End of macro

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu 12


mikroElektronika development systems
EPIC-1
Development systems

EXAMPLE MINI-SPEAKER: Connecting a mini-speaker to a microcontroller

+5V +5V 1 18
RA2 RA1
2 17

R10=10ΚΩ
R7=10KΩ

R6=10KΩ

RA3 RA0 4MHz


3 16
RA4/TOCKI OSC1
4 15
MCLR OSC2
Reset

5 PIC 14 +5V
T1 T0 Vss 16F84 Vdd
6 13

R2=330Ω
RB0/INT RB7
7 12
RB1 RB6
8 11
RB2 RB5
9 10
RB3 RB4

Jumpers setting

JP2
don't care RA3 have to be connected
JP1

LD0 RB0
LEDs are not used LD1 RB1 on beeper (JP1 is closed)
in this example. LD2 RB2
LD3 RB3
LD4 RB4 don't care
JP6

LD5 RB5 In this example we don't use input optocoupler.


LD6 RB6 Pin RB0 is free and JP6 is open.
LD7 RB7
JP3
Buttons are connected on T0 RA0
T1 JP5 RA3 can't be connected
RA0 and RA1 RA1 JP4
don't care
T2 RA2 on relay, it is already
T3 RA3 In this example we
used for beeper (JP5 is
don't use AD
open)
converter

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu 13


mikroElektronika development systems
EPIC-1
Development systems

ASM BEEP.ASM PAGE 1/2

;***** Declaring and configuring a microcontroller *****

PROCESSOR 16f84
#include "p16f84.inc"

__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC

;***** Declaring variables *****

Cblock 0x0C ; Beginning of RAM-a


WCYCLE ; Belongs to 'WAITX' macro
PRESCwait
Beep_TEMP1 ; Belongs to 'BEEP' macro
Beep_TEMP2
Beep_TEMP3
endc

;***** Declaring the hardware *****

#define BEEPport PORTA,3 ; Port and pin for mini speaker


#define BEEPtris TRISA,3

;***** Structure of program memory *****

ORG 0x00 ; Reset vector


goto Main

ORG 0x04 ; Interrupt vector


goto Main ; No interrupt routine

#include "bank.inc" ; Assistant files


#include "button.inc"
#include "wait.inc"
#include "beep.inc"

Main ; Beginning of the program


BANK1
movlw 0x17 ; Port A initialization
movwf TRISA ; TRISA <- 0x00
movlw 0x00
movwf TRISB
BANK0

BEEPinit ; Mini speaker initialization

clrf PORTB

Loop
Button 0, PORTA, 0, .100, Play1 ; Button 1
Button 0, PORTA, 1, .100, Play2 ; Button 2
goto Loop

Play1
BEEP 0xFF, 0x02

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu 14


mikroElektronika development systems
EPIC-1
Development systems

ASM BEEP.ASM PAGE 2/2


BEEP 0x90, 0x05
BEEP 0xC0, 0x03
BEEP 0xFF, 0x03 ; First melody
return

Play2
BEEP 0xbb, 0x02
BEEP 0x87, 0x05
BEEP 0xa2, 0x03
BEEP 0x98, 0x03 ; Second melody
return

End ; End of program

INC BEEP.INC PAGE 1/2


;**************************************************************************
;
; GENERATING A SOUND
; ==================
;
; Writen by: Andric Dragan, 21.07.1999, mikroElektronika
;
; ==============
; Processor: Microchip PIC 16XXX
; Clock: 4.00 MHz XT
; Instruction cycle: 1 MIPS
; Additional hardware: Mini speaker
;
;
; List of macros:
;
; "BEEPinit" - Inital BEEP port
; "BEEP xxx yyy" - Generate a sound
; xxx is sound frequency
; yyy is sound duration
;
; In the main program you must declare next variables:
; ====================================================
; Cblock 0x0C ; Beginning of RAM
; Beep_TEMP1
; Beep_TEMP2
; Beep_TEMP3
; endc ; End
;
; #define BEEPport PORTA,3 ; BEEP port
; #define BEEPtris TRISA,3
;
;**************************************************************************

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu 15


mikroElektronika development systems
EPIC-1
Development systems

INC BEEP.INC PAGE 2/2


;***** Declaring constants *****

CONSTANT PRESCbeep = b'00000111' ; 65,3 ms per cycle

;***** Macros *****

BEEP macro freq,duration


movlw freq
movwf Beep_TEMP1
movlw duration
call BEEPsub
endm

BEEPinit macro
bcf BEEPport
BANK1
bcf BEEPtris
BANK0
endm

;***** Podprogrami *****

BEEPsub movwf Beep_TEMP2 ; Set the value of sound duration


clrf TMR0 ; Initialize the counter
bcf BEEPport
BANK1
bcf BEEPport
movlw PRESCbeep ; Set the prescaler for TMR0
movwf OPTION_REG ; OPTION <- W
BANK0
BEEPa bcf INTCON,T0IF ; Erase TMR0 Overflow Fleg
BEEPb bsf BEEPport
call B_Wait ; Duration of logic "1"
bcf BEEPport
call B_Wait ; Duration of logic "0"
btfss INTCON,T0IF ; Check the TMR0 Overflow Fleg,
goto BEEPb ; Skip of it is set
decfsz Beep_TEMP2,1 ; Is the Beep_TEMP2 = 0 ?
goto BEEPa ; If not, jump to BEEP again
RETURN

B_Wait movfw Beep_TEMP1


movwf Beep_TEMP3
B_Waita decfsz Beep_TEMP3,1

goto B_Waita

RETURN

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu 16


mikroElektronika development systems
EPIC-1
Development systems

EXAMPLE INPUT SHIFT REGISTER: Connection of an input shift register to


a microcontroller

Input connector Cn7


+5V 1 18
0 RA2 RA1
2 17
1
B Vcc
RA3 RA0 4MHz
3 16
2
C A RA4/TOCKI OSC1
+5V 4 15
3 R10=10K
D Serial input MCLR OSC2
4 Serial or 5 PIC 14
+5V

16F84
E parallel
mode Vss 16F84 Vdd
5 6 13 RL1=330Ω LD0
F Latch
RB0/INT RB7
6
G Clock 7 12 RL2=330Ω LD1

Reset
7
+5V RB1 RB6
H Reset 8 11 RL3=330Ω LD2
GND Seial output
RB2 RB5
9 10 RL4=330Ω LD3
74HC597 RB3 RB4

RL5=330Ω LD4

RL6=330Ω LD5

RL7=330Ω LD6

RL8=330Ω LD7

Jumpers setting

JP2
LD0 RB0
JP1

LD1 RB1 RA3 can't be connected on beeper, because


LEDs are connected on LD2 RB2 it is used for connection to shift register
port B microcontroller LD3 RB3
LD4 RB4
LD5 RB5
JP6

In this example we can't use input optocoupler,


LD6 RB6
LD7 RB7
because pin RB0 is used for LED

JP3
Buttons are not RA0
used in this example RA1
RA2 RA3 can't be connected on relay, because it is
RA3 JP5 used for connection to shift register

Cn7
JP4 don't care
H Shift register
You have to put input shift In this example we
74HC597

G 74HC597
register correctly: F input lines don't use AD converter
E
D
This side down! C
B
A

Input connector Cn7

Warrning: Before you put input shift register 74HC597 on system be shure that
MAX232,74HC595 and LTC1286 chips are removed from the system

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu 17


mikroElektronika development systems
EPIC-1
Development systems

ASM HC597.ASM

;***** Declaring and configuring a microcontroller *****

PROCESSOR 16f84
#include "p16f84.inc"

__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC

;***** Declaring variables *****

Cblock 0x0C ; Beginning of RAM-a


RX
CountSPI
endc

;***** Declaring the hardware *****

#define Data PORTA,0


#define Clock PORTA,1
#define Latch PORTA,2
#define Load PORTA,3

;***** Structure of program memory *****

ORG 0x00 ; Reset vector


goto Main

ORG 0x04 ; Interrupt vector


goto Main ; No interrupt routine

#include "bank.inc" ; Assistant files


#include "hc597.inc"

Main ; Beginning of the program


BANK1
movlw b'00010001' ; Port A initialization
movwf TRISA ; TRISA <- 0x11
clrf TRISB
BANK0

clrf PORTA ; PORTA <- 0x00

bsf Load ; Enable SHIFT register

Loop
HC597 RX, CountSPI

; Status of input pins of SHIFT register


movf RX,W ; are found in variable RX
movwf PORTB ; Set the contents of RX variable to port B

goto Loop ; Repeat the loop

End ; End of program

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu 18


mikroElektronika development systems
EPIC-1
Development systems

INC HC597.INC PAGE 1/2

;**************************************************************************
;
; Input SHIFT register 74HC597
; ============================
;
; Writen by: Andric Dragan, 21.07.1999, mikroElektronika
;
; ==============
; Processor: Microchip PIC 16XXX
; Clock: 4.00 MHz XT
; Instruction cycle: 1 MIPS
; Additional hardware: SHIFT register 74HC597
;
;
; List of macros:
;
; "HC597 Var,Var1"
;
; Var - Data buffer variable
; Var1 - Loop counter
;
; In the main program you must have the next declaration:
; =======================================================
; Cblock 0x0C ; Beginning of RAM
; TX ; Data buffer
; Count ; Loop counter
; endc
;
; #define Data PORTA,0
; #define Clock PORTA,1
; #define Latch PORTA,3
; #define Load PORTA,2
;
;**************************************************************************

HC597 macro Var,Var1

Local Loop ; Local label

movlw .8 ; transfer eight bits


movwf Var1 ; Counter initialization

bsf Latch ; Read pins at input latch


nop
bcf Latch

bcf Load
nop
bsf Load

Loop rlf Var,f ; Rotate 'Var' one space to left

btfss Data ; Is Data line = '1' ?


bcf Var,0 ; If not, erase bit '0' at Var variable

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu 19


mikroElektronika development systems
EPIC-1
Development systems

INC HC597.INC PAGE 2/2

btfsc Data ; Is Data line = '0' ?


bsf Var,0 ; If not, set bit '0'

bsf Clock ; Make one clock


nop
bcf Clock

decfsz Var1,f ; Are 8 bits received ?


goto Loop ; If not, repeat

endm

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu 20


mikroElektronika development systems
EPIC-1
Development systems

EXAMPLE LCD : Connecting an LCD display to a microcontroller

1 18
+5V RA2 RA1
2 17
RA3 RA0 4MHz +5V
3 16
R10=10K RA4/TOCKI OSC1 k arakt eri : cc +
4 15
MCLR OSC2 m i k ro e l e k t r o n i k a
5 PIC 14
Vss 16F84 Vdd +5V
6 13
RB0/INT RB7
Reset

7 12 14 1
RB1 RB6
8 11
RB2 RB5
9 10 data lines
RB3 RB4
Pt2
D7
+5V S
ER P

PIH

AI
D6

N
D5
D4
E
R/W
Contrast for
RS LCD

control lines

Jumpers setting

JP2
LD0
JP1

LEDs are not used in this LD1 RA3 can be used for beeper if it is not
example LD2 used for relay
LD3
LD4
LD5 In this example we can use input
JP6

LD6 optocoupler, because pin RB0 is not


LD7 used
JP3
Buttons are not used in this T0 RA0
example.If we need buttons , T1 RA1 don't care if JP1 is open
we can connect them on port T2 RA2 RA3 can be used for relay if it is not used
T3 RA3 JP5 for beeper
A(see JP3)

JP4
don't care
In this example we don't use
AD converter

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu 21


mikroElektronika development systems
EPIC-1
Development systems

ASM LCD.ASM PAGE 1/2

;***** Declaring and configuring a microcontroller *****

PROCESSOR 16f84
#include "p16f84.inc"

__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC

;***** Declaring variables *****

Cblock 0x0C ; Beginning of RAM


LCDbuf ; Belongs to 'LCDxxx' macros
LCDtemp
WCYCLE ; Belongs to 'WAITX' macro
PRESCwait
Pointer ; Pointer on characters in message
endc

;***** Declaring the hardware *****

LCDtris equ TRISB


LCDport equ PORTB

;***** Structure of program memory *****

ORG 0x00 ; Reset vector


goto Main

ORG 0x04 ; Interrupt vector


goto Main ; No interrupt routine

Messages ; Beginning of the messages


movwf PCL
; Display messages

Message1 dt "mIkRoEleKtrOnIkA"
Message2 dt "bla, bla"
Message3 dt "example"

END_messages ; End of messages

#include "bank.inc" ; Assistant files


#include "wait.inc"
#include "lcd.inc"
#include "print.inc"

Main ; Beginning of the program

bcf PORTB,2

LCDinit ; LCD initialization

LCDchar 'K' ; Display character on LCD


LCDchar 'a'
LCDchar 'r'

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu 22


mikroElektronika development systems
EPIC-1
Development systems

ASM LCD.ASM PAGE 2/2

LCDchar 'a'
LCDchar 'k'
LCDchar 't'
LCDchar 'e'
LCDchar 'r'
LCDchar 'i'
LCDchar ':'
LCDchar ' '

LCDchar 0x00 ; Display special characters


LCDchar 0x01

LCDline 2 ; Second line

; Display message1 on LCD

PRINT Messages, Message1, Message2, Pointer, LCDw

Loop goto Loop ; Stay here

End ; End of program

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu 23


mikroElektronika development systems
EPIC-1
Development systems

INC PRINT.INC

;***** Declaring the hardware *****

RS equ 1 ; Register Select


RW equ 2 ; Read/Write
EN equ 3 ; Enable Output / "CLK"

;***** LCD commands *****

CONSTANT LCDEM8 = b'00110000' ; 8 Bit Mode, 2 Lines


CONSTANT LCDDZ = b'10000000' ; Write 0 u DDRAM
CONSTANT LCDEM4 = b'00100000' ; 4 Bit Mode, 2 Lines

;***** Standard commands for LCD initializatoion *****

CONSTANT LCD2L = b'00101000' ; Function: 4 bit 2 lines


CONSTANT LCDCONT = b'00001100' ; Display control: Display ON,
; Cursor OFF, blink OFF
CONSTANT LCDSH = b'00101000' ; Display mode: AutoInc cursor
; NoDisplayAutoShift

;***** Standard LCD commands *****

; In order to send one of these commands to LCD, we need to use LCDcmd


; macro, ex. "LCDcmd LCDCLR"

CONSTANT LCDCLR = b'00000001' ; clears display, resets cursor


CONSTANT LCDCH = b'00000010' ; cursor home
CONSTANT LCDCR = b'00000110' ; cursor move direction right
CONSTANT LCDCL = b'00000100' ; cursor move direction left
CONSTANT LCDSL = b'00011000' ; shifts display content left
CONSTANT LCDSR = b'00011100' ; shifts display content right
CONSTANT LCDL1 = b'10000000' ; selects line 1
CONSTANT LCDL2 = b'11000000' ; selects line 2

;***** Macros *****

LCDinit macro
call LCD_init ; LCD initialization
endm

LCDchar macro LCDarg ; write out the character on LCD


movlw LCDarg
call LCDdata
endm

LCDw macro
call LCDdata
endm

LCDcmd macro LCDcommand ; send the command to LCD


movlw LCDcommand
call LCDcomd
endm

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu 24


mikroElektronika development systems
EPIC-1
Development systems

INC LCD.INC PAGE 1/3

LCDline macro line_num


IF (line_num == 1)
LCDcmd LCDL1 ; Start macro with "First Line" instruc.
ELSE
IF (line_num == 2)
LCDcmd LCDL2 ; Start macro with "Second Line" instruc.
ELSE
ENDIF
ENDIF
endm

LCD_DDAdr macro DDRamAddress


Local value = DDRamAddress | b'10000000' ; Beginning of DDRAM
IF (DDRamAddress > 0x67)
ERROR "Wrong DDRAM address in LCD_DDAdr"
ELSE
movlw value
call LCDcomd
ENDIF
endm

LCD_CGAdr macro CGRamAddress


Local value = CGRamAddress | b'01000000' ; Beginning of CGRAM
IF (CGRamAddress > b'00111111')
ERROR "Wrong CGRAM address in LCD_CGAdr"
ELSE
movlw value
call LCDcomd
ENDIF
endm

;***** Subprograms *****

LCDcomd clrf LCDbuf ; Clear Data flag


goto LCDwr

LCDdata clrf LCDbuf


bsf LCDbuf,RS ; Set Data flag

LCDwr movwf LCDtemp ; Command/Data in Temp


andlw b'11110000' ; set aside the upper halfbyte
iorwf LCDbuf,0 ; set aside Data flag
movwf LCDport ; send the upper halfbyte to LCD port
call LCDclk
clrf LCDport
swapf LCDtemp,0 ; exchange the upper and lower halfbyte
; palces again
andlw b'11110000' ; set aside the lower halfbyte
iorwf LCDbuf,0 ; set aside the Data fleg
movwf LCDport ; send the low half byte to LCD port
call LCDclk
clrf LCDport
RETURN

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu 25


mikroElektronika development systems
EPIC-1
Development systems

INC LCD.INC PAGE 2/3

LCDclk WAITX 0x02, 0x00 ; Enable access to LCD for data and
; commands to be writen in
bsf LCDport,EN
bcf LCDport,EN
WAIT 0x02
RETURN

LCD_init
clrf LCDport ; Prepare LCDport
BANK1
clrf OPTION_REG
movlw b'00000000'
movwf LCDtris
BANK0
WAIT 0x02

movlw LCDEM8 ; Start initialization


movwf LCDport ; with "8-bit mode"
call LCDclk
clrf LCDport
WAIT 0x02

movlw LCDDZ ; write 0 in DDRAM


movwf LCDport
call LCDclk
clrf LCDport

movlw LCDEM4 ; go to 4 bit mode


movwf LCDport
call LCDclk
clrf LCDport

LCDcmd LCD2L ; Function: 2 lines, 4-bit mode


LCDcmd LCDCONT ; Display ON, no cursor
LCDcmd LCDSH ; Mode displaying AutoInc, NoAutoShift
LCDcmd LCDCLR ; Clear display, address counter to zero
call LCDspecialChars ; read in characters defined by the user
; to CGRAM
RETURN

LCDspecialChars ; Maximum number of characters


; that user can define is 8

; *** first special Character is "C" at the position 0x00 ***


; *** is called form "LCDchar 0x00" ***

LCD_CGAdr 0x00 ; Send CGRAM address


LCDchar b'00001010' ; Write data to CGRAM address
LCD_CGAdr 0x01
LCDchar b'00000100'
LCD_CGAdr 0x02
LCDchar b'00001110'
LCD_CGAdr 0x03

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu 26


mikroElektronika development systems
EPIC-1
Development systems

INC LCD.INC PAGE 4/4

LCDchar b'00010001'
LCD_CGAdr 0x04
LCDchar b'00010000'
LCD_CGAdr 0x05
LCDchar b'00010001'
LCD_CGAdr 0x06
LCDchar b'00001110'
LCD_CGAdr 0x07
LCDchar b'00000000'

; *** first special Character is "C" at the position 0x01 ***


; *** is called form "LCDchar 0x01" ***

LCD_CGAdr 0x08
LCDchar b'00000010'
LCD_CGAdr 0x09
LCDchar b'00000100'
LCD_CGAdr 0x0A
LCDchar b'00001110'
LCD_CGAdr 0x0B
LCDchar b'00010001'
LCD_CGAdr 0x0C
LCDchar b'00010000'
LCD_CGAdr 0x0D
LCDchar b'00010001'
LCD_CGAdr 0x0E
LCDchar b'00001110'
LCD_CGAdr 0x0F
LCDchar b'00000000'

LCD_DDAdr 0x00 ; Reset DDRAM

RETURN

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu 27


mikroElektronika development systems
EPIC-1
Development systems

EXAMPLE SERIAL COMMUNICATION: Connecting a microcontroller to a PC


via a RS232 line

C13=4.7µF +5V

1 18
RA2 RA1
C1+ 2 17

C11=4.7µF C10=4.7µF
Vcc
+ RA3 RA0 4MHz
V+ Vss 3 16
SUB-9- D pin connector on C1- T1out
RA4/TOCKI OSC1
+5V 4 15
microcontroller system R10=10K
MCLR
PIC OSC2

16F84
C2+ R1in
+ 5 14
+5V
C2- R1out Vss 16F84 Vdd
1 6 13
6
C12=4.7µF
V- T1in
RB0/INT RB7
2 7 12

Reset
T2out T2in
7 RB1 RB6
3
R2in R2out 8 11
8
4 RB2 RB5
9 MAX232 9 10
5 RB3 RB4

Serial cable
(1 on 1)

1
6
2 Receives data (Rx)
7
3 Sends data (Tx)
8
4
9
5

SUB-9- D pin connector on PC

Jumpers setting

JP2
JP1

RB0 is used for RS-232 RB0 RA3 can't be used for beeper because RA3 is
comunication (RX line) RB1 used as signal T2 in on MAX 232
RB2
RB3
RB4 In this example can't use input optocoupler,
JP6

RB5
RB6
because pin RB0 is used for R2out
RB7

JP3
RA0 RA3 can't be used for
RA1
JP5
relay
RA2
RA3
JP4 don't care
In this example we don't use AD converter

You must have serial


connection to PC trough
RS-232 connector

RS- 232 connector

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu 28


mikroElektronika development systems
EPIC-1
Development systems

ASM SCI.ASM PAGE 1/2

;***** Declaring and configuring a microcontroller *****

PROCESSOR 16f84
#include "p16f84.inc"

__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC

;***** Declaring variables *****

Cblock 0x0C ; Beginning of RAM


RS_TEMP1 ; Belongs to 'RS232'
RS_TEMP2
TXD
RXD
Pointer ; Pointer on characters in message
endc

;***** Deklaracija hardvera *****

#define TXport PORTA,3


#define TXtris TRISA,3

LCDtris equ TRISB


LCDport equ PORTB

;***** Structure of program memory *****

ORG 0x00 ; Reset vector


goto Main

ORG 0x04 ; Interrupt vector


goto ISR ; Jump on interrupt routine

Messages

movwf PCL ; Beginning of the messages

; Display messages

Message0 dt "Received character from PIC16F84: "


Message1 dt "$ PIC16F84 on line $"

END_messages ; End of messages

#include "bank.inc" ; Assistant files


#include "rs232.inc"
#include "print.inc"

;***** Interrupt routine *****

ISR bcf INTCON,GIE ; Disable all interrupts


btfsc INTCON,GIE
goto ISR

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu 29


mikroElektronika development systems
EPIC-1
Development systems

ASM SCI.ASM PAGE 1/2

RECEIVE ; Store received data in RX variable

SEND TAB
; Send massage 0

PRINT Messages, Message0, Message1, Pointer, SENDw

movfw RXD ; Send back received data


SENDw

SEND CR ; Carriage Return


SEND LF ; Line Feed
SEND LF

ISRend bcf INTCON,INTF ; Clear interrupt fleg RB0/INT


RETFIE ; Enable all interrupts

Main ; Beginning of the program

RS232init ; RS232 initialization

; Send message 1

PRINT Messages, Message1, END_messages, Pointer, SENDw

SEND CR ; Carriage Return


SEND LF ; Line Feed
SEND LF

Loop goto Loop ; Stay here

End ; End of program

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu 30


mikroElektronika development systems
EPIC-1
Development systems

INC RS232.INC PAGE 1/2

;**************************************************************************
;
; Software RS232 communication
; ============================
;
; Writen by: Andric Dragan, 21.07.1999, mikroElektronika
;
; ==============
; Processor: Microchip PIC 16XXX
; Clock: 4.00 MHz XT
; Instruction cycle: 1 MIPS
; Additional hardware: MAX232
;
;
; List of macros:
;
; "RS232init" - Initialization
; "SEND 'c' " - send ASCII charcters
; "SENDw" - send dump of w register
; "RECEIVE" - Function in ISR, receive data in RXD register
;
; In the main program you must have the next declaration:
; =======================================================
; Cblock 0x0C ; Beginning of RAM
; RS_TEMP1 ; Temp register
; RS_TEMP2
; TXD ; TX-Data register
; RXD ; RX-Data register
; endc
;
; #define TXport PORTA,0x00 ; RS232 TX pin
; #define TXtris TRISA,0x00
;
; ORG 0x04 ; interrupt vector
; goto ISR ; jump on ISR (Interrupt Service Routine)
;
; ;***** INTERRUPT SERVICE ROUTINE *****
;
; ISR bcf INTCON,GIE ; Disable all interrupts
; btfsc INTCON,GIE
; goto ISR
; RECEIVE
; <... future code ...>
; ISRend bcf INTCON,INTF ; Erase interrupt flag RB0/INT
; RETFIE ; Enable interrupts - INTCON,GIE
;
;*************************************************************************

;***** Declaring the hardware *****

#define RXport PORTB,0


#define RXtris TRISB,0

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu 31


mikroElektronika development systems
EPIC-1
Development systems

INC RS232.INC PAGE 2/2

;***** Declaring constants *****

CONSTANT LF = d'10' ; Line Feed


CONSTANT CR = d'13' ; Carriage Return
CONSTANT TAB = d'9' ; Tabulator
CONSTANT BS = d'8' ; Backspace

;***** Macros *****

RS232init macro
call RS_init
endm

SEND macro S_string


movlw S_string
call SENDsub
endm

SENDw macro
call SENDsub
endm

RECEIVE macro
call RECsub
endm

;***** Subprograms *****

RS_init bcf TXport


BANK1
clrf OPTION_REG
bcf TXtris
bsf RXtris
BANK0
bsf TXport
movlw b'10010000'
movwf INTCON
RETURN

SENDsub movwf TXD


bcf TXport
movlw 0x08
movwf RS_TEMP1
call S_Wait
SENDa btfsc TXD,0
goto SENDb
bcf TXport
goto SENDc
SENDb bsf TXport
SENDc rrf TXD,1
call S_Wait
decfsz RS_TEMP1,1
goto SENDa
goto SENDd

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu 32


mikroElektronika development systems
EPIC-1
Development systems

INC RS232.INC PAGE 2/2

SENDd bsf TXport


call S_Wait
call S_Wait
RETURN

S_Wait movlw 0x1E


movwf RS_TEMP2
goto X_Wait

Rs_Wait movlw 0x0C


movwf RS_TEMP2
goto X_Wait

R_Wait movlw 0x1D


movwf RS_TEMP2
goto X_Wait

X_Wait decfsz RS_TEMP2,1


goto X_Wait
RETURN

RECsub call Rs_Wait


btfsc RXport
goto REENTRY
movlw 0x08
movwf RS_TEMP1
goto RECa
RECa call R_Wait
btfss RXport
goto RECb
bsf RXD,0x07
goto RECc
RECb bcf RXD,0x07
RECc decfsz RS_TEMP1,0
rrf RXD,1
decfsz RS_TEMP1,1
goto RECa
call R_Wait
btfss RXport
clrf RXD
RETURN

REENTRY clrf RXD


goto ISRend

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu 33


mikroElektronika development systems
EPIC-1
Development systems

EXAMPLE AD CONVERTOR: Connecting an AD converter


to a microcontroller

+5V

+5V

R9=10KΩ

R8=10KΩ
5V
c +5V
Vref Vcc
1 18
0V
+IN CLK RA2 RA1
2 17
analog input -IN Dout RA3 RA0 4MHz
3 16
GND CS
RA4/TOCKI OSC1
+5V R10=10K 4 15
LTC1286 MCLR OSC2
5 PIC 14 +5V
Vss 16F84 Vdd
6 13
NC NC RB0/INT RB7

Reset
Vin=7-40V 7 12
Vin NC
RB1 RB6
TEMP Vout 8 11
Vout=5V RB2 RB5
GND Trim 9 10
RB3 RB4
REF02

Jumpers setting

JP2
don't care
LD0 RB0 RA3 can't be connected
JP1

LD1 RB1 on beeper(JP1 is not open)


LEDs are not used in this example. LD2 RB2
LD3 RB3
LD4 RB4
LD5 RB5 don't care
JP6

LD6 RB6 In this example we don't use input


LD7 RB7 optocoupler.Pin RB0 is free .
JP3
RA0 RB7
RA1 RB6
Buttons are not used in this example. RB5 RA3 can't be connected
RB4 JP5 on relay(JP5 is open)

Input AD converter can be connected :


JP4
on potetiometer Pt1(which simulates signal)

JP4
or on connect point Cn1for conversion of
signal which cames outside the system

Cn3 Cn5 Cn6 - + Cn1 Cn4


- + Cn7
- + - + - +
Analog DC
input output
(0-5V) +5V

12V-
N/C N/O
Switching
Input Input Relay contacts
optocupler optocupler input
analog input on RB0 on RA4 voltage

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu 34


mikroElektronika development systems
EPIC-1
Development systems

ASM LTC1286.ASM PAGE 1/2

;***** Declaring and configuring a microcontroller *****

PROCESSOR 16f84
#include "p16f84.inc"

__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC

;***** Declaring variables *****

Cblock 0x0C ; Beginning of RAM


LCDbuf ; Belongs to 'LCDxxx' macros
LCDtemp
WCYCLE ; Belongs to 'WAITX' macro
PRESCwait

TEMP1 ; Belongs to "LCDval_16" macro


TEMP2
TEMP3
LO ; LO_Data buffer
HI ; HI_Data buffer
LO_TEMP
HI_TEMP
Bcheck

Count ; Belongs to "LTC86" macro


Pointer ; Pointer on characters in message
endc

;***** Declaring the hardware *****

#define Data PORTA,0


#define Clock PORTA,1
#define CS PORTA,2

LCDtris equ TRISB


LCDport equ PORTB

;***** Structure of program memory *****

ORG 0x00 ; Reset vector


goto Main

ORG 0x04 ; Interrupt vector


goto Main ; No interrupt routine

Messages ; Beginning of the messages

movwf PCL
; Display messages

Message0 dt "* LTC1286 *"


Message1 dt "A/D rezul.:"

END_messages ; End of messages

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu 35


mikroElektronika development systems
EPIC-1
Development systems

ASM LTC1286.ASM PAGE 2/2

#include "bank.inc" ; Assistant files


#include "ltc1286.inc"
#include "wait.inc"
#include "lcd.inc"
#include "lcdv16.inc"
#include "print.inc"

Main ; Beginning of the program


BANK1
movlw 0xf1 ; Port A initialization
movwf TRISA ; TRISA <- 0xf1
BANK0

LCDinit ; LCD initialization

clrf PORTA ; PORTA <- 0x00

LCD_DDAdr .3

PRINT Messages, Message0, Message1, Pointer, LCDw

; Read value on AD coverter input

Loop
LTC86 LO, HI, Count
; Display AD result
call Out ; on LCD display

goto Loop ; Repeat loop

Out
LCDline 2 ; Second line

PRINT Messages, Message1, END_messages, Pointer, LCDw

LCDval_16

return

End ; End of program

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu 36


mikroElektronika development systems
EPIC-1
Development systems

INC LTC1286.INC PAGE 1/2

;**************************************************************************
;
; 12-bit A/D converter - LTC1286
; ==============================
;
; Writen by: Andric Dragan, 21.07.1999, mikroElektronika
;
; ==============
; Processor: Microchip PIC 16XXX
; Clock: 4.00 MHz XT
; Instruction cycle: 1 MIPS
; Additional hardware: A/D converter LTC1286
;
;
; List of macros:
;
; "LTC86 Var_LO, Var_HI, Var"
;
; Var_LO - LSB data result of AD conversion
; Var_HI - MSB data result of AD conversion
; Var - Loop counter
;
; In the main program you must have the next declaration:
; =======================================================
; Cblock 0x0C ; Beginning of RAM
; LSB ; LSB data buffer
; MSB ; MSB data buffer
; Count ; Loop counter
; endc
;
; #define Data PORTA,0
; #define Clock PORTA,1
; #define CS PORTA,2
;
;**************************************************************************

LTC86 macro Var_LO, Var_HI, Var

Local Loop ; Local label


Local Loop1

clrf Var_LO ; Erase data buffer


clrf Var_HI

movlw .4
movwf Var ; Counter initialization

bcf CS ; Enable AD coverter

call CLK ; Enable Dout line


call CLK ; /
call CLK ; NULL bit

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu 37


mikroElektronika development systems
EPIC-1
Development systems

INC LTC1286.INC

Loop rlf Var_HI,f ; RRotate 'Var_HI' one space to left

btfss Data ; is Dout line = '1' ?


bcf Var_HI,0 ; if not, clear bit '0' in Var_HI variable
btfsc Data ; is Dout line = '0' ?
bsf Var_HI,0 ; if not, set bit '0' in Var_HI variable

call CLK

decfsz Var,f ; Are 4 bits received ?


goto Loop ; If not, repeat

movlw .8
movwf Var ; Counter initialization

Loop1 rlf Var_LO,f ; Rotate 'Var_LO' one space to left

btfss Data ; is Dout line = '1' ?


bcf Var_LO,0 ; if not, clear bit '0' in Var_LO variable
btfsc Data ; is Dout line = '0' ?
bsf Var_LO,0 ; if not, set bit '0' in Var_LO variable

call CLK

decfsz Var,f ; Are 8 bits received ?


goto Loop1 ; If not, repeat

bsf CS ; Disable AD converter

endm
CLK
bsf Clock ; Make one clock
nop
nop
nop
bcf Clock

return

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu 38


mikroElektronika development systems
EPIC-1
Development systems

INC LCDV16.INC PAGE 1/2

LCDval_16 macro
call LCDval16
endm

;***** Subprograms *****

LCDval16
movfw LO
movwf LO_TEMP
movfw HI
movwf HI_TEMP
clrf Bcheck

movlw b'00010000'
movwf TEMP2
movlw b'00100111'
movwf TEMP3
call VALcnv

movlw b'11101000'
movwf TEMP2
movlw b'00000011'
movwf TEMP3
call VALcnv

movlw b'01100100'
movwf TEMP2
clrf TEMP3
call VALcnv

movlw b'00001010'
movwf TEMP2
clrf TEMP3
call VALcnv

movlw b'00000001'
movwf TEMP2
clrf TEMP3
bsf Bcheck,0

call VALcnv
RETURN

VALcnv clrf TEMP1


Vcnv1 movfw TEMP3
subwf HI_TEMP,0
skpc
goto LCDval2
bnz Vcnv2

movfw TEMP2
subwf LO_TEMP,0
skpc
goto LCDval2

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu 39


mikroElektronika development systems
EPIC-1
Development systems

INC LCDV16.INC PAGE 2/2

Vcnv2 movfw TEMP3


subwf HI_TEMP,1
movfw TEMP2
subwf LO_TEMP,1
skpc
decf HI_TEMP,1
incf TEMP1,1
bsf Bcheck,0
goto Vcnv1

LCDval2 movlw '0'


addwf TEMP1,0
btfss Bcheck,0
movlw ' '
LCDw
RETURN

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu 40


mikroElektronika development systems
EPIC-1
Development systems

EXAMPLE 7-SEG. DISPLAY: Connecting a microcontroller to


7-seg. disp. in mux. mode

Tr1 Tr0
R15=10ΚΩ R16=10ΚΩ

+5V 1 18 g f K a b g f K a b

8. 8.
RA2 RA1
2 17
R10=10ΚΩ

RA3 RA0 4MHz


3 16
RA4/TOCKI OSC1
4 15
MCLR OSC2
5 PIC 14 +5V
T1
Vss 16F84 Vdd
6 13 RD8=330Ω e d K c dp e d K c dp
RB0/INT RB7
7 12 RD7=330Ω
RB1 RB6
8 11 RD6=330Ω
RB2 RB5
9 10 RD5=330Ω
RB3 RB4

RD4=330Ω

RD3=330Ω

RD2=330Ω

RD1=330Ω

Jumpers setting

JP2 don't care if JP5 is open


JP1

LD0
RA3 can be connected on beeper,if it is not
LEDs can't be used LD1
LD2 used for relay
LD3
LD4
LD5
JP6

In this example we can't use input


LD6
LD7 optocoupler(JP6 is not connected)

JP3
RA0
Buttons are not used don't care if JP1 is open
RA1
in this example. T2 RA2 RA3 can be connected on relay, if it is not
T3 RA3 JP5 already used for beeper

JP4 don't care


In this example AD converter is not used

Notes: When 7-seg displays are not used resistors R15 and R16 should be removed

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu 41


mikroElektronika development systems
EPIC-1
Development systems

ASM 7-SEG.ASM

;***** Declaring and configuring a microcontroller *****

PROCESSOR 16f84
#include "p16f84.inc"

__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC

;***** Declaring variables *****

Cblock 0x0C ; Beginning of RAM


TempC ; Belongs to "LED_Disp2" macro
LO
endc

;***** Declaring the hardware *****

LEDtrisA equ TRISA


LEDportA equ PORTA

LEDtrisB equ TRISB


LEDportB equ PORTB

;***** Structure of program memory *****

ORG 0x00 ; Reset vector


goto Main

ORG 0x04 ; Interrupt vector


goto ISR ; Interapt rutina is found
; in 7-seg.inc file

#include "bank.inc" ; Assistant files


#include "7-seg.inc"

Main ; Beginning of the program


LED_Init

LED_Disp2 0x21 ; Display on two 7-seg. displays


; number "21"
loop goto loop ; Stay here

End ; End of program

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu 42


mikroElektronika development systems
EPIC-1
Development systems

INC 7-SEG.INC PAGE 1/3

;**************************************************************************
;
; Seven-segment display (multiplexing)
; ====================================
;
; Writen by: Andric Dragan, 21.07.1999, mikroElektronika
;
; ==============
; Processor: Microchip PIC 16XXX
; Clock: 4.00 MHz XT
; Instruction cycle: 1 MIPS
; Additional hardware: 7-segment displays
;
;
; List of macros:
;
; "LED_Init" - Initialization
; "LED_Disp2 num" - Display two digit number
;
;
; In the main program you must have the next declaration:
; =======================================================
; Cblock 0x0C ; Beginning of RAM
; TempC ; Temp. variable
; LO ; LO_Data buffer
; endc
;
; LEDtrisA equ TRISA
; LEDportA equ PORTA
;
; LEDtrisB equ TRISB
; LEDportB equ PORTB
;
;**************************************************************************

;***** Macros *****

LED_Init macro
call InitPorts
call InitTimers
endm

LED_Disp2 macro num


movlw num
movwf LO
call UpdateDisplay
endm

;***** Subprograms *****

InitPorts
BANK1
clrf LEDtrisA ; Pins RA0-4 are output
clrf LEDtrisB ; Port B is output

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu 43


mikroElektronika development systems
EPIC-1
Development systems

INC 7-SEG.INC PAGE 2/3

BANK0
clrf LEDportA ; Set all outputs to '0'
clrf LEDportB ; /
bsf LEDportA,3 ; Turn on MSD display

RETURN

InitTimers
BANK1
movlw B'10000100' ; Move the prescaler to TMR0
movwf OPTION_REG ; ps = 32
BANK0
movlw B'00100000' ; Enable TMR0 interrupt
movwf INTCON ;
movlw .96 ;
movwf TMR0 ; Start the timer

RETFIE

;***** ISR - Interrup service routine ******

ISR bcf INTCON,GIE ; Disable all interrupts


btfsc INTCON,GIE ; Check whether they are diasbled
goto ISR

movlw .96 ; Initialize the TMR0


movwf TMR0
bcf INTCON,T0IF ; Erase the T0IF flag
call UpdateDisplay ; "Refresh" dispaly

RETFIE

UpdateDisplay
movf LEDportA,W ; Display status -> w register
clrf LEDportA ; Turn off all 7-seg. displays
andlw 0x0f ; Separate the lower halfbyte
movwf TempC ; Save display status in TempC
bsf TempC,4 ; Beginning status of LSD display
rrf TempC,F ; Set the status of the next display
btfss STATUS,C ; c=1 ?
bcf TempC,3 ; If not, turn off the LSD display
btfsc TempC,0 ; If it is, check the status of MSD display
goto UpdateMsd ; If it is turned on, display the MSD digit
; of the number
UpdateLsd
call ChkMsdZero ; msd = 0 ?
btfss STATUS,Z ; If it is, skip
movf LO,W ; Third LSD digit -> W
andlw 0x0f ; /
goto DisplayOut ; Show it on the display
UpdateMsd
swapf LO,W ; Msd digit -> W
andlw 0x0f ; /

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu 44


mikroElektronika development systems
EPIC-1
Development systems

INC 7-SEG.INC PAGE 3/3

btfsc STATUS,Z ; msd != 0 ?


movlw 0x0a ; If it is, skip
DisplayOut
call LedTable ; Take the mask for a digit
movwf LEDportB ; Set the mask on port B
movf TempC,W ; Turn on displays
movwf LEDportA

RETURN

LedTable
addwf PCL, F
retlw B'00111111' ; mask for digit 0
retlw B'00000110' ; mask for digit 1
retlw B'01011011' ; mask for digit 2
retlw B'01001111' ; mask for digit 3
retlw B'01100110' ; mask for digit 4
retlw B'01101101' ; mask for digit 5
retlw B'01111101' ; mask for digit 6
retlw B'00000111' ; mask for digit 7
retlw B'01111111' ; mask for digit 8
retlw B'01101111' ; mask for digit 9
retlw B'00000000' ; no digit........

ChkMsdZero ; Checking the leading zero


movf LO,W ; Msd digit -> W
btfss STATUS,Z ; = 0 ? skip
RETURN ; If it is, skip
retlw .10 ; If not, go back from 10 to W reg.

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu 45


mikroElektronika development systems
EPIC-1
Development systems

EXAMPLE OUTPUT SHIFT REGISTER: Connection of an output shift register


to a microcontr.

1 18
RL1=330Ω LD0
RA2 RA1
+5V 2 17
RL2=330Ω LD1
QB Vcc
RA3 RA0 4MHz
3 16
RL3=330Ω LD2
QC QA RA4/TOCKI OSC1
+5V 4 15
RL4=330Ω R10=10K
LD3 QD Serial input MCLR OSC2
5 PIC 14
RL5=330Ω LD4 QE OE
Vss 16F84 Vdd +5V

16F84
QF Latch
6 13
RL6=330Ω LD5 RB0/INT RB7

Reset
QG Clock 7 12
RL7=330Ω LD6 +5V RB1 RB6
QH Reset 8 11
RL8=330Ω LD7
Vss
Serial RB2 RB5
output 9 10
74HC595 RB3 RB4

Jumpers setting

LEDs are connected on JP2 don't care if JP5 is open


output pins of shift register LD0 RA3 can be connected on
JP1

QA
LD1 QB beeper,if it is not used for
LD2 QC relay
LD3 QD
LD4 QE don't care
LD5 QF In this example we don't use input
JP6

LD6 QG optocoupler.Pin RB0 is free ,so if we need


LD7 QH input optocoupler we can close JP6 .
JP3
Buttons are not used T0 RB7
in this example. T1 RB6 don't care if JP1 is open JP4 don't care
If we need buttons T2 RB5 In this example we don't use
we can connect T3 RB4 JP5 AD converter
them on port B. RA3 can be connected on
relay, if it is not already
used for beeper
You have to put input shift
register correctly:
This side up!
74HC595

Warrning:Before you put output shift register 74HC595 on system


be shure that 74HC597 and LTC1286 chips are removed from
the system

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu 46


mikroElektronika development systems
EPIC-1
Development systems

ASM: HC595.ASM

;***** Declaring and configuring a microcontroller *****

PROCESSOR 16f84
#include "p16f84.inc"

__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC

;***** Declaring variables *****

Cblock 0x0C ; Beginning of RAM


TX ; Belongs to 'HC595' macro
CountSPI
endc

;***** Declaring the hardware *****

#define Data PORTA,0


#define Clock PORTA,1
#define Latch PORTA,2

;***** Structure of program memory *****

ORG 0x00 ; Reset vector


goto Main

ORG 0x04 ; Interrupt vector


goto Main ; No interrupt routine

#include "bank.inc" ; Assistant files


#include "hc595.inc"

Main ; Beginning of the program

BANK1
movlw 0x18 ; Port A initialization
movwf TRISA ; TRISA <- 0x18
BANK0

clrf PORTA ; PORTA <- 0x00

movlw 0xCB ; Fill the TX buffer


movwf TX ; TX <- '11001011'

HC595 TX, CountSPI

Loop goto Loop ; Stay here

End ; End of program

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu 47


mikroElektronika development systems
EPIC-1
Development systems

INC HC595.INC

;**************************************************************************
; Output SHIFT REGISTER 74HC595
; =============================
;
; Writen by: Andric Dragan, 21.07.1999, mikroElektronika
;
; ==============
; Processor: Microchip PIC 16XXX
; Clock: 4.00 MHz XT
; Instruction cycle: 1 MIPS
; Additional hardware: SHIFT register 74HC595
;
; List of macros:
;
; "HC595 Var,Var1"
;
; Var - Data buffer variable
; Var1 - Loop counter
;
; In the main program you must have the next declaration:
; =======================================================
; Cblock 0x0C ; Beginning of RAM
; TX ; Data buffer
; Count ; Loop counter
; endc
; #define Data PORTA,0
; #define Clock PORTA,1
; #define Latch PORTA,2
;
;**************************************************************************

HC595 macro Var,Var1

Local Loop ; Local label

movlw .8 ; transfer eight bits


movwf Var1 ; Counter initialization

Loop rlf Var,f ; Rotate 'Var' one space to left

btfss STATUS,C ; Is carry = '1' ?


bcf Data ; If not, set Data line to '0'
btfsc STATUS,C ; Is carry = '0' ?
bsf Data ; If not, set Data line to '1'

bsf Clock ; Make one clock


nop
bcf Clock

decfsz Var1,f ; Are eight bits sent ?


goto Loop ; If not, repeat
bsf Latch ; If all 8 bits have beem sent, move the
nop ; contents form SHIFT register to output latch
bcf Latch
endm

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu 48


mikroElektronika development systems
EPIC-1
Development systems

EXAMPLE RELAY: Connecting relay on the microcontroller

+5V

R10=10K
1 18
RA2 RA1
2 17
RA3 RA0
4MHz
3 16
RA4/TOCKI OSC1
4 15
MCLR OSC2
5 PIC 14 +5V
Vss 16F84 Vdd
6 13
RB0/INT RB7
Reset
7 12 ~ 220V
RB1 RB6
8 11
50Hz
RB2 RB5
9
RB3 RB4
10
Consumer
Relay input voltage
Cn5

+5V Rectifier
Protective
+ 12V -
diode
R3=330K Ω

Cn6 Optocoupler
Relay supply
H11B1

Spool with coils

Jumpers setting

JP2 JP4
RA3 can't be closed on don't care
JP1

LD0 RB0
LD1 RB1 beeper,because RA3 is
LD2 RB2 used for relay In this example we don't
don't care
LD3 RB3 use AD converter
Leds are not used don't care
LD4 RB4
in this example.
JP6

LD5 RB5 In this example we don't use input


LD6 RB6 optocoupler on pin RB0
LD7 RB7 JP5

JP3
don't care T0 RA0
Buttons are not used
T1 RA1 RA3 is closed on Relay
T2 RA2 relay(JP5 is closed)
in this example. JP5 H11B1
T3 RA3

Cn3 Cn5 Cn6 Cn1


- + Cn4
- + Cn7
- + - + - +
Analog DC
input output
(0-5V) +5V

12V-
N/C N/O
Input
optocupler
Input
optocupler
Relay input Switching contacts
on RB0 on RA4 voltage of relay

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu 49


mikroElektronika development systems
EPIC-1
Development systems

ASM RELAY.ASM

;***** Declaring and configuring a microcontroller *****

PROCESSOR 16f84
#include "p16f84.inc"

__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC

;***** Declaring variables *****

Cblock 0x0C ; Beginning of RAM


WCYCLE ; Belongs to 'WAITX' macro
PRESCwait
endc

;***** Declaring the hardware *****

#define RELAY PORTA,3

;***** Structure of program memory *****

ORG 0x00 ; Reset vector


goto Main

ORG 0x04 ; Interrupt vector


goto Main ; No interrupt routine

#include "bank.inc" ; Assistant files


#include "button.inc"
#include "wait.inc"

Main ; Beginning of the program


BANK1
movlw 0x17 ; PORTA initialization
movwf TRISA ; TRISA <- 0xff
movlw 0x00 ; PORTB initialization
movwf TRISB ; TRISB <- 0x00
BANK0

clrf PORTB ; PORTB <- 0x00


Loop
Button 0, PORTA, 0, .100, On ; Button 0
Button 0, PORTA, 1, .100, Off ; Button 1

goto Loop ; Repeat loop

On
bsf RELAY ; Turn on relay
return
Off
bcf RELAY ; Turn off relay
return

End ; End of program

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu 50


mikroElektronika development systems
EPIC-1
Development systems

EXAMPLE TIMER: Input RA4 line optocouplering example

1 18
optocouplered side RA2 RA1
2 17
RA3 RA0 4MHz
3 16
RA4/TOCKI OSC1
+5V 4 15
+12V +5V R10=10K
MCLR
5 PIC OSC2 14 +5V
Vss 16F84 Vdd

R12=10KΩ
R5=330Ω

6 13
RB0/INT RB7

Reset
7 12
RB1 RB6
8 11
RB2 RB5
9 10
Input on Cn6 RB3 RB4

CNY17

Jumpers setting

RA4
+5V 10ΚΩ

CNY17

330Ω

Cn3 Cn5 Cn6 - + Cn1 Cn4


- + Cn7
- + - + - +
Analog DC
input output
(0-5V) +5V

12V-
N/C N/O
Switching
Input Input Relay contacts
optocupler optocupler input
on RB0 on RA4 voltage

Input on Cn6

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu 51


mikroElektronika development systems
EPIC-1
Development systems

ASM TMR0.ASM

;***** Declaring and configuring a microcontroller *****

PROCESSOR 16f84
#include "p16f84.inc"

__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC

;***** Structure of program memory *****

ORG 0x00 ; Reset vector


goto Main

ORG 0x04 ; Interrupt vector


goto Main ; No interrupt routine

#include "bank.inc" ; Assistant files

Main ; Beginning of the program


BANK1
movlw 0xff ; PORTA initialization
movwf TRISA ; TRISA <- 0xff
movlw 0x00 ; PORTB initialization
movwf TRISB ; TRISB <- 0x00
movlw b'00110000' ; RA4 -> TMR0,
movwf OPTION_REG ; Increment TMR0 on failing edge
BANK0

clrf PORTB ; PORTB <- 0


clrf TMR0 ; TMR0 <- 0

Loop

movf TMR0,w ; Copy TMR0 in W reg.


movwf PORTB ; send value of W reg. on PORTB
goto Loop ; Repeat loop

End ; End of program

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu 52


mikroElektronika development systems
EPIC-1
Development systems

EXAMPLE INTERRUPT : Input RBO/ INT line optocouplering example

1 18
RA2 RA1
2 17
RA3 RA0 4MHz
optocouplered side 3 16
RA4/TOCKI OSC1
+5V 4 15
R10=10K
MCLR OSC2
5 PIC 14 +5V
Vss 16F84 Vdd
6 13
+12V RB0/INT RB7
7 12
RB1 RB6
R11=10KΩ

Reset
R4=330Ω

8 11
RB2 RB5
9 10
RB3 RB4

Input line optocouplering example

CNY17

Jumpers setting

RB0
If JP5 is closed input
JP5 optocoupler is connected
on RB0 pin
+5V 10ΚΩ

CNY17
330Ω

Cn3 Cn5 Cn6 Cn1


- + Cn4
- + Cn7
- + - + - +
Analog DC
input output
(0-5V) +5V

12V-
N/C N/O
Switching
Input Input Relay contacts
optocupler optocupler input
on RB0 on RA4 voltage

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu 53


mikroElektronika development systems
EPIC-1
Development systems

ASM INT0.ASM

;***** Declaring and configuring a microcontroller *****

PROCESSOR 16f84
#include "p16f84.inc"

__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC

;***** Structure of program memory *****


Cblock 0x0C ; Start of RAM-a
Port
endc

;***** Structure of program memory *****

ORG 0x00 ; Reset vector


goto Main

ORG 0x04 ; Interrupt vector


goto ISR

#include "bank.inc" ; Assistant files

Main ; Beginning of the program


BANK1
movlw 0x01 ; PORTB initialization
movwf TRISB ; TRISB <- 0x01
movlw 0x00
movwf OPTION_REG ; Interrupt on failing edge
movlw b'10010000' ; Enable interrupt INT0
movwf INTCON
BANK0
clrf Port ; Clear “Port”
clrf PORTB ; PORTB=0
Loop
goto Loop ; Stay in a loop

;***** Interrupt rutine *****

ISR

bcf INTCON,7 ; Disable interrupts GIE <- 0

btfss INTCON,INTF ; Did interrupt happened


goto _exit ; if not, go out from ISR

comf Port ; Complement “Port”


movf Port,w ; Port -> W
andlw b'10000000'
movwf PORTB ; W -> PORTB
_exit

bcf INTCON,INTF ; Clear INTF


retfie ; Return from ISR GIE <- 1
End ; End of program

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu 54


mikroElektronika development systems
EPIC-1
Development systems

PicPROG PICPROG PROGRAM : Instructions for PICPROG programming

PicProg is an easy to use program for PIC16F84 microcontroller


programming. It is started out of windows environment.

The programming itself is done in two steps:

Step 1.
You need to open a HEX file by clicking on FILE-->OPEN FILE which
opens a new window 'Open Hex File' where you can find hex file that you
wish to read into a microcontroller.

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu 55


mikroElektronika development systems
EPIC-1
Development systems

Step 2.

When you select a file, switches are turned into upper position on the
development system, and by clicking on "Program Chip' button you start
the microcontroller programming. Flow of programming can be followed
on a status line where you get a message at the end stating that a
microcontroller is programmed.

SELECTING THE SERIAL PORT:


Before programming, it is necessary to select a serial port through which
the development system is being programmed.

By clicking on SETUP->Con_PORT we get a new window where you can


select the computer port through which programming is done.

PIC, AVR, MC68HC11, i8051 development systems www.mikroelektronika.co.yu 56

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy