Difference between revisions of "Microchip PIC"
From Bashlinux
Line 14: | Line 14: | ||
== Configuration Fuses == |
== Configuration Fuses == |
||
==== MPLAB 8.x ==== |
==== MPLAB 8.x ==== |
||
+ | // Configuration Registers |
||
− | __CONFIG(1,HS&CPUDIV1) ; //use external crystal 4M |
||
− | __CONFIG( |
+ | __CONFIG(1,HS&CPUDIV1) ; // Conf Reg 1: Use external crystal 4MHz |
− | __CONFIG( |
+ | __CONFIG(2,WDTDIS) ; // Conf Reg 2: Watchdog off |
+ | __CONFIG(3,PBADDIS) ; // Conf Reg 3: Configure PORTB<4:0> pins as digital I/O on Reset |
||
− | __CONFIG(4,XINSTDIS) ; |
||
+ | __CONFIG(4,XINSTDIS) ; // Conf Reg 4: Extended CPU Enable Disabled |
||
==== MPLAB X v2.35 ==== |
==== MPLAB X v2.35 ==== |
||
− | #pragma config PLLDIV = 1 |
+ | #pragma config PLLDIV = 1 // No prescale (4 MHz oscillator input drives PLL directly |
− | #pragma config CPUDIV = OSC1_PLL2 |
+ | #pragma config CPUDIV = OSC1_PLL2 // [OSC1/OSC2 Src: /1][96 MHz PLL Src: /2] |
− | #pragma config FOSC = HS |
+ | #pragma config FOSC = HS // HS oscillator, HS used by USB |
− | #pragma config WDT = OFF |
+ | #pragma config WDT = OFF // Watchdog off |
− | #pragma config PBADEN = OFF |
+ | #pragma config PBADEN = OFF // Configure PORTB<4:0> pins as digital I/O on Reset |
− | #pragma config XINST = OFF |
||
== SDK/IDEs == |
== SDK/IDEs == |
||
* '''mpide:''' Arduino like IDE for ChipKit & Fubarino |
* '''mpide:''' Arduino like IDE for ChipKit & Fubarino |
||
: http://chipkit.s3.amazonaws.com/index.html |
: http://chipkit.s3.amazonaws.com/index.html |
||
+ | |||
+ | == REFERENCES == |
Revision as of 19:50, 20 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 haveMCLR
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
// Configuration Registers
__CONFIG(1,HS&CPUDIV1) ; // Conf Reg 1: Use external crystal 4MHz __CONFIG(2,WDTDIS) ; // Conf Reg 2: Watchdog off __CONFIG(3,PBADDIS) ; // Conf Reg 3: Configure PORTB<4:0> pins as digital I/O on Reset __CONFIG(4,XINSTDIS) ; // Conf Reg 4: Extended CPU Enable Disabled
MPLAB X v2.35
#pragma config PLLDIV = 1 // No prescale (4 MHz oscillator input drives PLL directly #pragma config CPUDIV = OSC1_PLL2 // [OSC1/OSC2 Src: /1][96 MHz PLL Src: /2] #pragma config FOSC = HS // HS oscillator, HS used by USB #pragma config WDT = OFF // Watchdog off #pragma config PBADEN = OFF // Configure PORTB<4:0> pins as digital I/O on Reset
SDK/IDEs
- mpide: Arduino like IDE for ChipKit & Fubarino