Microchip TC1320 Manual


Læs gratis den danske manual til Microchip TC1320 (39 sider) i kategorien Ikke kategoriseret. Denne vejledning er vurderet som hjælpsom af 14 personer og har en gennemsnitlig bedømmelse på 4.1 stjerner ud af 7.5 anmeldelser. Har du et spørgsmål om Microchip TC1320, eller vil du spørge andre brugere om produktet?

Side 1/39
2000 Microchip Technology Inc. Preliminary DS00735A-page 1
INTRODUCTION
This application note describes the implementation of
the PICmicro MSSP module for Master I2C communi-
cations. The Master Synchronous Serial Port (MSSP)
module is the enhanced Synchronous Serial Port
developed by Microchip Technology and is featured on
many of the PICmicro devices. This module provides
for both the 4-mode SPI communications, as well as
Master and Slave I2C communications, in hardware.
For information on the SPITM peripheral implementation
see the PICmicroTM Mid-Range MCU Family Reference
Manual, document DS33023. The MSSP module in I
2C
mode fully implements all Master and Slave functions
(including general call support) and provides interrupts
on START and STOP bits in hardware to determine a
free I2C bus (multi-master function). The MSSP module
implements the standard mode specifications, as well
as 7-bit and 10-bit addressing. Figure 1 depicts a func-
tional block diagram of the I2C Master mode. The appli-
cation code for this I2C example is developed for and
tested on a PIC16F873, but can be ported over to a
PIC17CXXX and PIC18CXXX PICmicro MCU which
features a MSSP module.
FIGURE 1: I2C MASTER MODE BLOCK DIAGRAM
Author: Richard L. Fischer
Microchip Technology Inc.
Read Write
SSPSR
START bit, STOP bit,
SSPBUF
Internal
Data Bus
Set/Reset, S, P, WCOL (SSPSTAT)
Shift
Clock
MSb LSb
SDA
Acknowledge
Generate
SCL
SCL In
Bus Collision
SDA In
Receive Enable
Clock cntl
Clock Arbitrate/WCOL Detect
(hold off clock source)
SSPADD<6:0>
Baud
Set SSPIF, BCLIF
Reset ACKSTAT, PEN (SSPCON2)
Rate
Generator
SSPM3:SSPM0
START bit detect
STOP bit detect
Write collision detect
Clock Arbitration
State counter for
end of XMIT/RCV
AN735
Using the PICmicro® MSSP Module for Master
I2CTM Communications
AN735
DS00735A-page 2 Preliminary 2000 Microchip Technology Inc.
THE I2C BUS SPECIFICATION
Although a complete discussion of the I
2C bus specifi-
cation is outside the scope of this application note,
some of the basics will be covered here. For more infor-
mation on the I2C bus specification, you may refer to
sources indicated in the References section.
The Inter-Integrated-Circuit, or I2C bus specification
was originally developed by Philips Inc. for the transfer
of data between ICs at the PCB level. The physical
interface for the bus consists of two open-collector
lines; one for the clock (SCL) and one for data (SDA).
The SDA and SCL lines are pulled high by resistors
connected to the VDD rail. The bus may have a one
Master/many Slave configuration or may have multiple
master devices. The master device is responsible for
generating the clock source for the linked Slave
devices.
The I2C protocol supports either a 7-bit addressing
mode, or a 10-bit addressing mode, permitting 128 or
1024 physical devices to be on the bus, respectively. In
practice, the bus specification reserves certain
addresses so slightly fewer usable addresses are avail-
able. For example, the 7-bit addressing mode allows
112 usable addresses. The 7-bit address protocol is
used in this application note.
All data transfers on the bus are initiated by the master
device and are done eight bits at a time, MSb first.
There is no limit to the amount of data that can be sent
in one transfer. After each 8-bit transfer, a 9th clock
pulse is sent by the master. At this time, the transmit-
ting device on the bus releases the SDA line and the
receiving device on the bus acknowledges the data
sent by the transmitting device. An ACK (SDA held low)
is sent if the data was received successfully, or a NACK
(SDA left high) is sent if it was not received success-
fully. A NACK is also used to terminate a data transfer
after the last byte is received.
According to the I2C specification, all changes on the
SDA line must occur while the SCL line is low. This
restriction allows two unique conditions to be detected
on the bus; a START sequence (S) and a STOP
sequence (P). A START sequence occurs when the
master device pulls the SDA line low while the SCL line
is high. The START sequence tells all Slave devices on
the bus that address bytes are about to be sent. The
STOP sequence occurs when the SDA line goes high
while the SCL line is high, and it terminates the trans-
mission. Slave devices on the bus should reset their
receive logic after the STOP sequence has been
detected.
The I2C protocol also permits a Repeated Start condi-
tion (Rs), which allows the master device to execute a
START sequence without preceding it with a STOP
sequence. The Repeated Start is useful, for example,
when the Master device changes from a write operation
to a read operation and does not release control of the
bus.
MSSP MODULE SETUP,
IMPLEMENTATION AND CONTROL
The following sections describe the setup, implemen-
tation and control of the PICmicro MSSP module for
I2C Master mode. Some key Special Function Regis-
ters (SFRs) utilized by the MSSP module are:
1. SSP Control Register1 (SSPCON1)
2. SSP Control Register2 (SSPCON2)
3. SSP Status Register (SSPSTAT)
4. Pin Direction Control Register (TRISC)
5. Serial Receive/Transmit Buffer (SSPBUF)
6. SSP Shift Register (SSPSR) - Not directly
accessible
7. SSP Address Register (SSPADD)
8. SSP Hardware Event Status (PIR1)
9. SSP Interrupt Enable (PIE1)
10. SSP Bus Collision Status (PIR2)
11. SSP Bus Collision Interrupt Enable (PIE2)
Module Setup
To configure the MSSP module for Master I2C mode,
there are key SFR registers which must be initialized.
Respective code examples are shown for each.
1. SSP Control Register1 (SSPCON1)
• I2C Mode Configuration
2. SSP Address Register (SSPADD<6:0>)
• I2C Bit Rate
3. SSP Status Register (SSPSTAT)
Slew Rate Control
Input Pin Threshold Levels (SMbus or I2C)
4. Pin Direction Control (TRISC)
SCL/SDA Direction
To configure the MSSP module for Master I2C mode,
the SSPCON1 register is modified as shown in
Example 1.
EXAMPLE 1: I2C MODE CONFIGURATION
With the two-wire synchronous I2C bus, the Master
generates all clock signals at a desired bit rate. Using
the formula in Equation 1, the bit rate can be calculated
and written to the SSPADD register. For a 400kHz bit
rate @ Fosc = 16MHz, the SSPADD register is modi-
fied as shown in Example 2.
movlw b’00101000’ ; setup value
; into W register
banksel SSPCON1 ; select SFR
; bank
movwf SSPCON1 ; configure for
; Master I 2C


Produkt Specifikationer

Mærke: Microchip
Kategori: Ikke kategoriseret
Model: TC1320

Har du brug for hjælp?

Hvis du har brug for hjælp til Microchip TC1320 stil et spørgsmål nedenfor, og andre brugere vil svare dig




Ikke kategoriseret Microchip Manualer

Ikke kategoriseret Manualer

Nyeste Ikke kategoriseret Manualer