External functional features of PIC16C64 microcontroller

Publisher:落寞梦惊Latest update time:2017-12-05 Source: eefocusKeywords:PIC16C64 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

      1. Capture/Compare/ PWM Module

  The RC2 /CCPI pin of the PICI6C64 microcontroller has the functions of capture/compare/ PWM output , corresponding to the internal capture/compare/PWM module, referred to as the CCPI module. This module has a 16-bit register (CCPR1) which can be set by software as a capture register, compare register or PWM output register. The mode is selected by the CCP1 control register (CCP1CON) in the graphics card.


  (I) Capture function

  When the RC2/CCP 1 pin is used as a capture function, it should be set to input state. When a pulse event occurs on the CCP1 pin, CCPR1 captures and records the value of TMR1 (counter 1) at this time, and generates a capture interrupt request.

  Example 1. BSF TRISC,2; CCP1 pin is set as input

  MOVLW,XXXX0101; Select CCP1 as the capture mode,

  Each rising edge is valid

  MOVWF CCP1CON ; Set CCPP1 control register

  The capture function can be used to calculate external pulse width ( frequency ), etc.

  

 

  0000: CCP1 mode function is disabled (reset).

  0100: Capture mode, CCP1 pin captures every falling edge.

  0101: Capture mode, every rising edge of CCP1 pin is captured.

  0110: Capture mode, CCP1 pin captures every 4 rising edges.

  0111: Capture mode, CCP1 pin captures every 16 rising edges.

  1000: Compare mode, CCP1 pin is set to 1 when it matches.

  1001: Compare mode, CCP1 pin is cleared to 0 when it matches.

  1010: Comparison mode, when the match occurs, the CCCP1 pin remains unchanged and an interrupt request is generated.

  1011: Compare mode: trigger a special event to occur.

  11XX: PWM output mode

  (ii) Comparison function RC2/CCP1 pin should be set to output state at this time. In comparison mode, CCPR1 register is constantly compared with TMR1 register. When the values ​​of the two registers are equal (match), the following situations may occur on RC2/CCP1 pin.

  (1) Pull to high level

  (2) Pull to low level

  (3) Remain unchanged.

  At the same time, a compare interrupt request is also generated.

  Example 2. BCF TRISC,2; CCP1 pin is set as output

  MOVLW XXXX1000; select CCP1 as compare mode

  When a match occurs, the CCP1 pin is set high.

  MOVWF CCP1CON; Set the OCPI control register comparison function, which is often used to time drive certain components.

  


(III) PWM  function

 

  At this time, the RC2/ CC P1 pin should be set to output state. In PWM mode, the user sets the 8-bit duty cycle into the lower 8-bit byte CCPR1L of CCPR1, and the upper 8-bit CCPR1H is used as the PWM register. The PWM generation process is shown in the figure:

  PWM cycle = [(PR2) + 1] × 4Tosc × (TMR2 pre- division value)

  PWM Dwty Cycle = DC1 × Tosc × (TMR2 pre-division value


  DC1 = 10-bit value composed of CCPR1L and CCPR1CON (5:4), so the PWM output resolution can reach up to 10 bits. The relationship between PWM frequency and resolution (under 20 MHz oscillation , see Table 1.

  Table 1 PWM frequency and resolution relationship table

  

 

  2. Synchronous Serial Port (SSP) ??

  The PIC16C64 microcontroller has a synchronous serial port, referred to as SSP, which can be used to communicate with other peripheral devices or microcontrollers. Peripheral devices can be EEPROM, shift registers, display drivers, A/D converters, etc. The SSP module can be selected by the user in two working modes

  (1)Serial peripheral interface (SPI)

  (2)I2C interface

  (I) Serial External Interface (SPI) mode The SPI mode allows 8-bit data to be transmitted and received synchronously, using 3 pins to complete its communication function:

  (1)Serial Data Out (SDO)

  (2) Serial Data Input ( SDI )

  (3)Serial Clock ( SCK )

  PICI6C64 has an SSP control register SSP CON, which users can set with software to select the working mode they need. Another SSP status register SSPSTAT records the various working states of the SSP.

  By setting the SSPCON(5:0) bits, the SPI can operate in the following modes.

  (1) Master control mode (SCK as clock output)

  (2) Slave mode (SCK as clock input)

  (3) Clock polarity (SCK rising/falling edge transmits data) Figure 3 shows a typical example of two microprocessors connected.

  

 

  The master controller (microprocessor 1) starts transmitting data through the SCK signal. Data is transmitted through the shift register on each clock edge and latched on the next edge. The two processors communicate serially with the same clock polarity, and the two processors can send and receive data at the same time.

(II) I2C method 

 

  SSP can complete all slave functions in I2C mode and provide hardware support for master software implementation. Two pins are used for data transmission: RC3/SCK/SCL (clock) and RC4/SD1/SDA (data). The I2C serial communication of PICI6C64 microcontroller supports 7-bit and 10-bit addressing, and can complete standard and fast data transmission.

  The user can set SSPCON (3: O) to make the I2C operation work in the following modes:

  (1) I2C slave mode (7-bit address).

  (2) I2C slave mode (10-bit address).

  (3) I2C slave mode (7-bit address) and supports master mode,

  (4) I2C slave mode (10-bit address) and supports master mode.

  (5) I2C master mode, not used in slave mode.

  The SSPSTAT register indicates the status of data transmission, including the detection of the STABT and STOP bits, distinguishing between address and data, determining whether the next byte is a 10-bit address, and the direction of data transfer.


Keywords:PIC16C64 Reference address:External functional features of PIC16C64 microcontroller

Previous article:PIC10F200 LED running light program
Next article:IAI wireless module test board based on PIC microcontroller

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号