You are on page 1of 74

LED Flasher

This flasher moves, while lighting of LED drags on.


The brightness of LED is four kinds, bright, less bright, almost dim and dim. These lighting states are
moved with time.
Control of brightness is performed in lighting time of LED like PWM(Pulse Width Modulation).
There is no PWM function in PIC16F84A. Therefore, I divided lighting of LED into four cycles, and
controlled them. It is "Bright" when all periodic lightings are carried out. 2 cycle lighting state is
"Less bright". 1 cycle lighting state is "almost dim". It is "Dim" in OFF a total cycle.
At first, I was going to prepare much more cycles. However, because PIC16F84A carried only 1Kword program memory, I made into four cycles.

Patern 1
(Left)

Patern 0
(Center)

Patern 2
(Right)

Hardware
Circuit drawing
Pattern drawing
Circuit explanation
Parts explanation
Software
Flow chart
List
Processing explanation

Circuit drawing of LED flasher

Pattern drawing of LED flasher


(Wiring side)

Olive-green line shows the wiring at the component side.

Circuit explanation of LED flasher


Key-in circuit
In this circuit, three pins from RA0 to RA2 are used as key input.
The pull-up of each pin is carried out by the resistor of 10Kohm. By
this, when the switch is not pushed, the pin is held at H level (+5V).
It will be set to L level (0V) if a switch is pushed.
When a switch closes, the phenomenon of chattering occurs. This
phenomenon occurs with the point of contact bound when a switch
is closed. It is the phenomenon that the opening and closing of a
switch is repeated in short time. In this circuit, the condition of a
switch is detected with the software scanning. It is judged that the switch will be closed at the time of
scan if it is L level. By this software, an operating condition is held until other switches will be closed, if it
detects that a certain switch was closed. Therefore, the prevention circuit of chattering is not prepared.

LED control circuit


Eight pins of RB0 to RB7 are used as an LED control pin.
The anode side of LED is connected in +5V. Lighting of LED is
controlled by PIC via a resistor in the cathode side. Therefore, when
the output of PIC is H level(+5V), LED puts out the light and, in the
case of L level(0V), LED turns it on. The resistance for current
control of LED is calaculated as follows. The lighting
recommendation current of LED used this time is 20mA.
( Power supply voltage - LED lighting voltage(2V) ) / LED lighting
current
= ( 5V - 2V ) / 0.02A = 150 ohm
Because I had no 150 ohms resistor at hand, I used 220 ohms. In this case, the current of LED is ( 5V - 2V )
/ 220ohm =14mA.

Clock generator circuit


5

The timer function of PIC is used for the processing which moves
the lighting position of LED.
When man looks at the lighting situation of LED, it is not meaningful
if too quick. In this circuit, it is the purpose to show so that lighting
of LED may drag on.
In order to lengthen time of a timer, 4MHz resonator is used. The
period with 4MHz frequency is 1/4,000,000 = 0.25 microseconds.
Because 4 periods (the clock) are necessary to the count of the
timer, a count is downed with the timer every microsecond. Because a prescaler of 1/256 is used for the
input of timer, actually, a count is downed with every 256 microseconds. When making the initial value
of the timer as 195, the time-out becomes 256sec/count x 195count = 49920sec = 50msec.

Power supply circuit


A 3 terminal regulator is used to get +5V power from the +12V. I
used a 1 A-type regulator(7805).
In the software this time, two "bright", two "less bright" and two
"almost dim" as the LED which light up at the same time. It is about
60mA even if it supposes that four LEDs light up at the same time. It
is less than 100 mA even if it adds the consumption of PIC. In case of
it, 100 mA type regulator(78L05) can be used.

Parts explanation of LED flasher


6

PIC16F84A

Voltage regulator (7805)

PIC16F84A is used in this circuit. In PIC16F84A, the


oscillator upto 20MHz can be used. It is made to
operate by 4MHz in the case of the software
currently introduced here.

Light Emitting Diode

This device is
used in order
to get the
voltage of
stable +5V.
1A type is
used.
When there is
little LED made
to turn on
simultaneously, 100mA type 78L05
can be used.
Data sheet for 7805

Resonator

The high luminosity type


red LED with a diameter of
10mm is used.
A part number is
unknown.
Recommendation lighting
current is 20mA.

This device is
a ceramic
oscillation
element for
the clock
oscillation of
PIC. Because
the
capacitors for an oscillation are built
in, wiring can also attain simplification.
Oscillation frequency is 4MHz.

Switch

IC socket

These switches are used in


order to choose the
lighting pattern of LED.
These are non lock type
small switches.

Multilayer ceramic capacitor

This is a
socket for
mounting
PIC16F84A
on a printed
circuit board.
It is more
convenient
to use a socket, because the software
of PIC may be rewritten.

Resistor

These capacitors are


used for oscillation
prevention of 3 terminal
regulator.
Even if it does not
attach, there is usually
no problem.
However, to attach as foundations is safer.

Printed board

In this
circuit,
there is no
circuit
through
which big
current
flows.
Therefore, the resistor of 1/8W type is
used altogether.

Wiring terminal

The pin
type
terminal is
used as a
power
supply
input

terminal.

The universal printed circuit board with 24 x 30


holes is used.

Stud

The metal studs are used


as the leg. There is no
metal necessity.

Software flow chart of LED flasher (1/2)

10

Software flow chart of LED flasher (2/2)

11

Source code file for LED flasher


0001 ;********************************************************
0002 ;
0003 ;

LED flash control 2

0004 ;
0005 ;

Device : PIC16F84A

0006 ;

Clock : 4MHz

0007 ;

Author : Seiichi Inoue

0008 ;********************************************************
0009
0010

list

p=pic16f84a

0011

include

0012

__config _hs_osc & _wdt_off & _pwrte_on & _cp_off

0013

errorlevel

p16f84a.inc

-302 ;Eliminate bank warning

0014
0015 ;**************** Label Definition ********************
0016

cblock h'0c'

0017 loop_cnt

;Loop counter for LED cnt

0018 led_data0

;LED data 0

0019 led_data1

;LED data 1

0020 led01

;LED 01 pattern

0021 led10

;LED 10 pattern

0022 led11

;LED 11 pattern

0023 port_work

;LED data save area

12

0024 counter

;Software timer counter

0025 ptn_save

;Pattern number save area

0026 ptn_counter

;Pattern counter

0027 w_save

;W register save area

0028 s_save

;STATUS regi save area

0029

endc

0030
0031 ra0

equ

00

;RA0 bit

0032 ra1

equ

01

;RA1 bit

0033 ra2

equ

02

;RA2 bit

0034
0035 ;**************** Speed control data ********************
0036 speed equ

;100ms (+1=50ms)

0037
0038 ;************* Brightness control data ****************
0039 led1 equ

b'11111110'

;(01) almost dim

0040 led2 equ

b'11111010'

;(10) less bright

0041 led3 equ

b'11110000'

;(11) bright

0042
0043 ;************* Pattern Data Definition ****************
0044 ; 1 bright 1 less bright 0 almost dim 0 dim
0045 ; 1

0046
0047 ;****** Pattern 0 ******
0048 p000 equ

b'00000000'

0049 p001 equ

b'00000000'

0050
0051 p010 equ

b'10000001'

13

0052 p011 equ

b'10000001'

0053
0054 p020 equ

b'11000011'

0055 p021 equ

b'01000010'

0056
0057 p030 equ

b'01100110'

0058 p031 equ

b'10100101'

0059
0060 p040 equ

b'00111100'

0061 p041 equ

b'01011010'

0062
0063 p050 equ

b'00011000'

0064 p051 equ

b'00111100'

0065
0066 p060 equ

b'00111100'

0067 p061 equ

b'00100100'

0068
0069 p070 equ

b'01100110'

0070 p071 equ

b'01011010'

0071
0072 p080 equ

b'11000011'

0073 p081 equ

b'10100101'

0074
0075 p090 equ

b'10000001'

0076 p091 equ

b'01000010'

0077
0078 p0a0 equ

b'00000000'

0079 p0a1 equ

b'10000001'

14

0080
0081 ;****** Pattern 1 ******
0082 p100 equ

b'00000000'

0083 p101 equ

b'00000000'

0084
0085 p110 equ

b'00000001'

