• No results found

Flowcode PICmicro 16F877A

N/A
N/A
Protected

Academic year: 2021

Share "Flowcode PICmicro 16F877A"

Copied!
27
0
0

Loading.... (view fulltext now)

Full text

(1)

PICMicrocontroller

(2)

Input/Output

• Pins can be assigned as analog input,

digital input or digital output

(3)
(4)
(5)

Has 6 pins

RegisterAbit0 to RegisterAbit5 (RA0-RA5)

AnalogInput0 to AnalogInput4 (AN0-AN4)

RA0-RA5 can be used as digital inputs

Port A

RA0-RA5 can be used as digital inputs

RA0-RA5 can be used as digital outputs

AN0-AN4 can be used as analog inputs

(6)
(7)

Has 8 pins

RB0-RB7 can be used as digital

inputs

RB0-RB7 can be used as digital

Port B

RB0-RB7 can be used as digital

outputs

External interrupt pin on RB0

(8)
(9)

Has 8 pins

RC0-RC7 can be used as digital inputs

RC0-RC7 can be used as digital outputs

PWM (Pulse Width Modulation) is possible

Port C

PWM (Pulse Width Modulation) is possible

on RC1 AND RC2

Port C contains USART (Universal

Synchronous - Asynchronous Receiver

Transmitter) for serial communication

(10)
(11)

Has 8 pins

RD0-RD7 can be used as digital

inputs

RD0-RD7 can be used as digital

Port D

RD0-RD7 can be used as digital

outputs

(12)
(13)

Has 3 pins

RE0-RE2 can be used as digital

inputs

RE0-RE2 can be used as digital

Port E

RE0-RE2 can be used as digital

outputs

AN5-AN7 can be used as analogue

inputs

(14)
(15)
(16)

EPROM

The memory where the program you

write is stored in.

The program you write is 'compiled'

by your computer to binary code and

by your computer to binary code and

then downloaded into the Flash

memory of the PICmicro.

The Flash memory of the 16F877 can

store up to 8000 program commands.

(17)

RAM

RAM is the memory where the

'variables' you declare are stored in.

This memory is of the RAM-type. It is

erased every time the power gets cut

erased every time the power gets cut

or a reset occurs.

The RAM of the 16F877A can store

up to 368 bytes of data.

(18)

EEPROM

Sometimes referred to as 'Flash'

memory.

EEPROM is the memory where the

variables can be permanently stored

variables can be permanently stored

This memory is of the PROM-type. It

is preserved every time the power

gets cut or a reset occurs.

The EEPROM of the 16F877A can

store up to 256 bytes of data.

(19)

ALU

The ALU (Arithmetic Logic Unit) is the

heart of the PICmicro.

Everything passes through this unit.

The program in the Flash memory tells the

ALU what to do.

ALU what to do.

The ALU can send data to, and fetch data

from all the separate blocks and Ports in

the PICmicro by the 8-bit wide data-bus.

The ALU needs 4 external oscillator clock

pulses to execute one whole instruction.

(20)

TMR1

This timer interrupt is used to provide the PICmicro with exact timing info.

It is clocked by the system clock or by an external clock on RC0. This system clock runs exactly 4 times slower than the external oscillator clock.

Either the external clock or the system clock can be divided by 1, 2, 4 or 8 by configuring the Prescaler of TMR1 in Flowcode.

This divided clock triggers the TMR1 to increment the TMR1 This divided clock triggers the TMR1 to increment the TMR1 register.

This TMR1 register is an 8-bit register and will have an overflow when it reaches 256.

he exact moment when this overflow occurs, TMR1 generates an interrupt and the TMR1 register is set back to 0.

This TMR1 Interrupt will stop the main program immediately and start up the TMR1 Macro.

After the TMR1 Macro is finished, the main program goes further where it had left before.

(21)

Example

External clock oscillator

= XTAL

: 19.660.800Hz

System Clock

= /4

: 4.915.200 Hz

Set prescaler to 8

= /8

Set prescaler to 8

= /8

: 614.400 Hz

Overflow when TMR1 = 256

= /256

: 2400 Hz

Conclusion: In this situation, TMR1 will

interrupt the main program and execute the

TMR1 Macro 2400 times per second.

(22)

TMR0

This timer interrupt is used to provide the PICmicro with exact timing info. It is clocked by the system clock or by an external clock on RA4.

