EPIC-1: User Guide
EPIC-1: User Guide
EPIC-1: User Guide
EPIC-1
Development systems
EPIC-1
User guide
September 2001.
CONTENTS
Examples:
Connecting LED diodes to PORTB microcontroller page 6
Port.asm page 7
Bank.inc page 8
Wait.inc page 8
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
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
+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
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
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.
ASM PORT.ASM
PROCESSOR 16f84
#include "p16f84.inc"
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
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
;*****************************************************************
;
; 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
;
;*****************************************************************
RETURN
+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
ASM BUTTON.ASM
PROCESSOR 16f84
#include "p16f84.inc"
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
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
;
;**************************************************************************
+5V +5V 1 18
RA2 RA1
2 17
R10=10ΚΩ
R7=10KΩ
R6=10KΩ
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
PROCESSOR 16f84
#include "p16f84.inc"
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
Play2
BEEP 0xbb, 0x02
BEEP 0x87, 0x05
BEEP 0xa2, 0x03
BEEP 0x98, 0x03 ; Second melody
return
BEEPinit macro
bcf BEEPport
BANK1
bcf BEEPtris
BANK0
endm
goto B_Waita
RETURN
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
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
Warrning: Before you put input shift register 74HC597 on system be shure that
MAX232,74HC595 and LTC1286 chips are removed from the system
ASM HC597.ASM
PROCESSOR 16f84
#include "p16f84.inc"
Loop
HC597 RX, CountSPI
;**************************************************************************
;
; 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
;
;**************************************************************************
bcf Load
nop
bsf Load
endm
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
JP4
don't care
In this example we don't use
AD converter
PROCESSOR 16f84
#include "p16f84.inc"
Message1 dt "mIkRoEleKtrOnIkA"
Message2 dt "bla, bla"
Message3 dt "example"
bcf PORTB,2
LCDchar 'a'
LCDchar 'k'
LCDchar 't'
LCDchar 'e'
LCDchar 'r'
LCDchar 'i'
LCDchar ':'
LCDchar ' '
INC PRINT.INC
LCDinit macro
call LCD_init ; LCD initialization
endm
LCDw macro
call LCDdata
endm
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
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'
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'
RETURN
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
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
PROCESSOR 16f84
#include "p16f84.inc"
Messages
; Display messages
SEND TAB
; Send massage 0
; Send message 1
;**************************************************************************
;
; 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
;
;*************************************************************************
RS232init macro
call RS_init
endm
SENDw macro
call SENDsub
endm
RECEIVE macro
call RECsub
endm
+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
JP4
or on connect point Cn1for conversion of
signal which cames outside the system
12V-
N/C N/O
Switching
Input Input Relay contacts
optocupler optocupler input
analog input on RB0 on RA4 voltage
PROCESSOR 16f84
#include "p16f84.inc"
movwf PCL
; Display messages
LCD_DDAdr .3
Loop
LTC86 LO, HI, Count
; Display AD result
call Out ; on LCD display
Out
LCDline 2 ; Second line
LCDval_16
return
;**************************************************************************
;
; 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
;
;**************************************************************************
movlw .4
movwf Var ; Counter initialization
INC LTC1286.INC
call CLK
movlw .8
movwf Var ; Counter initialization
call CLK
endm
CLK
bsf Clock ; Make one clock
nop
nop
nop
bcf Clock
return
LCDval_16 macro
call LCDval16
endm
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
movfw TEMP2
subwf LO_TEMP,0
skpc
goto LCDval2
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ΚΩ
RD4=330Ω
RD3=330Ω
RD2=330Ω
RD1=330Ω
Jumpers setting
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
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
Notes: When 7-seg displays are not used resistors R15 and R16 should be removed
ASM 7-SEG.ASM
PROCESSOR 16f84
#include "p16f84.inc"
;**************************************************************************
;
; 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
;
;**************************************************************************
LED_Init macro
call InitPorts
call InitTimers
endm
InitPorts
BANK1
clrf LEDtrisA ; Pins RA0-4 are output
clrf LEDtrisB ; Port B is output
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
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 ; /
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........
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
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
ASM: HC595.ASM
PROCESSOR 16f84
#include "p16f84.inc"
BANK1
movlw 0x18 ; Port A initialization
movwf TRISA ; TRISA <- 0x18
BANK0
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
;
;**************************************************************************
+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
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
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
12V-
N/C N/O
Input
optocupler
Input
optocupler
Relay input Switching contacts
on RB0 on RA4 voltage of relay
ASM RELAY.ASM
PROCESSOR 16f84
#include "p16f84.inc"
On
bsf RELAY ; Turn on relay
return
Off
bcf RELAY ; Turn off relay
return
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Ω
12V-
N/C N/O
Switching
Input Input Relay contacts
optocupler optocupler input
on RB0 on RA4 voltage
Input on Cn6
ASM TMR0.ASM
PROCESSOR 16f84
#include "p16f84.inc"
Loop
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
CNY17
Jumpers setting
RB0
If JP5 is closed input
JP5 optocoupler is connected
on RB0 pin
+5V 10ΚΩ
CNY17
330Ω
12V-
N/C N/O
Switching
Input Input Relay contacts
optocupler optocupler input
on RB0 on RA4 voltage
ASM INT0.ASM
PROCESSOR 16f84
#include "p16f84.inc"
ISR
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.
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.