0086 p111 equ

b'00000001'

0087
0088 p120 equ

b'00000011'

0089 p121 equ

b'00000010'

0090
0091 p130 equ

b'00000110'

0092 p131 equ

b'00000101'

0093
0094 p140 equ

b'00001100'

0095 p141 equ

b'00001010'

0096
0097 p150 equ

b'00011000'

0098 p151 equ

b'00010100'

0099
0100 p160 equ

b'00110000'

0101 p161 equ

b'00101000'

0102
0103 p170 equ

b'01100000'

0104 p171 equ

b'01010000'

0105
0106 p180 equ

b'11000000'

0107 p181 equ

b'10100000'

15

0108
0109 p190 equ

b'10000000'

0110 p191 equ

b'01000000'

0111
0112 p1a0 equ

b'00000000'

0113 p1a1 equ

b'10000000'

0114
0115 ;****** Pattern 2 ******
0116 p200 equ

b'00000000'

0117 p201 equ

b'00000000'

0118
0119 p210 equ

b'10000000'

0120 p211 equ

b'10000000'

0121
0122 p220 equ

b'11000000'

0123 p221 equ

b'01000000'

0124
0125 p230 equ

b'01100000'

0126 p231 equ

b'10100000'

0127
0128 p240 equ

b'00110000'

0129 p241 equ

b'01010000'

0130
0131 p250 equ

b'00011000'

0132 p251 equ

b'00101000'

0133
0134 p260 equ

b'00001100'

0135 p261 equ

b'00010100'

16

0136
0137 p270 equ

b'00000110'

0138 p271 equ

b'00001010'

0139
0140 p280 equ

b'00000011'

0141 p281 equ

b'00000101'

0142
0143 p290 equ

b'00000001'

0144 p291 equ

b'00000010'

0145
0146 p2a0 equ

b'00000000'

0147 p2a1 equ

b'00000001'

0148
0149 ;**************** Program Start ***********************
0150

org

0151

goto init

0152

org

0153

goto int

;Reset Vector

;Interrupt Vector

0154
0155 ;****************** Initial Process *******************
0156 init
0157 ;*** Set Port mode
0158

bsf

status,rp0

;Change to Bank1

0159

movlw b'00000111'

0160

movwf trisa

0161

movlw b'00000000'

0162

movwf trisb

;RA2-0:IN mode

;Set TRISA reg


;RB7-0:OUT mode

;Set TRISB reg

0163

17

0164 ;*** Set Option reg


0165

movlw b'10000111'

;RBPU=OFF,PSA=0,PS=1:256

0166

movwf option_reg

;Set OPTION_REG

0167

bcf

status,rp0

;Change to Bank0

0168
0169 ;*** Set work area
0170

clrf led_data0

;Clear LED data0

0171

clrf led_data1

;Clear LED data1

0172

movlw led1

;Read 01 pattern

0173

movwf led01

;Set 01 pattern

0174

movlw led2

;Read 10 pattern

0175

movwf led10

;Set 10 pattern

0176

movlw led3

;Read 11 pattern

0177

movwf led11

;Set 11 pattern

0178

clrf port_work

;Clear LED data save area

0179

movlw speed

;Read speed data

0180

addlw d'1'

0181

movwf counter

0182

movlw d'1'

0183

movwf ptn_save

0184

clrf ptn_counter

;+1 addition
;Set counter
;Set pattern data
;Set pattern 0
;Clear pattern counter

0185
0186 ;*** Set TMR0 reg
0187

movlw d'61'

;256-50ms/0.256ms = 61

0188

movwf tmr0

0189

movlw b'10100000'

0190

movwf intcon

;Set 50msec to TMR0


;GIE=1,TOIE=1

;Interruption enable

0191

18

0192 ;**************** LED control Process ******************


0193 loop
0194

movlw d'4'

0195

movwf loop_cnt

;Set loop counter data


;Set loop counter

0196 loop1
0197

movlw d'1'

;Set check data

0198

subwf loop_cnt,w

0199

btfss status,z

;Counter = 1 ?

0200

goto next2

;No.

0201

goto process4

;Check exec times

;Jump to Process4

0202 next2
0203

movlw d'2'

;Set check data

0204

subwf loop_cnt,w

0205

btfss status,z

;Counter = 2 ?

0206

goto next3

;No.

0207

goto process3

;Check exec times

;Jump to Process3

0208 next3
0209

movlw d'3'

;Set check data

0210

subwf loop_cnt,w

0211

btfss status,z

;Counter = 3 ?

0212

goto next4

;No.

0213

goto process2

;Check exec times

;Jump to Process2

0214 next4
0215

movlw d'4'

;Set check data

0216

subwf loop_cnt,w

0217

btfss status,z

;Counter = 4 ?

0218

goto loop

;No. illegal

0219

goto process1

;Check exec times

;Jump to Process1

19

0220
0221 led_cont
0222

movfw port_work

;Read PORT WORK data

0223

movwf portb

;Set PORTB

0225

decfsz loop_cnt,f

;Count down

0226

goto loop1

;Next Process

0227

goto loop

;Next Period

0224 next

0228
0229 process1
0230 ;****************** bit0 for process1 *******************
0231

btfss led_data0,0

;1x ?

0232

goto p10_0x

0233

btfss led_data1,0

0234

goto p10_10

;Jump to 10 process

0235

goto p10_11

;Jump to 11 process

;No.
;11 ?

0236 p10_0x
0237

btfsc led_data1,0

0238

goto p10_01

;01 ?
;Jump to 01 process

0239
0240 p10_00
0241

goto p10_set

;LED off

0242
0243 p10_01
0244

btfss led01,0

0245

goto p10_clear

0246

goto p10_set

;Data = 1 ?
;No.
;Yes.

0247

20

0248 p10_10
0249

btfss led10,0

0250

goto p10_clear

0251

goto p10_set

;Data = 1 ?
;No.
;Yes.

0252
0253 p10_11
0254

btfss led11,0

0255

goto p10_clear

;Data = 1 ?
;No.

0256
0257 p10_set
0258

bsf

port_work,0

;Set bit0

0259

goto bit1_process1

0260 p10_clear
0261

bcf

port_work,0

;Clear bit0

0262
0263 bit1_process1
0264 ;****************** bit1 for process1 *******************
0265

btfss led_data0,1

;1x ?

0266

goto p11_0x

0267

btfss led_data1,1

0268

goto p11_10

;Jump to 10 process

0269

goto p11_11

;Jump to 11 process

;No.
;11 ?

0270 p11_0x
0271

btfsc led_data1,1

0272

goto p11_01

;01 ?
;Jump to 01 process

0273
0274 p11_00
0275

goto p11_set

;LED off

21

0276
0277 p11_01
0278

btfss led01,0

0279

goto p11_clear

0280

goto p11_set

;Data = 1 ?
;No.
;Yes.

0281
0282 p11_10
0283

btfss led10,0

0284

goto p11_clear

0285

goto p11_set

;Data = 1 ?
;No.
;Yes.

0286
0287 p11_11
0288

btfss led11,0

0289

goto p11_clear

;Data = 1 ?
;No.

0290
0291 p11_set
0292

bsf

port_work,1

;Set bit1

0293

goto bit2_process1

0294 p11_clear
0295

bcf

port_work,1

;Clear bit1

0296
0297 bit2_process1
0298 ;****************** bit2 for process1 *******************
0299

btfss led_data0,2

;1x ?

0300

goto p12_0x

0301

btfss led_data1,2

0302

goto p12_10

;Jump to 10 process

0303

goto p12_11

;Jump to 11 process

;No.
;11 ?

22

0304 p12_0x
0305

btfsc led_data1,2

0306

goto p12_01

;01 ?
;Jump to 01 process

0307
0308 p12_00
0309

goto p12_set

;LED off

0310
0311 p12_01
0312

btfss led01,0

0313

goto p12_clear

0314

goto p12_set

;Data = 1 ?
;No.
;Yes.

0315
0316 p12_10
0317

btfss led10,0

0318

goto p12_clear

0319

goto p12_set

;Data = 1 ?
;No.
;Yes.

0320
0321 p12_11
0322

btfss led11,0

0323

goto p12_clear

;Data = 1 ?
;No.

0324
0325 p12_set
0326

