ВУЗ: Не указан

Категория: Не указан

Дисциплина: Не указана

Добавлен: 14.06.2025

Просмотров: 491

Скачиваний: 0

ВНИМАНИЕ! Если данный файл нарушает Ваши авторские права, то обязательно сообщите нам.

MainLoop

movlw b'10000011'

movwf PORTB

call Delay500

; execute a 500mS delay

movlw b'11111111'

movwf PORTB

call Delay500

; execute a 500mS delay

Pretty simple isn’t it.

Modify the flash.asm code then try it out and see.

How can you convert this code into a single instruction??

movlw b'00000000' movwf PORTB

Check out the data sheet to find out and look in the instructions section.

(Hint: the instruction is cl.. PORTB)

If you are stuck, turn the page....

DIY K81 Project - Page 41

clrf PORTB

For some additional exercises.....

Try to make the LEDs count up in binary. Try to make LEDs count down in binary.

Try to makes the LEDs come on one at a time moving from left to right.

There are code examples for these exercises in the installation directory for you to look at. Try to do them yourself and use the examples if you get confused.

binaryup.asm

binarydn.asm

binarylr.asm

Two of these programs use the XORLW instruction to make sure the data written to PORTB is correct. Try to figure out why it was used.

XOR TRUTH TABLE

A

B

OUT

0

0

0

0

1

1

1

0

1

1

1

0

Hint: Notice how A XOR 1 = opposite A

If XORLW wasn’t used how would you increment or decrement the Counter value to make the program work. As you will find out, it’s much better to use the XOR instruction.

DIY K81 Project - Page 42


CONFIG

The __CONFIG statement at the start of the code is used to control the

Configuration Fuse register. This is a special location that controls how the chip operates. Things like Oscillator Type, Watch Dog Timer, Programming Mode and other features. These are listed in the data sheets. The value used...

__CONFIG 0x3FFB

... is a specially selected value for this project. It selects RC Oscillator, Watch Dog Disabled and no Code Protection.

RC mode was selected because the PIC clock source connected to the demonstration socket is a simple Resistor/Capacitor circuit.

Please do not alter this value as the PIC may stop operating when you run the code. If you accidently changed the value, change it back and reassemble. After programming again, the chip should run normally.

Cheers and happy programming.

DIY K81 Project - Page 43

PARTS LIST

Used

Part Type

Designators

Description

SEMICONDUCTORS

1

PIC16F84A

IC4

PIC Processor

1

74LS07

IC3

HEX OC buffer

1

78L05

IC1

Regulator

1

78L08

IC2

Regulator

2

BC557

Q1, Q2

PNP Transistor

1

W02

B1

Bridge Rectifier

1

RB2

L2

5mm LED

1

RB3

L3

5mm LED

1

RB4

L4

5mm LED

1

RB5

L5

5mm LED

1

RB6

L6

5mm LED

1

Program /Verify

L1

5mm LED

RESISTORS all 1/4W 5%

1

SIP 10K

SIL1

1

SIP 1K

SIL2

1

1K

R1

2

3K3

R3, R6

1

3K9

R8

4

10K

R2, R4, R5, R7

CAPACITORS

1

330p

C6

Ceramic

1

22p

C5

Ceramic

3

100N

C1, C2, C4

Ceramic

1

470uF

C3

Electrolytic 35V

MISCELLANEOUS

1

BLANK PCB

PCB1

2

IC SOCKET

18 pin

1

IC SOCKET

14 pin

1

PARALLEL

CN1

Male RA DB25

1

JACK

JK1

3 Pin Power Jack

DIY K81 Project - Page 44


1

2

3

4

IC1

IC2

78L08

1

BR1

78L05

D

1

Vin

Vout

3

VPP

JK1

GND

1

4

2

1

Vin

Vout

3

VCC

2

GND

2

3

JACK

W02

C3

C1

C4

3

2

470uF

100N

100N

GND

J1

DB25

C

13

25 GND

IC3A

12

24

11

7407

23

10

22

9

1

2

21

8

SIL2

20

IC3F

7

19

1K

6

VCC

18

13

12

5

17

4

16

IC3B

R8

3

14

15

3K9

IC4

2

B

14

3

4

MCLR VCC

1

L1

L2

L3

L4

L5

4

16

OSC1

RB0

6

IC3E

15

7

OSC2

RB1

8

17

RB2

9

VCC

RA0

RB3

18

10

11

10

RA1

RB4

1

11

RA2

RB5

2

12

RA3

RB6

3

13

RA4

Gnd

RB7

IC3D

C5

16F84

R7

5

22p

TEST CIRCUIT

8

9

10K

GND

IC3C

A

VDD

5

6

1

2

3

4

5

6

D

VCC

VPP

R5

R2

10K

10K

Q2

Q1

BC557

BC557

R6

R3

3K3

3K3

C

VDD

14

IC5

L6

VCC

MCLR

1

4

6

RB0

OSC1

16

SIL1

7

15

RB1

OSC2

8

R1

10K

9

RB2

17

RB3

RA0

10

18

R4

1K

4 3 2

11

RB4

RA1

1

12

RB5

RA2

2

10K

13

RB6

RA3

3

RB7

Gnd

RA4

16F84

5

B

GND

VDD

C6

C2

100N

330p

GND

A

Title

Size

Number

Revision

B

7407

Date:

Sheet of

22-Nov-2002

File:

C:\DIYPRO~1\K81\KIT81.SCH

Drawn By:

5

6