Difference between revisions of "Microchip PIC"

From Bashlinux
Jump to: navigation, search
(Configuration Fuses)
 
(4 intermediate revisions by the same user not shown)
Line 2: Line 2:
 
== Cautions ==
 
== Cautions ==
 
'''Config'''<br>
 
'''Config'''<br>
* NEVER disable the PIC's <code>/MCLR</code> (Reset) pin function
+
* NEVER disable the PIC's <tt>/MCLR</tt> (Reset) pin function.
* NEVER program a PIC "in circuit" with ANY other connections to the target board
+
* NEVER program a PIC "in circuit" with ANY other connections to the target board.
   
 
'''Circuit Design'''<br>
 
'''Circuit Design'''<br>
* ALWAYS set <code>MCLRE_ON</code> in the config options and have <code>MCLR</code> pin with a 10K pull-up resistor to Vdd.
+
ALWAYS set <tt>MCLRE_ON</tt> in the config options and have <tt>MCLR</tt> pin with a 10K pull-up resistor to Vdd.
   
 
'''Initialization'''<br>
 
'''Initialization'''<br>
* 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.
i.e. SDO should have TRISX bit cleared, SDI should have TRISX bit set.
+
* SDO should have <tt>TRISX</tt> bit cleared
  +
* SDI should have <tt>TRISX</tt> bit set.
   
 
== Configuration Fuses ==
 
== Configuration Fuses ==
'''HI-TECH C (MPLAB 8.x)'''<br>
+
'''HI-TECH PICC (MPLAB IDE v8.x)'''<br>
 
__CONFIG(1,HS&CPUDIV1) ; // Conf Reg 1: Use external crystal 4MHz
 
__CONFIG(1,HS&CPUDIV1) ; // Conf Reg 1: Use external crystal 4MHz
 
__CONFIG(2,WDTDIS) ; // Conf Reg 2: Watchdog off
 
__CONFIG(2,WDTDIS) ; // Conf Reg 2: Watchdog off
Line 19: Line 21:
 
__CONFIG(4,XINSTDIS) ; // Conf Reg 4: Extended CPU Enable Disabled
 
__CONFIG(4,XINSTDIS) ; // Conf Reg 4: Extended CPU Enable Disabled
   
'''XC8 (MPLAB X 2.x/3.x)'''<br>
+
'''MPLAB XC (MPLAB X v2.x/v3.x)'''<br>
#pragma config PLLDIV = 1 // No prescale (4 MHz oscillator input drives PLL directly
+
#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 WDT = OFF // Watchdog off
 
#pragma config PBADEN = OFF // Configure PORTB<4:0> pins as digital I/O on Reset
 
#pragma config PBADEN = OFF // Configure PORTB<4:0> pins as digital I/O on Reset
 
#pragma config CPUDIV = OSC1_PLL2 // [OSC1/OSC2 Src: /1][96 MHz PLL Src: /2]
 
#pragma config FOSC = HS // HS oscillator, HS used by USB
  +
  +
== Development boards ==
  +
* [https://www.microchip.com/en-us/development-tools-tools-and-software/development-boards-and-hardware Product-spscific boards] - 8-bit, 16-bit, and 32-bit Explorer boards and development kits
  +
* [https://www.microchip.com/en-us/development-tools-tools-and-software/development-boards-and-hardware/curiosity-boards Curiosity boards] - Rapid prototyping boards for first-time users
  +
* [https://store.digilentinc.com/digilent-system-boards-and-components/ Digilent] - Training board with peripherals and prototyping area
   
 
== IDEs ==
 
== IDEs ==
 
* [http://www.microchip.com/archived MPLAB] - Discontinued Microchip's IDE
 
* [http://www.microchip.com/archived MPLAB] - Discontinued Microchip's IDE
 
* [http://www.microchip.com/mplabx/ MPLAB X] - Official's Microchip IDE
 
* [http://www.microchip.com/mplabx/ MPLAB X] - Official's Microchip IDE
* [http://chipkit.s3.amazonaws.com/index.html MPIDE] - Arduino like IDE for ChipKit & Fubarino
+
* [https://uecide.org/ UECIDE] - Alternative to Arduino IDE with support for chipKIT

Latest revision as of 07:58, 8 June 2021

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

HI-TECH PICC (MPLAB IDE v8.x)

__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 XC (MPLAB X v2.x/v3.x)

#pragma config PLLDIV = 1          // No prescale (4 MHz oscillator input drives PLL directly)
#pragma config WDT = OFF           // Watchdog off
#pragma config PBADEN = OFF        // Configure PORTB<4:0> pins as digital I/O on Reset
#pragma config CPUDIV = OSC1_PLL2  // [OSC1/OSC2 Src: /1][96 MHz PLL Src: /2]
#pragma config FOSC = HS           // HS oscillator, HS used by USB

Development boards

IDEs

  • MPLAB - Discontinued Microchip's IDE
  • MPLAB X - Official's Microchip IDE
  • UECIDE - Alternative to Arduino IDE with support for chipKIT