bsf

port_work,2

0327

goto bit3_process1

;Set bit2

0328 p12_clear
0329

bcf

port_work,2

;Clear bit2

0330
0331 bit3_process1

23

0332 ;****************** bit3 for process1 *******************


0333

btfss led_data0,3

;1x ?

0334

goto p13_0x

0335

btfss led_data1,3

0336

goto p13_10

;Jump to 10 process

0337

goto p13_11

;Jump to 11 process

;No.
;11 ?

0338 p13_0x
0339

btfsc led_data1,3

0340

goto p13_01

;01 ?
;Jump to 01 process

0341
0342 p13_00
0343

goto p13_set

;LED off

0344
0345 p13_01
0346

btfss led01,0

0347

goto p13_clear

0348

goto p13_set

;Data = 1 ?
;No.
;Yes.

0349
0350 p13_10
0351

btfss led10,0

0352

goto p13_clear

0353

goto p13_set

;Data = 1 ?
;No.
;Yes.

0354
0355 p13_11
0356

btfss led11,0

0357

goto p13_clear

;Data = 1 ?
;No.

0358
0359 p13_set

24

0360

bsf

port_work,3

;Set bit3

0361

goto bit4_process1

0362 p13_clear
0363

bcf

port_work,3

;Clear bit3

0364
0365 bit4_process1
0366 ;****************** bit4 for process1 *******************
0367

btfss led_data0,4

;1x ?

0368

goto p14_0x

0369

btfss led_data1,4

0370

goto p14_10

;Jump to 10 process

0371

goto p14_11

;Jump to 11 process

;No.
;11 ?

0372 p14_0x
0373

btfsc led_data1,4

0374

goto p14_01

;01 ?
;Jump to 01 process

0375
0376 p14_00
0377

goto p14_set

;LED off

0378
0379 p14_01
0380

btfss led01,0

0381

goto p14_clear

0382

goto p14_set

;Data = 1 ?
;No.
;Yes.

0383
0384 p14_10
0385

btfss led10,0

0386

goto p14_clear

0387

goto p14_set

;Data = 1 ?
;No.
;Yes.

25

0388
0389 p14_11
0390

btfss led11,0

0391

goto p14_clear

;Data = 1 ?
;No.

0392
0393 p14_set
0394

bsf

port_work,4

;Set bit4

0395

goto bit5_process1

0396 p14_clear
0397

bcf

port_work,4

;Clear bit4

0398
0399 bit5_process1
0400 ;****************** bit5 for process1 *******************
0401

btfss led_data0,5

;1x ?

0402

goto p15_0x

0403

btfss led_data1,5

0404

goto p15_10

;Jump to 10 process

0405

goto p15_11

;Jump to 11 process

;No.
;11 ?

0406 p15_0x
0407

btfsc led_data1,5

0408

goto p15_01

;01 ?
;Jump to 01 process

0409
0410 p15_00
0411

goto p15_set

;LED off

0412
0413 p15_01
0414

btfss led01,0

0415

goto p15_clear

;Data = 1 ?
;No.

26

0416

goto p15_set

;Yes.

0417
0418 p15_10
0419

btfss led10,0

0420

goto p15_clear

0421

goto p15_set

;Data = 1 ?
;No.
;Yes.

0422
0423 p15_11
0424

btfss led11,0

0425

goto p15_clear

;Data = 1 ?
;No.

0426
0427 p15_set
0428

bsf

port_work,5

;Set bit5

0429

goto bit6_process1

0430 p15_clear
0431

bcf

port_work,5

;Clear bit5

0432
0433 bit6_process1
0434 ;****************** bit6 for process1 *******************
0435

btfss led_data0,6

;1x ?

0436

goto p16_0x

0437

btfss led_data1,6

0438

goto p16_10

;Jump to 10 process

0439

goto p16_11

;Jump to 11 process

;No.
;11 ?

0440 p16_0x
0441

btfsc led_data1,6

0442

goto p16_01

;01 ?
;Jump to 01 process

0443

27

0444 p16_00
0445

goto p16_set

;LED off

0446
0447 p16_01
0448

btfss led01,0

0449

goto p16_clear

0450

goto p16_set

;Data = 1 ?
;No.
;Yes.

0451
0452 p16_10
0453

btfss led10,0

0454

goto p16_clear

0455

goto p16_set

;Data = 1 ?
;No.
;Yes.

0456
0457 p16_11
0458

btfss led11,0

0459

goto p16_clear

;Data = 1 ?
;No.

0460
0461 p16_set
0462

bsf

port_work,6

;Set bit6

0463

goto bit7_process1

0464 p16_clear
0465

bcf

port_work,6

;Clear bit6

0466
0467 bit7_process1
0468 ;****************** bit7 for process1 *******************
0469

btfss led_data0,7

0470

goto p17_0x

0471

btfss led_data1,7

;1x ?
;No.
;11 ?

28

0472

goto p17_10

;Jump to 10 process

0473

goto p17_11

;Jump to 11 process

0474 p17_0x
0475

btfsc led_data1,7

0476

goto p17_01

;01 ?
;Jump to 01 process

0477
0478 p17_00
0479

goto p7_set

;LED off

0480
0481 p17_01
0482

btfss led01,0

0483

goto p7_clear

0484

goto p7_set

;Data = 1 ?
;No.
;Yes.

0485
0486 p17_10
0487

btfss led10,0

;Data = 1 ?

0488

goto p7_clear

;No.

0489

goto p7_set

;Yes.

0490
0491 p17_11
0492

btfss led11,0

0493

goto p7_clear

0494

goto p7_set

;Data = 1 ?
;No.
;Yes.

0495
0496 process2
0497 ;****************** bit0 for process2 *******************
0498

btfss led_data0,0

0499

goto p20_0x

;1x ?
;No.

29

0500

btfss led_data1,0

;11 ?

0501

goto p20_10

;Jump to 10 process

0502

goto p20_11

;Jump to 11 process

0503 p20_0x
0504

btfsc led_data1,0

0505

goto p20_01

;01 ?
;Jump to 01 process

0506
0507 p20_00
0508

goto p20_set

;LED off

0509
0510 p20_01
0511

btfss led01,1

0512

goto p20_clear

0513

goto p20_set

;Data = 1 ?
;No.
;Yes.

0514
0515 p20_10
0516

btfss led10,1

0517

goto p20_clear

0518

goto p20_set

;Data = 1 ?
;No.
;Yes.

0519
0520 p20_11
0521

btfss led11,1

0522

goto p20_clear

;Data = 1 ?
;No.

0523
0524 p20_set
0525

bsf

port_work,0

0526

goto bit1_process2

;Set bit0

0527 p20_clear

30

0528

bcf

port_work,0

;Clear bit0

0529
0530 bit1_process2
0531 ;****************** bit1 for process2 *******************
0532

btfss led_data0,1

;1x ?

0533

goto p21_0x

0534

btfss led_data1,1

0535

goto p21_10

;Jump to 10 process

0536

goto p21_11

;Jump to 11 process

;No.
;11 ?

0537 p21_0x
0538

btfsc led_data1,1

0539

goto p21_01

;01 ?
;Jump to 01 process

0540
0541 p21_00
0542

goto p21_set

;LED off

0543
0544 p21_01
0545

btfss led01,1

0546

goto p21_clear

0547

goto p21_set

;Data = 1 ?
;No.
;Yes.

0548
0549 p21_10
0550

btfss led10,1

0551

goto p21_clear

0552

goto p21_set

;Data = 1 ?
;No.
;Yes.

0553
0554 p21_11
0555

btfss led11,1

;Data = 1 ?

31

0556

goto p21_clear

;No.

0557
0558 p21_set
0559

bsf

port_work,1

;Set bit1

0560

goto bit2_process2

0561 p21_clear
0562

bcf

port_work,1

;Clear bit1

0563
0564 bit2_process2
0565 ;****************** bit2 for process2 *******************
0566

btfss led_data0,2

;1x ?

0567

goto p22_0x

0568

btfss led_data1,2

0569

goto p22_10

;Jump to 10 process

0570

goto p22_11

;Jump to 11 process

;No.
;11 ?

0571 p22_0x
0572

btfsc led_data1,2

0573

goto p22_01

;01 ?
;Jump to 01 process

