Difference between revisions of "Microchip PIC"

From Bashlinux
Jump to: navigation, search
Line 1: Line 1:
  +
__NOTOC__
 
== Cautions ==
 
== Cautions ==
 
'''Config'''<br>
 
'''Config'''<br>
Line 10: Line 11:
 
* ALWAYS set the input pins and clear the output pins, excepting UART TX/RX.
 
* ALWAYS set the input pins and clear the output pins, excepting UART TX/RX.
 
i.e. SDO should have TRISX bit cleared, SDI should have TRISX bit set.
 
i.e. SDO should have TRISX bit cleared, SDI should have TRISX bit set.
  +
  +
== Configuration Fuses ==
  +
==== MPLAB 8.x ====
  +
__CONFIG(1,HS&CPUDIV1) ; //use external crystal 4M
  +
__CONFIG(2,WDTDIS) ; //wtd off
  +
__CONFIG(3,PBADDIS) ; //Configure PORTB<4:0> pins as digital
  +
__CONFIG(4,XINSTDIS) ;
  +
  +
==== MPLAB X v2.35 ====
  +
#pragma config PLLDIV = 1
  +
#pragma config CPUDIV = OSC1_PLL2
  +
#pragma config FOSC = HS
  +
#pragma config WDT = OFF
  +
#pragma config PBADEN = OFF
  +
#pragma config XINST = OFF

Revision as of 23:59, 11 June 2015

Cautions

Config

  • NEVER disable the PIC's /MCLR (Reset) pin function
  • NEVER program a PIC "in circuit" with ANY other connections to the target board

Circuit Design

  • ALWAYS set MCLRE_ON in the config options and have MCLR pin with a 10K pull-up resistor to Vdd.

Initialization

  • ALWAYS set the input pins and clear the output pins, excepting UART TX/RX.
i.e. SDO should have TRISX bit cleared, SDI should have TRISX bit set.

Configuration Fuses

MPLAB 8.x

__CONFIG(1,HS&CPUDIV1) ;  //use external crystal 4M
__CONFIG(2,WDTDIS) ;      //wtd off
__CONFIG(3,PBADDIS) ;     //Configure PORTB<4:0> pins as digital
__CONFIG(4,XINSTDIS) ;

MPLAB X v2.35

#pragma config PLLDIV = 1
#pragma config CPUDIV = OSC1_PLL2
#pragma config FOSC = HS
#pragma config WDT = OFF
#pragma config PBADEN = OFF
#pragma config XINST = OFF