20 December 2010

list of errors in PIC

LIST OF Most common errors with PICs

You are lost with your PIC, because you can't get it work, or it works... sometimes ?

This page will help you to solve the problem.

The first common error with PIC is to not read its datasheet. So for once, find your PIC in this list and open its datasheet : you will need it.
Then, read this carefully :

 

Q : my PIC does not work, or works partially, some modules or PORTs do not work, oscillator does not start or is not stable.

A : The PIC is not correctly POWERED.

  • Check if your chip is correctly powered : some PICs have more than one Vcc and Vdd pins
  • Check the voltage vs oscillator : highest clock frequency may not work with lowest voltage
  • Add a 100nF capacitor as close as possible to the PIC to each Vcc and Vdd pair of pins

 

Q : my PIC works partially, does not start, or stops at any time, works only if I approach my hand or a screwdriver, or resets at any time.

A: the CONFIGURATION FLAGS are not fitted to your hardware.

  • Check with your programmer your configuration flags : they may be set correctly in your project settings, but not included in your .HEX file, and then not be written in the PIC.
  • Check your OSCILLATOR FLAG : it must fit to your hardware. Here is a little summary of most common oscillator configurations (some of them may be not available on your PIC !) :
    • LP : low power, use a low frequency crystal (32.768 Khz for example)
    • XT : crystal or resonator, up to 4 Mhz
    • HS : high speed crystal, up to 20 Mhz (PIC12 & PIC16) and up to 10 Mhz (PIC18)
    • EXTRC : external RC connected to Fin, Fout is oscillator output
    • EXTRCIO : external RC connected to Fin, Fout is PORT I/O
    • INTRC : internal RC, Fin and Fout are reserved to oscillator
    • INTRCIO : internal RC, Fin and Fout are available for PORT I/O
    • EC : external clock, connect an oscillator to Fin, Fout is oscillator output
    • ECIO : external cloc, connect an oscillator to Fin, Fout is PORT I/O
    • PLL suffix : PIC internal 4x PLL is enabled (for example : HSPLL, ECPLL...)
  • Check your BROWN OUT DETECT & VOLTAGE : if enabled, the brown out voltage must be higher than normal operation voltage
  • Check your MASTER CLEAR enable bit : 
    • If set, the /MCLR pin must be connected to a reset circuit or tied to the Vcc.
    • If not set, /MCLR is an INPUT pin.
  • Check your LOW VOLTAGE PROGRAM enable bit :
    • If set, you can't use PGM, PGC and PGD pins as I/O pins, they are reserved for programming the chip.
    • If not set, you can use PGM, PGC and PGD pin as I/O pins, but you can't use low voltage programming.

 

Q : I can't get the expected PWM frequency I want, I can't get the expected timer period I want, my delays do not work.

A: Check if your PIC is correctly clocked :

  • Check configuration flags (see above)
  • You can't use a 40 Mhz crystal with a PIC18 : use a 10 Mhz crystal with 4 x PLL enabled
  • Your PIC may be overclocked (for example you are using a 4 Mhz PIC16F84A with a 20 Mhz crystal)
  • Configure the OSCCON register if there is one in your PIC

 

Q : my PIC does not start, or hangs, or resets.

A : the CONFIGURATION FLAGS are not fitted to your software.

  • If your PIC does not start, check the ICD (In-circuit debugger) flag :
    • If set, your program can't run in stand-alone mode, the PIC is in in-circuit debugging mode
    • If not set, your program runs normally, but you can't debug with ICD
  • If you suspect your PIC to reset, check the WATCHDOG TIMER flag :
    • If set, you have to clear the watchdog timer by software before a rollover occurs. If you don't, your PIC will reset.
    • If not set, you don't have to deal with watchdog timer, but your program may lock in an infinite loop. 
  • If your PIC hangs, check the EXTENDED INSTRUCTION SET flag :
    • If set, your program (or your compiler) must take it into account to use the correct addressing methods.
    • If not set, your program (or your compiler) must use standard addressing modes.

 

Q : PORTA is not working, PORTE is not working, GPIO is not working

A : Most PICs have PORTA (GPIO) and PORTE digital I/O multiplexed with analog I/O. Check registers related to :

  • comparators : CMCON registers
  • A/D converters ADCON and ANSEL registers
  • voltage reference module CVRCON registers

 

Q : PORTA is not working, GPIO is not working

A : Most PICs have /MCLR reset pin multiplexed with a PORTA (GPIO) pin : if you want to use this pin as I/O, the MASTER CLEAR configuration must not be set. In this case the corresponding PORTA (GPIO) pin can be use as digital INPUT only.

 

Q : RA4 is not working

A : Some PICs have RA4 with open drain output instead of CMOS output ! Connect a pull-up resistor to the output and reverse RA4 logic control.

  

Q : PORTB is not working

A : Some PICs have PORTB digital I/O multiplexed with analog I/O.

  • Check registers related to A/D converters : ADCON and ANSEL registers
  • Check configuration flag PORTB A/D ENABLE BIT

 

Q : PORTD is not working

A : most PICs can turn PORTD into a parallel port.

  • Check TRISE PSPMODE bit.

0 comments:

Post a Comment

Related Posts with Thumbnails

Popular Posts

 
;