0574
0575 p22_00
0576

goto p22_set

;LED off

0577
0578 p22_01
0579

btfss led01,1

0580

goto p22_clear

0581

goto p22_set

;Data = 1 ?
;No.
;Yes.

0582
0583 p22_10

32

0584

btfss led10,1

0585

goto p22_clear

0586

goto p22_set

;Data = 1 ?
;No.
;Yes.

0587
0588 p22_11
0589

btfss led11,1

0590

goto p22_clear

;Data = 1 ?
;No.

0591
0592 p22_set
0593

bsf

port_work,2

;Set bit2

0594

goto bit3_process2

0595 p22_clear
0596

bcf

port_work,2

;Clear bit2

0597
0598 bit3_process2
0599 ;****************** bit3 for process2 *******************
0600

btfss led_data0,3

;1x ?

0601

goto p23_0x

0602

btfss led_data1,3

0603

goto p23_10

;Jump to 10 process

0604

goto p23_11

;Jump to 11 process

;No.
;11 ?

0605 p23_0x
0606

btfsc led_data1,3

0607

goto p23_01

;01 ?
;Jump to 01 process

0608
0609 p23_00
0610

goto p23_set

;LED off

0611

33

0612 p23_01
0613

btfss led01,1

0614

goto p23_clear

0615

goto p23_set

;Data = 1 ?
;No.
;Yes.

0616
0617 p23_10
0618

btfss led10,1

0619

goto p23_clear

0620

goto p23_set

;Data = 1 ?
;No.
;Yes.

0621
0622 p23_11
0623

btfss led11,1

0624

goto p23_clear

;Data = 1 ?
;No.

0625
0626 p23_set
0627

bsf

port_work,3

;Set bit3

0628

goto bit4_process2

0629 p23_clear
0630

bcf

port_work,3

;Clear bit3

0631
0632 bit4_process2
0633 ;****************** bit4 for process2 *******************
0634

btfss led_data0,4

;1x ?

0635

goto p24_0x

0636

btfss led_data1,4

0637

goto p24_10

;Jump to 10 process

0638

goto p24_11

;Jump to 11 process

;No.
;11 ?

0639 p24_0x

34

0640

btfsc led_data1,4

0641

goto p24_01

;01 ?
;Jump to 01 process

0642
0643 p24_00
0644

goto p24_set

;LED off

0645
0646 p24_01
0647

btfss led01,1

0648

goto p24_clear

0649

goto p24_set

;Data = 1 ?
;No.
;Yes.

0650
0651 p24_10
0652

btfss led10,1

0653

goto p24_clear

0654

goto p24_set

;Data = 1 ?
;No.
;Yes.

0655
0656 p24_11
0657

btfss led11,1

0658

goto p24_clear

;Data = 1 ?
;No.

0659
0660 p24_set
0661

bsf

port_work,4

0662

goto bit5_process2

;Set bit4

0663 p24_clear
0664

bcf

port_work,4

;Clear bit4

0665
0666 bit5_process2
0667 ;****************** bit5 for process2 *******************

35

0668

btfss led_data0,5

;1x ?

0669

goto p25_0x

0670

btfss led_data1,5

0671

goto p25_10

;Jump to 10 process

0672

goto p25_11

;Jump to 11 process

;No.
;11 ?

0673 p25_0x
0674

btfsc led_data1,5

0675

goto p25_01

;01 ?
;Jump to 01 process

0676
0677 p25_00
0678

goto p25_set

;LED off

0679
0680 p25_01
0681

btfss led01,1

;Data = 1 ?

0682

goto p25_clear

;No.

0683

goto p25_set

;Yes.

0684
0685 p25_10
0686

btfss led10,1

0687

goto p25_clear

0688

goto p25_set

;Data = 1 ?
;No.
;Yes.

0689
0690 p25_11
0691

btfss led11,1

0692

goto p25_clear

;Data = 1 ?
;No.

0693
0694 p25_set
0695

bsf

port_work,5

;Set bit5

36

0696

goto bit6_process2

0697 p25_clear
0698

bcf

port_work,5

;Clear bit5

0699
0700 bit6_process2
0701 ;****************** bit6 for process2 *******************
0702

btfss led_data0,6

;1x ?

0703

goto p26_0x

0704

btfss led_data1,6

0705

goto p26_10

;Jump to 10 process

0706

goto p26_11

;Jump to 11 process

;No.
;11 ?

0707 p26_0x
0708

btfsc led_data1,6

0709

goto p26_01

;01 ?
;Jump to 01 process

0710
0711 p26_00
0712

goto p26_set

;LED off

0713 p26_01
0714

btfss led01,1

0715

goto p26_clear

0716

goto p26_set

;Data = 1 ?
;No.
;Yes.

0717
0718 p26_10
0719

btfss led10,1

0720

goto p26_clear

0721

goto p26_set

;Data = 1 ?
;No.
;Yes.

0722
0723 p26_11

37

0724

btfss led11,1

0725

goto p26_clear

;Data = 1 ?
;No.

0726
0727 p26_set
0728

bsf

port_work,6

;Set bit6

0729

goto bit7_process2

0730 p26_clear
0731

bcf

port_work,6

;Clear bit6

0732
0733 bit7_process2
0734 ;****************** bit7 for process2 *******************
0735

btfss led_data0,7

;1x ?

0736

goto p27_0x

0737

btfss led_data1,7

0738

goto p27_10

;Jump to 10 process

0739

goto p27_11

;Jump to 11 process

;No.
;11 ?

0740 p27_0x
0741

btfsc led_data1,7

0742

goto p27_01

;01 ?
;Jump to 01 process

0743
0744 p27_00
0745

goto p7_set

;LED off

0746
0747 p27_01
0748

btfss led01,1

0749

goto p7_clear

0750

goto p7_set

;Data = 1 ?
;No.
;Yes.

0751

38

0752 p27_10
0753

btfss led10,1

0754

goto p7_clear

0755

goto p7_set

;Data = 1 ?
;No.
;Yes.

0756
0757 p27_11
0758

btfss led11,1

0759

goto p7_clear

0760

goto p7_set

;Data = 1 ?
;No.
;Yes.

0761
0762 process3
0763 ;****************** bit0 for process3 *******************
0764

btfss led_data0,0

;1x ?

0765

goto p30_0x

0766

btfss led_data1,0

0767

goto p30_10

;Jump to 10 process

0768

goto p30_11

;Jump to 11 process

;No.
;11 ?

0769 p30_0x
0770

btfsc led_data1,0

0771

goto p30_01

;01 ?
;Jump to 01 process

0772
0773 p30_00
0774

goto p30_set

;LED off

0775
0776 p30_01
0777

btfss led01,2

0778

goto p30_clear

0779

goto p30_set

;Data = 1 ?
;No.
;Yes.

39

0780
0781 p30_10
0782

btfss led10,2

0783

goto p30_clear

0784

goto p30_set

;Data = 1 ?
;No.
;Yes.

0785
0786 p30_11
0787

btfss led11,2

0788

goto p30_clear

;Data = 1 ?
;No.

0789
0790 p30_set
0791

bsf

port_work,0

;Set bit0

0792

goto bit1_process3

0793 p30_clear
0794

bcf

port_work,0

;Clear bit0

0795
0796 bit1_process3
0797 ;****************** bit1 for process3 *******************
0798

btfss led_data0,1

;1x ?

0799

goto p31_0x

0800

btfss led_data1,1

0801

goto p31_10

;Jump to 10 process

0802

goto p31_11

;Jump to 11 process

;No.
;11 ?

0803 p31_0x
0804

btfsc led_data1,1

0805

goto p31_01

;01 ?
;Jump to 01 process

0806
0807 p31_00

40

0808

goto p31_set

;LED off

0809
0810 p31_01
0811

btfss led01,2

0812

goto p31_clear

0813

goto p31_set

;Data = 1 ?
;No.
;Yes.

0814
0815 p31_10
0816

btfss led10,2

0817

goto p31_clear

0818

goto p31_set

;Data = 1 ?
;No.
;Yes.

0819
0820 p31_11
0821

btfss led11,2

0822

goto p31_clear

;Data = 1 ?
;No.

0823
0824 p31_set
0825

bsf

port_work,1

;Set bit1

