Difference between revisions of "PIC16F684 Registers"

From Mech
Jump to navigationJump to search
 
(5 intermediate revisions by the same user not shown)
Line 48: Line 48:
====TRISC====
====TRISC====
[[image:PIC register TRISC.png|center]]
[[image:PIC register TRISC.png|center]]

===Timers===

====T2CON====
T2CON sets up Timer2, which is used for PWM timing.
[[image:PIC register T2CON.png|center]]

===A/D Configuration and Usage===

When configuring and using the ADC the following functions must be considered:
* Port configuration (ANSEL)
* Channel selection (ADCON0)
* ADC voltage reference selection (ADCON0)
* ADC conversion clock source (ADCON1)
* Interrupt control (INTCON)
* Results formatting (ADCON0)

====ADCON0====
[[image:PIC register ADCON0.png|center]]

====ADCON1====
[[image:PIC register ADCON1.png|center]]


====ADRESH====
ADRESH contains the highest significant digits of the A/D conversion. The values contained in this register depend on whether you select "Right Justified" (ADFM=1) or "Left Justified" (ADFM=0) results.

:'''Right Justified (ADFM=1):'''
[[image:PIC register ADRESHR.png|center]]

:'''Left Justified (ADMF=0):'''
[[image:PIC register ADRESHL.png|center]]

====ADRESL====
ADRESL contains the lowest significant digits of the A/D conversion. The values contained in this register depend on whether you select "Right Justified" (ADFM=1) or "Left Justified" (ADFM=0) results.

:'''Right Justified (ADFM=1):'''
[[image:PIC register ADRESLR.png|center]]

:'''Left Justified (ADMF=0):'''
[[image:PIC register ADRESLL.png|center]]

===PWM Configuration and Usage===
The PWM duty cycle is specified by writing a 10-bit value to multiple registers: CCPR1L register and CCP1<1:0> bits of the CCP1CON register. The CCPR1L contains the eight MSbs and the CCP1<1:0> bits of the CCP1CON register contain the two LSbs.

====CCP1CON====
The CCP1CON register configures PWM output by selecting Single, Half or Full-Bridge modes. These modes were created to make interfacing the PIC16F684 with H-Bridges and Full-Bridges simple.

[[image:PIC register CCP1CON.png|center]]

====CCPR1L====
The CCPR1L register holds the 8 MSbs of the PWM duty cycle. '''If you are using an analog input to determine the duty cycle, you should set up the A/D to be left justified and then all you have to do is copy ADRESH to CCPR1L.'''

====PR2====
The PR2 is an 8-bit register used to set the PWM period. This must be set along with the Timer2 prescale in T2CON. The table below shows the results:

[[image:PIC PWM Frequencies.png|center]]

Latest revision as of 15:38, 11 July 2006

This page is a more detailed overview of the registers. It includes the most commonly used registers. All remaining information can be found on the Microchip website.

Memory Map

These images show the memory map of the PIC16F684. Use these for a quick reference for register addresses and initial values.

Registers in Memory Bank 0

PIC registers bank0.png

Registers in Memory Bank 1

PIC registers bank1.png

Register Descriptions

Configuration

STATUS

PIC register STATUS.png

OPTION

PIC register OPTION.png

INTCON

PIC register INTCON.png

PIE1

The PIE1 is used to enable/disable interrupts.

PIC register PIE1.png

I/O

PORTA

PIC register PORTA.png

TRISA

PIC register TRISA.png

ANSEL

The ANSEL register determines whether a pin, AN<7:0>, is an analog input or not.

PIC register ANSEL.png

IOCA

The IOCA register determines whether or not an interrupt is generated when a digital pin on PORTA, RA<5:0>, experiences a change in value.

PIC register IOCA.png

PORTC

PIC register PORTC.png

TRISC

PIC register TRISC.png

Timers

T2CON

T2CON sets up Timer2, which is used for PWM timing.

PIC register T2CON.png

A/D Configuration and Usage

When configuring and using the ADC the following functions must be considered:

  • Port configuration (ANSEL)
  • Channel selection (ADCON0)
  • ADC voltage reference selection (ADCON0)
  • ADC conversion clock source (ADCON1)
  • Interrupt control (INTCON)
  • Results formatting (ADCON0)

ADCON0

PIC register ADCON0.png

ADCON1

PIC register ADCON1.png


ADRESH

ADRESH contains the highest significant digits of the A/D conversion. The values contained in this register depend on whether you select "Right Justified" (ADFM=1) or "Left Justified" (ADFM=0) results.

Right Justified (ADFM=1):
PIC register ADRESHR.png
Left Justified (ADMF=0):
PIC register ADRESHL.png

ADRESL

ADRESL contains the lowest significant digits of the A/D conversion. The values contained in this register depend on whether you select "Right Justified" (ADFM=1) or "Left Justified" (ADFM=0) results.

Right Justified (ADFM=1):
PIC register ADRESLR.png
Left Justified (ADMF=0):
PIC register ADRESLL.png

PWM Configuration and Usage

The PWM duty cycle is specified by writing a 10-bit value to multiple registers: CCPR1L register and CCP1<1:0> bits of the CCP1CON register. The CCPR1L contains the eight MSbs and the CCP1<1:0> bits of the CCP1CON register contain the two LSbs.

CCP1CON

The CCP1CON register configures PWM output by selecting Single, Half or Full-Bridge modes. These modes were created to make interfacing the PIC16F684 with H-Bridges and Full-Bridges simple.

PIC register CCP1CON.png

CCPR1L

The CCPR1L register holds the 8 MSbs of the PWM duty cycle. If you are using an analog input to determine the duty cycle, you should set up the A/D to be left justified and then all you have to do is copy ADRESH to CCPR1L.

PR2

The PR2 is an 8-bit register used to set the PWM period. This must be set along with the Timer2 prescale in T2CON. The table below shows the results:

PIC PWM Frequencies.png