Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
11
Добавлен:
21.12.2020
Размер:
8.16 Mб
Скачать

PIC18F8722 FAMILY

20.4.2EUSART SYNCHRONOUS SLAVE RECEPTION

The operation of the Synchronous Master and Slave modes is identical, except in the case of Sleep, or any Idle mode and bit SREN, which is a “don’t care” in Slave mode.

If receive is enabled by setting the CREN bit prior to entering Sleep or any Idle mode, then a word may be received while in this low-power mode. Once the word is received, the RSRx register will transfer the data to the RCREGx register; if the RCxIE enable bit is set, the interrupt generated will wake the chip from the lowpower mode. If the global interrupt is enabled, the program will branch to the interrupt vector.

To set up a Synchronous Slave Reception:

1.Enable the synchronous master serial port by setting bits SYNC and SPEN and clearing bit CSRC.

2.If interrupts are desired, set enable bit RCxIE.

3.If 9-bit reception is desired, set bit RX9.

4.To enable reception, set enable bit CREN.

5.Flag bit, RCxIF, will be set when reception is complete. An interrupt will be generated if enable bit, RCxIE, was set.

6.Read the RCSTAx register to get the 9th bit (if enabled) and determine if any error occurred during reception.

7.Read the 8-bit received data by reading the RCREGx register.

8.If any error occurred, clear the error by clearing bit CREN.

9.If using interrupts, ensure that the GIE and PEIE bits in the INTCON register (INTCON<7:6>) are set.

TABLE 20-10: REGISTERS ASSOCIATED WITH SYNCHRONOUS SLAVE RECEPTION

 

 

 

 

 

 

 

 

 

Reset

Name

Bit 7

Bit 6

Bit 5

Bit 4

Bit 3

Bit 2

Bit 1

Bit 0

Values

 

 

 

 

 

 

 

 

 

on page

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

INTCON

GIE/GIEH

PEIE/GIEL

TMR0IE

INT0IE

RBIE

TMR0IF

INT0IF

RBIF

57

PIR1

PSPIF

ADIF

RC1IF

TX1IF

SSP1IF

CCP1IF

TMR2IF

TMR1IF

60

PIE1

PSPIE

ADIE

RC1IE

TX1IE

SSP1IE

CCP1IE

TMR2IE

TMR1IE

60

IPR1

PSPIP

ADIP

RC1IP

TX1IP

SSP1IP

CCP1IP

TMR2IP

TMR1IP

60

TRISC

TRISC7

TRISC6

TRISC5

TRISC4

TRISC3

TRISC2

TRISC1

TRISC0

60

 

 

 

 

 

 

 

 

 

 

TRISG

TRISG4

TRISG3

TRISG2

TRISG1

TRISG0

60

RCSTAx

SPEN

RX9

SREN

CREN

ADDEN

FERR

OERR

RX9D

59

RCREGx

EUSARTx Receive Register

 

 

 

 

 

59

 

 

 

 

 

 

 

 

 

 

TXSTAx

CSRC

TX9

TXEN

SYNC

SENDB

BRGH

TRMT

TX9D

59

BAUDCONx

ABDOVF

RCIDL

SCKP

BRG16

WUE

ABDEN

61

SPBRGHx

EUSARTx Baud Rate Generator Register High Byte

 

 

 

61

 

 

 

 

 

 

SPBRGx

EUSARTx Baud Rate Generator Register Low Byte

 

 

 

59

 

 

 

 

 

 

 

 

 

 

Legend: — = unimplemented, read as ‘0’. Shaded cells are not used for synchronous slave reception.

2004 Microchip Technology Inc.

Preliminary

DS39646B-page 269

PIC18F8722 FAMILY

NOTES:

DS39646B-page 270

Preliminary

2004 Microchip Technology Inc.

PIC18F8722 FAMILY

21.010-BIT ANALOG-TO-DIGITAL CONVERTER (A/D) MODULE

The Analog-to-Digital (A/D) converter

module has

12 inputs for the 64-pin devices and 16

for the 80-pin

devices. This module allows conversion of an analog input signal to a corresponding 10-bit digital number.

The module has five registers:

A/D Result High Register (ADRESH)

A/D Result Low Register (ADRESL)

A/D Control Register 0 (ADCON0)

A/D Control Register 1 (ADCON1)

A/D Control Register 2 (ADCON2)

The ADCON0 register, shown in Register 21-1, controls the operation of the A/D module. The ADCON1 register, shown in Register 21-2, configures the functions of the port pins. The ADCON2 register, shown in Register 21-3, configures the A/D clock source, programmed acquisition time and justification.

REGISTER 21-1: ADCON0: A/D CONTROL REGISTER

U-0

U-0

R/W-0

R/W-0

R/W-0

R/W-0

R/W-0

R/W-0

CHS3

CHS2

CHS1

CHS0

 

 

 

ADON

GO/DONE

 

bit 7

 

 

 

 

 

 

 

 

bit 0

bit 7-6 Unimplemented: Read as ‘0

bit 5-2 CHS3:CHS0: Analog Channel Select bits

0000 = Channel 0 (AN0)

0001 = Channel 1 (AN1)

0010 = Channel 2 (AN2)

0011 = Channel 3 (AN3)

0100 = Channel 4 (AN4)

0101 = Channel 5 (AN5)

0110 = Channel 6 (AN6)

0111 = Channel 7 (AN7)

1000 = Channel 8 (AN8)

1001 = Channel 9 (AN9)

1010 = Channel 10 (AN10)

1011 = Channel 11 (AN11)

1100 = Channel 12 (AN12)(1)

1101 = Channel 13 (AN13)(1)

1110 = Channel 14 (AN14)(1)