0826

goto bit2_process3

0827 p31_clear
0828

bcf

port_work,1

;Clear bit1

0829
0830 bit2_process3
0831 ;****************** bit2 for process3 *******************
0832

btfss led_data0,2

0833

goto p32_0x

0834

btfss led_data1,2

0835

goto p32_10

;1x ?
;No.
;11 ?
;Jump to 10 process

41

0836

goto p32_11

;Jump to 11 process

0837 p32_0x
0838

btfsc led_data1,2

0839

goto p32_01

;01 ?
;Jump to 01 process

0840
0841 p32_00
0842

goto p32_set

;LED off

0843
0844 p32_01
0845

btfss led01,2

0846

goto p32_clear

0847

goto p32_set

;Data = 1 ?
;No.
;Yes.

0848
0849 p32_10
0850

btfss led10,2

0851

goto p32_clear

0852

goto p32_set

;Data = 1 ?
;No.
;Yes.

0853
0854 p32_11
0855

btfss led11,2

0856

goto p32_clear

;Data = 1 ?
;No.

0857
0858 p32_set
0859

bsf

port_work,2

0860

goto bit3_process3

;Set bit2

0861 p32_clear
0862

bcf

port_work,2

;Clear bit2

0863

42

0864 bit3_process3
0865 ;****************** bit3 for process3 *******************
0866

btfss led_data0,3

;1x ?

0867

goto p33_0x

0868

btfss led_data1,3

0869

goto p33_10

;Jump to 10 process

0870

goto p33_11

;Jump to 11 process

;No.
;11 ?

0871 p33_0x
0872

btfsc led_data1,3

0873

goto p33_01

;01 ?
;Jump to 01 process

0874
0875 p33_00
0876

goto p33_set

;LED off

0877
0878 p33_01
0879

btfss led01,2

0880

goto p33_clear

0881

goto p33_set

;Data = 1 ?
;No.
;Yes.

0882
0883 p33_10
0884

btfss led10,2

0885

goto p33_clear

0886

goto p33_set

;Data = 1 ?
;No.
;Yes.

0887
0888 p33_11
0889

btfss led11,2

0890

goto p33_clear

;Data = 1 ?
;No.

0891

43

0892 p33_set
0893

bsf

port_work,3

;Set bit3

0894

goto bit4_process3

0895 p33_clear
0896

bcf

port_work,3

;Clear bit3

0897
0898 bit4_process3
0899 ;****************** bit4 for process3 *******************
0900

btfss led_data0,4

;1x ?

0901

goto p34_0x

0902

btfss led_data1,4

0903

goto p34_10

;Jump to 10 process

0904

goto p34_11

;Jump to 11 process

;No.
;11 ?

0905 p34_0x
0906

btfsc led_data1,4

0907

goto p34_01

;01 ?
;Jump to 01 process

0908
0909 p34_00
0910

goto p34_set

;LED off

0911
0912 p34_01
0913

btfss led01,2

0914

goto p34_clear

0915

goto p34_set

;Data = 1 ?
;No.
;Yes.

0916
0917 p34_10
0918

btfss led10,2

0919

goto p34_clear

;Data = 1 ?
;No.

44

0920

goto p34_set

;Yes.

0921
0922 p34_11
0923

btfss led11,2

0924

goto p34_clear

;Data = 1 ?
;No.

0925
0926 p34_set
0927

bsf

port_work,4

;Set bit4

0928

goto bit5_process3

0929 p34_clear
0930

bcf

port_work,4

;Clear bit4

0931
0932 bit5_process3
0933 ;****************** bit5 for process3 *******************
0934

btfss led_data0,5

;1x ?

0935

goto p35_0x

0936

btfss led_data1,5

0937

goto p35_10

;Jump to 10 process

0938

goto p35_11

;Jump to 11 process

;No.
;11 ?

0939 p35_0x
0940

btfsc led_data1,5

0941

goto p35_01

;01 ?
;Jump to 01 process

0942
0943 p35_00
0944

goto p35_set

;LED off

0945
0946 p35_01
0947

btfss led01,2

;Data = 1 ?

45

0948

goto p35_clear

0949

goto p35_set

;No.
;Yes.

0950
0951 p35_10
0952

btfss led10,2

0953

goto p35_clear

0954

goto p35_set

;Data = 1 ?
;No.
;Yes.

0955
0956 p35_11
0957

btfss led11,2

0958

goto p35_clear

;Data = 1 ?
;No.

0959
0960 p35_set
0961

bsf

port_work,5

;Set bit5

0962

goto bit6_process3

0963 p35_clear
0964

bcf

port_work,5

;Clear bit5

0965
0966 bit6_process3
0967 ;****************** bit6 for process3 *******************
0968

btfss led_data0,6

;1x ?

0969

goto p36_0x

0970

btfss led_data1,6

0971

goto p36_10

;Jump to 10 process

0972

goto p36_11

;Jump to 11 process

;No.
;11 ?

0973 p36_0x
0974

btfsc led_data1,6

0975

goto p36_01

;01 ?
;Jump to 01 process

46

0976
0977 p36_00
0978

goto p36_set

;LED off

0979
0980 p36_01
0981

btfss led01,2

0982

goto p36_clear

0983

goto p36_set

;Data = 1 ?
;No.
;Yes.

0984
0985 p36_10
0986

btfss led10,2

0987

goto p36_clear

0988

goto p36_set

;Data = 1 ?
;No.
;Yes.

0989
0990 p36_11
0991

btfss led11,2

0992

goto p36_clear

;Data = 1 ?
;No.

0993
0994 p36_set
0995

bsf

port_work,6

;Set bit6

0996

goto bit7_process3

0997 p36_clear
0998

bcf

port_work,6

;Clear bit6

0999
1000 bit7_process3
1001 ;****************** bit7 for process3 *******************
1002

btfss led_data0,7

1003

goto p37_0x

;1x ?
;No.

47

1004

btfss led_data1,7

;11 ?

1005

goto p37_10

;Jump to 10 process

1006

goto p37_11

;Jump to 11 process

1007 p37_0x
1008

btfsc led_data1,7

1009

goto p37_01

;01 ?
;Jump to 01 process

1010
1011 p37_00
1012

goto p7_set

;LED off

1013 p37_01
1014

btfss led01,2

;Data = 1 ?

1015

goto p7_clear

;No.

1016

goto p7_set

;Yes.

1017
1018 p37_10
1019

btfss led10,2

1020

goto p7_clear

1021

goto p7_set

;Data = 1 ?
;No.
;Yes.

1022
1023 p37_11
1024

btfss led11,2

1025

goto p7_clear

1026

goto p7_set

;Data = 1 ?
;No.
;Yes.

1027
1028 process4
1029 ;****************** bit0 for process4 *******************
1030

btfss led_data0,0

1031

goto p40_0x

;1x ?
;No.

48

1032

btfss led_data1,0

;11 ?

1033

goto p40_10

;Jump to 10 process

1034

goto p40_11

;Jump to 11 process

1035 p40_0x
1036

btfsc led_data1,0

1037

goto p40_01

;01 ?
;Jump to 01 process

1038
1039 p40_00
1040

goto p40_set

;LED off

1041
1042 p40_01
1043

btfss led01,3

1044

goto p40_clear

1045

goto p40_set

;Data = 1 ?
;No.
;Yes.

1046
1047 p40_10
1048

btfss led10,3

1049

goto p40_clear

1050

goto p40_set

;Data = 1 ?
;No.
;Yes.

1051
1052 p40_11
1053

btfss led11,3

1054

goto p40_clear

;Data = 1 ?
;No.

1055
1056 p40_set
1057

bsf

port_work,0

1058

goto bit1_process4

;Set bit0

1059 p40_clear

49

1060

bcf

port_work,0

;Clear bit0

1061
1062 bit1_process4
1063 ;****************** bit1 for process4 *******************
1064

btfss led_data0,1

;1x ?

1065

goto p41_0x

1066

btfss led_data1,1

1067

goto p41_10

;Jump to 10 process

1068

goto p41_11

;Jump to 11 process

;No.
;11 ?

1069 p41_0x
1070

btfsc led_data1,1

1071

goto p41_01

;01 ?
;Jump to 01 process

1072
1073 p41_00
1074