This system clock runs exactly 4 times slower than the external oscillator clock.

Either the external clock or the system clock can be divided by 1, 2, 4 or 8, 16, 32, 64, 128, or by 256 by configuring the Prescaler of TMR0 in

Flowcode.

This divided clock triggers TMR0 to increment the TMR0 register. This divided clock triggers TMR0 to increment the TMR0 register.

This TMR0 register is an 8-bit register and will have an overflow when it reaches 256.

he exact moment when this overflow occurs, TMR0 generates an interrupt and the TMR0 register is set back to 0.

This TMR0 Interrupt will stop the main program immediately and start up the TMR0 Macro.

After the TMR0 Macro is finished, the main program goes further where it had left before.

(23)

Example

Example:

External clock oscillator

=

XTAL

: 19.660.800Hz

System Clock

= /4

System Clock

= /4

: 4.915.200 Hz

Set prescaler to 256

=

/256

: 19200 Hz

Overflow when TMR0 = 256 = /256

: 75 Hz

(24)

RB0 External Interrupt

A logic level change on RB0 can be

configured to generate an interrupt.

It can be configured in Flowcode to react to

a rising or to a falling edge on RB0.

When it is set to react to a rising edge and

When it is set to react to a rising edge and

a rising edge occurs at RB0 then:

This will immediately stop the main program

The RB0 related macro is executed

After this RBO macro is executed, the main

program goes further where it had left before.

This will happen every time a rising edge is

detected at pin RB0

(25)

PORT B External

Interrupt

A logic level change on either RB4 or RB5 or RB6 or RB7

can be configured to generate one and the same single

interrupt.

It can not be configured to react to a rising or to a falling

edge. It is triggered by both rising and falling edges.

When it is configured in Flowcode and a level change occurs

on either of these 4 input pins of Port B:

on either of these 4 input pins of Port B:

This will immediately stop the main program The PORTB related macro is executed

After this PORTB macro is executed, the main program goes further where it had left before.

This will happen every time a level change is detected on

one of the 4 MSB's of PORTB

(26)

A/D Conversion

This 16F877A PICmicro Microcontroller has 8 pins that have an extra A/D function.

This PICmicro controller has only one single 10-bit A/D converter. This implies that these 8 Analogue inputs can't all be read at the same time.

A built in analogue switch is the answer to this problem.

In Flowcode you can select witch of the 8 analogue inputs you want to sample.

to sample.

After this 'sample' instruction, the analogue switch is set to the

correct input and this analogue input is converted to a 10-bit binary value.

In Flowcode, you can select to only use the 8 MSB's of this 10-bit value by using the 'ReadAsByte' instruction, or you can select to use the full 10 bits by selecting the 'ReadAsInt' instruction. The 10 bits will fill up the 10 LSB's of the selected 16-bit integer variable. After this, you can select an other analogue input that needs to be read.

(27)

Busses

Busses

Busses

Busses

A PICmicro is a typical Harvard-type

Microcontroller.

This means that there is a separate bus for

Instructions and one for Data.

Instructions and one for Data.

The data bus is 8-bit wide and connects

every block and port together.

The instruction bus is 14 bit wide and

transports 14 bit long instructions from the

program memory to the ALU.

References

Related documents

Тип ресурсу Призначення Алфавітний підхід Статистичний підхід Семантичний підхід Файлова система Персональний ресурс Автоматично Не застосовується

As a producer of custom drip pans it is natural that Killarney Metals has a drip pan for your Aircraft drip tray needs.. Useful for all general aviation and maintenance needs, we

Key words: Ahtna Athabascans, Community Subsistence Harvest, subsistence hunting, GMU 13 moose, Alaska Board o f Game, Copper River Basin, natural resource management,

By first analysing the image data in terms of the local image structures, such as lines or edges, and then controlling the filtering based on local information from the analysis

Txawm hais tias nws nyuam qhuav nrhiav tau tus Tswv txoj kev zoo siab, nws paub hais tias nws qhov kev cia siab rau txoj kev xyiv fab uas nyob mus ib txhis nyob ntawm saib cov

We have shown in Section 2.1 that for the DI model and the SP models, in so far as we assume a homogeneous susceptible population such that there is one group of

The landowner may reserve the right to inspect the camphouse, motor vehicles and the game bags of hunters and guests on the leased premises for compliance both with the lease terms