1111 = Channel 15 (AN15)(1)

Note 1: These channels are not implemented on 64-pin devices.

bit 1 GO/DONE: A/D Conversion Status bit

When ADON = 1:

1 = A/D conversion in progress

0 = A/D Idle

bit 0 ADON: A/D On bit

1 = A/D converter module is enabled

0 = A/D converter module is disabled

Legend:

 

 

 

R = Readable bit

W = Writable bit

U = Unimplemented bit, read as ‘0’

-n = Value at POR

‘1’ = Bit is set

‘0’ = Bit is cleared

x = Bit is unknown

 

 

 

 

2004 Microchip Technology Inc.

Preliminary

DS39646B-page 271

PIC18F8722 FAMILY

REGISTER 21-2: ADCON1: A/D CONTROL REGISTER 1

 

U-0

 

U-0

 

R/W-0

R/W-0

R/W-0

R/W-0

R/W-0

R/W-0

 

 

VCFG1

VCFG0

PCFG3

PCFG2

PCFG1

PCFG0

 

bit 7

 

 

 

 

 

 

 

 

 

bit 0

bit 7-6

Unimplemented: Read as ‘0

 

 

 

 

 

 

bit 5-4

VCFG1:VCFG0: Voltage Reference Configuration bits

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

A/D VREF+

 

A/D VREF-

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

00

 

 

AVDD

 

AVSS

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

01

 

External VREF+

 

AVSS

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

10

 

 

AVDD

 

External VREF-

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

11

 

External VREF+

 

External VREF-

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

bit 3-0 PCFG3:PCFG0: A/D Port Configuration Control bits:

 

(1)

(1)

(1)

(1)

AN11

AN10

AN9

AN8

AN7

AN6

AN5

AN4

AN3

AN2

AN1

AN0

PCFG3:

AN15

AN14

AN13

AN12

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

PCFG0

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0000

A

A

A

A

A

A

A

A

A

A

A

A

A

A

A

A

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0001

D

D

A

A

A

A

A

A

A

A

A

A

A

A

A

A

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0010

D

D

D

A

A

A

A

A

A

A

A

A

A

A

A

A

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0011

D

D

D

D

A

A

A

A

A

A

A

A

A

A

A

A

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0100

D

D

D

D

D

A

A

A

A

A

A

A

A

A

A

A

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0101

D

D

D

D

D

D

A

A

A

A

A

A

A

A

A

A

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0110

D

D

D

D

D

D

D

A

A

A

A

A

A

A

A

A

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0111

D

D

D

D

D

D

D

D

A

A

A

A

A

A

A

A

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

1000

D

D

D

D

D

D

D

D

D

A

A

A

A

A

A

A

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

1001

D

D

D

D

D

D

D

D

D

D

A

A

A

A

A

A

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

1010

D

D

D

D

D

D

D

D

D

D

D

A

A

A

A

A

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

1011

D

D

D

D

D

D

D

D

D

D

D

D

A

A

A

A

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

1100

D

D

D

D

D

D

D

D

D

D

D

D

D

A

A

A

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

1101

D

D

D

D

D

D

D

D

D

D

D

D

D

D

A

A

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

1110

D

D

D

D

D

D

D

D

D

D

D

D

D

D

D

A

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

1111

D

D

D

D

D

D

D

D

D

D

D

D

D

D

D

D

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

A = Analog input

 

 

 

 

D = Digital I/O

 

 

 

 

 

 

 

Note 1: AN15 through AN12 are available only on 80-pin devices.

Legend:

 

 

 

R = Readable bit

W = Writable bit

U = Unimplemented bit, read as ‘0’

-n = Value at POR

‘1’ = Bit is set

‘0’ = Bit is cleared

x = Bit is unknown

 

 

 

 

DS39646B-page 272

Preliminary

2004 Microchip Technology Inc.

PIC18F8722 FAMILY

REGISTER 21-3:

ADCON2: A/D CONTROL REGISTER 2

 

 

 

 

 

 

 

R/W-0

U-0

R/W-0

R/W-0

R/W-0

R/W-0

R/W-0

R/W-0

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

ADFM

ACQT2

 

ACQT1

ACQT0

ADCS2

ADCS1

ADCS0

 

 

bit 7

 

 

 

 

 

 

 

bit 0

bit 7

 

ADFM: A/D Result Format Select bit

 

 

 

 

 

 

1

= Right justified

 

 

 

 

 

 

 

 

0

= Left justified

 

 

 

 

 

 

 

bit 6 Unimplemented: Read as ‘0

bit 5-3 ACQT2:ACQT0: A/D Acquisition Time Select bits

111 = 20 TAD

110 = 16 TAD

101 = 12 TAD

100 = 8 TAD

011 = 6 TAD

010 = 4 TAD

001 = 2 TAD

000 = 0 TAD(1)

bit 2-0 ADCS2:ADCS0: A/D Conversion Clock Select bits

111 = FRC (clock derived from A/D RC oscillator)(1) 110 = FOSC/64

101 = FOSC/16

100 = FOSC/4

011 = FRC (clock derived from A/D RC oscillator)(1) 010 = FOSC/32

001 = FOSC/8

000 = FOSC/2

Note 1: If the A/D FRC clock source is selected, a delay of one TCY (instruction cycle) is added before the A/D clock starts. This allows the SLEEP instruction to be executed before starting a conversion.

Legend:

 

 

 

R = Readable bit

W = Writable bit

U = Unimplemented bit, read as ‘0’

-n = Value at POR

‘1’ = Bit is set

‘0’ = Bit is cleared

x = Bit is unknown

 

 

 

 

2004 Microchip Technology Inc.

Preliminary

DS39646B-page 273

Соседние файлы в папке Склад