goto p41_set

;LED off

1075
1076 p41_01
1077

btfss led01,3

1078

goto p41_clear

1079

goto p41_set

;Data = 1 ?
;No.
;Yes.

1080
1081 p41_10
1082

btfss led10,3

1083

goto p41_clear

1084

goto p41_set

;Data = 1 ?
;No.
;Yes.

1085
1086 p41_11
1087

btfss led11,3

;Data = 1 ?

50

1088

goto p41_clear

;No.

1089
1090 p41_set
1091

bsf

port_work,1

;Set bit1

1092

goto bit2_process4

1093 p41_clear
1094

bcf

port_work,1

;Clear bit1

1095
1096 bit2_process4
1097 ;****************** bit2 for process4 *******************
1098

btfss led_data0,2

;1x ?

1099

goto p42_0x

1100

btfss led_data1,2

1101

goto p42_10

;Jump to 10 process

1102

goto p42_11

;Jump to 11 process

;No.
;11 ?

1103 p42_0x
1104

btfsc led_data1,2

1105

goto p42_01

;01 ?
;Jump to 01 process

1106
1107 p42_00
1108

goto p42_set

;LED off

1109
1110 p42_01
1111

btfss led01,3

1112

goto p42_clear

1113

goto p42_set

;Data = 1 ?
;No.
;Yes.

1114
1115 p42_10

51

1116

btfss led10,3

1117

goto p42_clear

1118

goto p42_set

;Data = 1 ?
;No.
;Yes.

1119
1120 p42_11
1121

btfss led11,3

1122

goto p42_clear

;Data = 1 ?
;No.

1123
1124 p42_set
1125

bsf

port_work,2

;Set bit2

1126

goto bit3_process4

1127 p42_clear
1128

bcf

port_work,2

;Clear bit2

1129
1130 bit3_process4
1131 ;****************** bit3 for process4 *******************
1132

btfss led_data0,3

;1x ?

1133

goto p43_0x

1134

btfss led_data1,3

1135

goto p43_10

;Jump to 10 process

1136

goto p43_11

;Jump to 11 process

;No.
;11 ?

1137 p43_0x
1138

btfsc led_data1,3

1139

goto p43_01

;01 ?
;Jump to 01 process

1140
1141 p43_00
1142

goto p43_set

;LED off

1143

52

1144 p43_01
1145

btfss led01,3

1146

goto p43_clear

1147

goto p43_set

;Data = 1 ?
;No.
;Yes.

1148
1149 p43_10
1150

btfss led10,3

1151

goto p43_clear

1152

goto p43_set

;Data = 1 ?
;No.
;Yes.

1153
1154 p43_11
1155

btfss led11,3

1156

goto p43_clear

;Data = 1 ?
;No.

1157
1158 p43_set
1159

bsf

port_work,3

;Set bit3

1160

goto bit4_process4

1161 p43_clear
1162

bcf

port_work,3

;Clear bit3

1163
1164 bit4_process4
1165 ;****************** bit4 for process4 *******************
1166

btfss led_data0,4

;1x ?

1167

goto p44_0x

1168

btfss led_data1,4

1169

goto p44_10

;Jump to 10 process

1170

goto p44_11

;Jump to 11 process

;No.
;11 ?

1171 p44_0x

53

1172

btfsc led_data1,4

1173

goto p44_01

;01 ?
;Jump to 01 process

1174
1175 p44_00
1176

goto p44_set

;LED off

1177
1178 p44_01
1179

btfss led01,3

;Data = 1 ?

1180

goto p44_clear

;No.

1181

goto p44_set

;Yes.

1182
1183 p44_10
1184

btfss led10,3

1185

goto p44_clear

1186

goto p44_set

;Data = 1 ?
;No.
;Yes.

1187
1188 p44_11
1189

btfss led11,3

1190

goto p44_clear

;Data = 1 ?
;No.

1191
1192 p44_set
1193

bsf

port_work,4

1194

goto bit5_process4

;Set bit4

1195 p44_clear
1196

bcf

port_work,4

;Clear bit4

1197
1198 bit5_process4
1199 ;****************** bit5 for process4 *******************

54

1200

btfss led_data0,5

;1x ?

1201

goto p45_0x

1202

btfss led_data1,5

1203

goto p45_10

;Jump to 10 process

1204

goto p45_11

;Jump to 11 process

;No.
;11 ?

1205 p45_0x
1206

btfsc led_data1,5

1207

goto p45_01

;01 ?
;Jump to 01 process

1208
1209 p45_00
1210

goto p45_set

;LED off

1211
1212 p45_01
1213

btfss led01,3

1214

goto p45_clear

1215

goto p45_set

;Data = 1 ?
;No.
;Yes.

1216
1217 p45_10
1218

btfss led10,3

1219

goto p45_clear

1220

goto p45_set

;Data = 1 ?
;No.
;Yes.

1221
1222 p45_11
1223

btfss led11,3

1224

goto p45_clear

;Data = 1 ?
;No.

1225
1226 p45_set
1227

bsf

port_work,5

;Set bit5

55

1228

goto bit6_process4

1229 p45_clear
1230

bcf

port_work,5

;Clear bit5

1231
1232 bit6_process4
1233 ;****************** bit6 for process4 *******************
1234

btfss led_data0,6

;1x ?

1235

goto p46_0x

1236

btfss led_data1,6

1237

goto p46_10

;Jump to 10 process

1238

goto p46_11

;Jump to 11 process

;No.
;11 ?

1239 p46_0x
1240

btfsc led_data1,6

1241

goto p46_01

;01 ?
;Jump to 01 process

1242
1243 p46_00
1244

goto p46_set

;LED off

1245
1246 p46_01
1247

btfss led01,3

1248

goto p46_clear

1249

goto p46_set

;Data = 1 ?
;No.
;Yes.

1250
1251 p46_10
1252

btfss led10,3

1253

goto p46_clear

1254

goto p46_set

;Data = 1 ?
;No.
;Yes.

1255

56

1256 p46_11
1257

btfss led11,3

1258

goto p46_clear

;Data = 1 ?
;No.

1259
1260 p46_set
1261

bsf

port_work,6

;Set bit6

1262

goto bit7_process4

1263 p46_clear
1264

bcf

port_work,6

;Clear bit6

1265
1266 bit7_process4
1267 ;****************** bit7 for process4 *******************
1268

btfss led_data0,7

;1x ?

1269

goto p47_0x

1270

btfss led_data1,7

1271

goto p47_10

;Jump to 10 process

1272

goto p47_11

;Jump to 11 process

;No.
;11 ?

1273 p47_0x
1274

btfsc led_data1,7

1275

goto p47_01

;01 ?
;Jump to 01 process

1276
1277 p47_00
1278

goto p7_set

;LED off

1279
1280 p47_01
1281

btfss led01,3

1282

goto p7_clear

1283

goto p7_set

;Data = 1 ?
;No.
;Yes.

57

1284
1285 p47_10
1286

btfss led10,3

1287

goto p7_clear

1288

goto p7_set

;Data = 1 ?
;No.
;Yes.

1289
1290 p47_11
1291

btfss led11,3

1292

goto p7_clear

;Data = 1 ?
;No.

1293
1294 p7_set
1295

bsf

port_work,7

1296

goto led_cont

;Set bit7

1297 p7_clear
1298

bcf

port_work,7

1299

goto led_cont

;Clear bit7

1300
1301 int
1302 ;********** Interruption process beginning *************
1303

movwf w_save

;Save W register

1304

movfw status

;Read STATUS reg

1305

movwf s_save

;Save STATUS reg

1306

btfsc intcon,t0if

;Time out interruption ?

1307

goto timer_int

;Jump to Time-out

1308

goto init

;Reset(Illegal interrupt)

1309
1310 int_end
1311 ;************ END of interruption process **************

58

1312

movfw s_save

;Read saved STATUS reg

1313

movwf status

;Recover STATUS reg

1314

swapf w_save,f

;Read saved W register

1315

swapf w_save,w

;Recover W register

1316

retfie

1317
1318 timer_int
1319 ;***** Timer interruption process (50ms interval) ******
1320

bcf

intcon,t0if

;Clear timer int flag

1321

movlw d'61'

;Set timer value

1322

movwf tmr0

