|
|
|
|
EE Design > In Technical
Title: The PIC Microcontrollers Author: Vincent Wong Date: 29th March 2005 Here I have listed some notes on developing with the PIC microcontrollers. The most common PICs that I am using are the 18-pin PIC16F84, 28-pin PIC16F870 and the 40/PLCC-44 pin PIC16F877 or PIC18F452 series. A project that requires low pin count MCU are like the 12C508 & 16F627 are developed using the PIC16F84. Please note that the 16F627 are cheaper for industrial product design compared to the 16F84. It has 2 additional timers, 1 comparator input and many other additional features. However, they are not widely available at local electronic shops. When using PIC16F84 to emulate the 12C508, please note that the address and size of internal RAM (file/registers) are different. The general purpose register (GPR) area for the F84 is from 0x0C to 0x4F. The GPR for 12C508 is from 0x07 to 0x1F. It can be seen that the common GPRs for the c508 and F84 overlaps at 0x0C - 0x1F. For the 16F627, the comparator must be turned off if it is being used as digital I/O like the 16F84. To make all PORTA of 16F627 as I/O ports, we must first turn off the comparator module and enable I/O function:
MOVLW 0X07 MOVWF CMCON ; .. now we can set the direction of port A The scratch pad area (GPRs) for the PIC16F870 is from 0x20 to 0x7F (96 bytes). Please note that when using the 16F87X series the low voltage programming option must be turn off when burning in chip. The comparator must be turned off if PORTA is being used as digital I/Os. The 16F87X series has 4 to 8 ADCs. They must be turned off when PORTA is being used as digital I/Os.
MOVLW 0X06 MOVWF ADCON1 ;All pins at PORTA is digital I/Os ; .. now we can set the direction of port A
MOVLW 0XC1 MOVWF TRISA ;RA0=input, RA1-RA5=output MOVLW 0X0E MOVWF ADCON1 ;RA0=analog input with Vdd & Vss as ref.
__CONFIG _CONFIG2L, 0Eh __CONFIG _CONFIG2H, 0Eh __CONFIG _CONFIG3H, 00h __CONFIG _CONFIG4L, 80h __CONFIG _CONFIG5L, 0Fh __CONFIG _CONFIG5H, 0C0h __CONFIG _CONFIG6L, 0Fh __CONFIG _CONFIG6H, 0E0h __CONFIG _CONFIG7L, 0Fh __CONFIG _CONFIG7H, 40h |