;TMR0 = 50ms

1323
1324 ;****************** Key Scan Process *******************
1325

btfsc porta,ra0

;RA0 ON(Low lebel) ?

1326

goto key0

;No.

1327

movlw d'2'

;Set pattern 1 data

1328

goto key2

;Pattern exec

1329 key0
1330

btfsc porta,ra1

;RA1 ON ?

1331

goto key1

;No.

1332

movlw d'1'

;Set pattern 0 data

1333

goto key2

;Pattern exec

1334 key1
1335

btfsc porta,ra2

;RA2 ON ?

1336

goto key3

;No.

1337

movlw d'3'

;Set pattern 2 data

1338 key2
1339

movwf ptn_save

;Save pattern

59

1340 key3
1341

decfsz counter,f

1342

goto int_end

;Count out ?
;Next Period

1343
1344 ;***************** Pattern Process *********************
1345

movlw speed

;Read speed data

1346

addlw d'1'

1347

movwf counter

1348

movlw d'1'

1349

subwf ptn_save,w

1350

btfsc status,z

;Pattern 0 ?

1351

goto ptn0

;Jump to pattern 0

1352

movlw d'2'

;Set pattern number

1353

subwf ptn_save,w

1354

btfsc status,z

;Pattern 1 ?

1355

goto ptn1

;Jump to pattern 1

1356

movlw d'3'

;Set pattern number

1357

subwf ptn_save,w

1358

btfsc status,z

;Pattern 2 ?

1359

goto ptn2

;Jump to pattern 2

;+1 addition
;Set counter
;Set pattern number
;Check pattern number

;Check pattern number

;Check pattern number

1360
1361 ptn0
1362 ;********************* Pattren 0 ***********************
1363

movlw d'1'

;Set pattern number

1364

subwf ptn_save,w

1365

btfss status,z

;Check pattern number

;Same ?

1366 ptn0_clear
1367

clrf ptn_counter

;Clear pattern counter

60

1368 ptn0_head
1369

movlw d'1'

;Set pattern number

1370

movwf ptn_save

1371

movfw ptn_counter

1372

btfsc status,z

1373

goto ptn0_0

1374

movlw d'1'

1375

subwf ptn_counter,w ;Check counter

1376

btfsc status,z

1377

goto ptn0_1

1378

movlw d'2'

1379

subwf ptn_counter,w ;Check counter

1380

btfsc status,z

1381

goto ptn0_2

1382

movlw d'3'

1383

subwf ptn_counter,w ;Check counter

1384

btfsc status,z

1385

goto ptn0_3

1386

movlw d'4'

1387

subwf ptn_counter,w ;Check counter

1388

btfsc status,z

1389

goto ptn0_4

1390

movlw d'5'

1391

subwf ptn_counter,w ;Check counter

1392

btfsc status,z

1393

goto ptn0_5

1394

movlw d'6'

1395

subwf ptn_counter,w ;Check counter

;Save pattern number


;Read pattern counter

;Counter = 0 ?
;Yes
;Set check data

;Counter = 1 ?
;Yes
;Set check data

;Counter = 2 ?
;Yes
;Set check data

;Counter = 3 ?
;Yes
;Set check data

;Counter = 4 ?
;Yes
;Set check data

;Counter = 5 ?
;Yes
;Set check data

61

1396

btfsc status,z

;Counter = 6 ?

1397

goto ptn0_6

1398

movlw d'7'

1399

subwf ptn_counter,w ;Check counter

1400

btfsc status,z

1401

goto ptn0_7

1402

movlw d'8'

1403

subwf ptn_counter,w ;Check counter

1404

btfsc status,z

1405

goto ptn0_8

1406

movlw d'9'

1407

subwf ptn_counter,w ;Check counter

1408

btfsc status,z

1409

goto ptn0_9

;Yes

1410

movlw d'10'

;Set check data

1411

subwf ptn_counter,w ;Check counter

1412

btfsc status,z

1413

goto ptn0_10

;Yes

1414

goto ptn0_clear

;Repeat

;Yes
;Set check data

;Counter = 7 ?
;Yes
;Set check data

;Counter = 8 ?
;Yes
;Set check data

;Counter = 9 ?

;Counter = 10 ?

1415
1416 ptn0_0
1417

clrf led_data0

1418

clrf led_data1

1419

goto p_countup

;Jump to count up

1420 ptn0_1
1421

movlw p010

1422

movwf led_data0

1423

movlw p011

;Set 1st upper data

;Set 1st lower data

62

1424

movwf led_data1

1425

goto p_countup

;Jump to count up

1426 ptn0_2
1427

movlw p020

1428

movwf led_data0

1429

movlw p021

1430

movwf led_data1

1431

goto p_countup

;Set 1st upper data

;Set 1st lower data

;Jump to count up

1432 ptn0_3
1433

movlw p030

1434

movwf led_data0

1435

movlw p031

1436

movwf led_data1

1437

goto p_countup

;Set 1st upper data

;Set 1st lower data

;Jump to count up

1438 ptn0_4
1439

movlw p040

1440

movwf led_data0

1441

movlw p041

1442

movwf led_data1

1443

goto p_countup

;Set 1st upper data

;Set 1st lower data

;Jump to count up

1444 ptn0_5
1445

movlw p050

1446

movwf led_data0

1447

movlw p051

1448

movwf led_data1

1449

goto p_countup

;Set 1st upper data

;Set 1st lower data

;Jump to count up

1450 ptn0_6
1451

movlw p060

;Set 1st upper data

63

1452

movwf led_data0

1453

movlw p061

1454

movwf led_data1

1455

goto p_countup

;Set 1st lower data

;Jump to count up

1456 ptn0_7
1457

movlw p070

1458

movwf led_data0

1459

movlw p071

1460

movwf led_data1

1461

goto p_countup

;Set 1st upper data

;Set 1st lower data

;Jump to count up

1462 ptn0_8
1463

movlw p080

1464

movwf led_data0

1465

movlw p081

1466

movwf led_data1

1467

goto p_countup

;Set 1st upper data

;Set 1st lower data

;Jump to count up

1468 ptn0_9
1469

movlw p090

1470

movwf led_data0

1471

movlw p091

1472

movwf led_data1

1473

goto p_countup

;Set 1st upper data

;Set 1st lower data

;Jump to count up

1474 ptn0_10
1475

movlw p0a0

1476

movwf led_data0

1477

movlw p0a1

1478

movwf led_data1

1479

goto p_countup

;Set 1st upper data

;Set 1st lower data

;Jump to count up

64

1480
1481 ptn1
1482 ;********************* Pattren 1 ***********************
1483

movlw d'2'

;Set pattern number

1484

subwf ptn_save,w

1485

btfss status,z

;Check pattern number

;Same ?

1486 ptn1_clear
1487

clrf ptn_counter

;Clear pattern counter

1488 ptn1_head
1489

movlw d'2'

;Set pattern number

1490

movwf ptn_save

1491

movfw ptn_counter

1492

btfsc status,z

1493

goto ptn1_0

1494

movlw d'1'

1495

subwf ptn_counter,w ;Check counter

1496

btfsc status,z

1497

goto ptn1_1

1498

movlw d'2'

1499

subwf ptn_counter,w ;Check counter

1500

btfsc status,z

1501

goto ptn1_2

1502

movlw d'3'

1503

subwf ptn_counter,w ;Check counter

1504

btfsc status,z

1505

goto ptn1_3

1506

movlw d'4'

1507

subwf ptn_counter,w ;Check counter

;Save pattern number


;Read pattern counter

;Counter = 0 ?
;Yes
;Set check data

;Counter = 1 ?
;Yes
;Set check data

;Counter = 2 ?
;Yes
;Set check data

;Counter = 3 ?
;Yes
;Set check data

65

1508

btfsc status,z

;Counter = 4 ?

1509

goto ptn1_4

1510

movlw d'5'

1511

subwf ptn_counter,w ;Check counter

1512

btfsc status,z

1513

goto ptn1_5

1514

movlw d'6'

1515

subwf ptn_counter,w ;Check counter

1516

btfsc status,z

1517

goto ptn1_6

1518

movlw d'7'

1519

subwf ptn_counter,w ;Check counter

1520

btfsc status,z

1521

goto ptn1_7

1522

movlw d'8'

1523

subwf ptn_counter,w ;Check counter

1524

btfsc status,z

1525

goto ptn1_8

1526

movlw d'9'

1527

subwf ptn_counter,w ;Check counter

1528

btfsc status,z

1529

goto ptn1_9

;Yes

1530

movlw d'10'

;Set check data

1531

subwf ptn_counter,w ;Check counter

1532

btfsc status,z

1533

goto ptn1_10

;Yes

1534

goto ptn1_clear

;Repeat

;Yes
;Set check data

;Counter = 5 ?
;Yes
;Set check data

;Counter = 6 ?
;Yes
;Set check data

;Counter = 7 ?
;Yes
;Set check data

;Counter = 8 ?
;Yes
;Set check data

;Counter = 9 ?

;Counter = 10 ?

1535

66

1536 ptn1_0
1537

clrf led_data0

1538

clrf led_data1

1539

goto p_countup

;Jump to count up

1540 ptn1_1
1541

movlw p110

1542

movwf led_data0

1543

movlw p111

1544

movwf led_data1

1545

goto p_countup

;Set 1st upper data

;Set 1st lower data

;Jump to count up

1546 ptn1_2
1547

movlw p120

1548

movwf led_data0

1549

movlw p121

1550

movwf led_data1

1551

goto p_countup

;Set 1st upper data

;Set 1st lower data

;Jump to count up

1552 ptn1_3
1553

movlw p130

1554

movwf led_data0

1555

movlw p131

1556

movwf led_data1

1557

goto p_countup

;Set 1st upper data

;Set 1st lower data

;Jump to count up

1558 ptn1_4
1559

movlw p140

1560

movwf led_data0

1561

movlw p141

1562

movwf led_data1

1563

goto p_countup

;Set 1st upper data

;Set 1st lower data

;Jump to count up

67

1564 ptn1_5
1565

movlw p150

1566

movwf led_data0

1567

movlw p151

1568

movwf led_data1

1569

goto p_countup

;Set 1st upper data

;Set 1st lower data

;Jump to count up

1570 ptn1_6
1571

movlw p160

1572

movwf led_data0

1573

movlw p161

1574

movwf led_data1

1575

goto p_countup

;Set 1st upper data

;Set 1st lower data

;Jump to count up

1576 ptn1_7
1577

movlw p170

1578

movwf led_data0

1579

movlw p171

1580

movwf led_data1

1581

goto p_countup

;Set 1st upper data

;Set 1st lower data

;Jump to count up

1582 ptn1_8
1583

movlw p180

1584

movwf led_data0

1585

movlw p181

1586

movwf led_data1

1587

goto p_countup

;Set 1st upper data

;Set 1st lower data

;Jump to count up

1588 ptn1_9
1589

movlw p190

1590

movwf led_data0

1591

movlw p191

;Set 1st upper data

;Set 1st lower data

68

1592

movwf led_data1

1593

goto p_countup

;Jump to count up

1594 ptn1_10
1595

movlw p1a0

;Set 1st upper data

1596

movwf led_data0

1597

movlw p1a1

1598

movwf led_data1

1599

goto p_countup

;Set 1st lower data

;Jump to count up

1600
1601 ptn2
1602 ;********************* Pattren 2 ***********************
1603

movlw d'3'

;Set pattern number

1604

subwf ptn_save,w

1605

btfss status,z

;Check pattern number

;Same ?

1606 ptn2_clear
1607

clrf ptn_counter

;Clear pattern counter

1608 ptn2_head
1609

movlw d'3'

;Set pattern number

1610

movwf ptn_save

1611

movfw ptn_counter

1612

btfsc status,z

1613

goto ptn2_0

1614

movlw d'1'

1615

subwf ptn_counter,w ;Check counter

1616

btfsc status,z

1617

goto ptn2_1

1618

movlw d'2'

1619

subwf ptn_counter,w ;Check counter

;Save pattern number


;Read pattern counter

;Counter = 0 ?
;Yes
;Set check data

;Counter = 1 ?
;Yes
;Set check data

69

1620

btfsc status,z

;Counter = 2 ?

1621

goto ptn2_2

1622

movlw d'3'

1623

subwf ptn_counter,w ;Check counter

1624

btfsc status,z

1625

goto ptn2_3

1626

movlw d'4'

1627

subwf ptn_counter,w ;Check counter

1628

btfsc status,z

1629

goto ptn2_4

1630

movlw d'5'

1631

subwf ptn_counter,w ;Check counter

1632

btfsc status,z

1633

goto ptn2_5

1634

movlw d'6'

1635

subwf ptn_counter,w ;Check counter

1636

btfsc status,z

1637

goto ptn2_6

1638

movlw d'7'

1639

subwf ptn_counter,w ;Check counter

1640

btfsc status,z

1641

goto ptn2_7

1642

movlw d'8'

1643

subwf ptn_counter,w ;Check counter

1644

btfsc status,z

1645

goto ptn2_8

1646

movlw d'9'

1647

subwf ptn_counter,w ;Check counter

;Yes
;Set check data

;Counter = 3 ?
;Yes
;Set check data

;Counter = 4 ?
;Yes
;Set check data

;Counter = 5 ?
;Yes
;Set check data

;Counter = 6 ?
;Yes
;Set check data

;Counter = 7 ?
;Yes
;Set check data

;Counter = 8 ?
;Yes
;Set check data

70

1648

btfsc status,z

;Counter = 9 ?

1649

goto ptn2_9

;Yes

1650

movlw d'10'

;Set check data

1651

subwf ptn_counter,w ;Check counter

1652

btfsc status,z

1653

goto ptn2_10

;Yes

1654

goto ptn2_clear

;Repeat

;Counter = 10 ?

1655
1656 ptn2_0
1657

clrf led_data0

1658

clrf led_data1

1659

goto p_countup

;Jump to count up

1660 ptn2_1
1661

movlw p210

1662

movwf led_data0

1663

movlw p211

1664

movwf led_data1

1665

goto p_countup

;Set 1st upper data

;Set 1st lower data

;Jump to count up

1666 ptn2_2
1667

movlw p220

1668

movwf led_data0

1669

movlw p221

1670

movwf led_data1

1671

goto p_countup

;Set 1st upper data

;Set 1st lower data

;Jump to count up

1672 ptn2_3
1673

movlw p230

1674

movwf led_data0

1675

movlw p231

;Set 1st upper data

;Set 1st lower data

71

1676

movwf led_data1

1677

goto p_countup

;Jump to count up

1678 ptn2_4
1679

movlw p240

1680

movwf led_data0

1681

movlw p241

1682

movwf led_data1

1683

goto p_countup

;Set 1st upper data

;Set 1st lower data

;Jump to count up

1684 ptn2_5
1685

movlw p250

1686

movwf led_data0

1687

movlw p251

1688

movwf led_data1

1689

goto p_countup

;Set 1st upper data

;Set 1st lower data

;Jump to count up

1690 ptn2_6
1691

movlw p260

1692

movwf led_data0

1693

movlw p261

1694

movwf led_data1

1695

goto p_countup

;Set 1st upper data

;Set 1st lower data

;Jump to count up

1696 ptn2_7
1697

movlw p270

1698

movwf led_data0

1699

movlw p271

1700

movwf led_data1

1701

goto p_countup

;Set 1st upper data

;Set 1st lower data

;Jump to count up

1702 ptn2_8
1703

movlw p280

;Set 1st upper data

72

1704

movwf led_data0

1705

movlw p281

1706

movwf led_data1

1707

goto p_countup

;Set 1st lower data

;Jump to count up

1708 ptn2_9
1709

movlw p290

1710

movwf led_data0

1711

movlw p291

1712

movwf led_data1

1713

goto p_countup

;Set 1st upper data

;Set 1st lower data

;Jump to count up

1714 ptn2_10
1715

movlw p2a0

1716

movwf led_data0

1717

movlw p2a1

1718

movwf led_data1

;Set 1st upper data

;Set 1st lower data

1719
1720 p_countup
1721

incf ptn_counter,f ;pattern counter count up

1722

goto int_end

;Next Period

1723
1724 ;********************************************************
1725 ;

END of LED flash control 2 process

1726 ;********************************************************
1727
1728

end

73

74

You might also like