Author Topic: PIC18F4550 dont start  (Read 1933 times)

0 Members and 1 Guest are viewing this topic.

Offline Vindhyachal.taknikiTopic starter

  • Frequent Contributor
  • **
  • Posts: 487
PIC18F4550 dont start
« on: May 12, 2016, 03:34:37 pm »


I have connected used PIC18F4550 in one of project. Problem is PIC never start up.
In start of code in main function, i have toggled a pin continuously.
I want my system freq to be of 4Mhz. There is no USB used. Using Hi-tech PICC18-PRO V9.80 with MPLABX.
I think its configuration bits issues. Tried external osc & then internal osc but sysem never runs. Voltage at reset pin is +5V & vdd pin is +5V. Both vdd & Vss are connected.I have checked on CRO

Programming in MCU is done by PICkit3 debugger & software programmer(Beta version) & software version 0.2.0.2

Case1: 4Mhz crystal is connected with 22pF load caps.
<code>
//#pragma config CONFIG1L = 0x0
__CONFIG(1, PLLDIV_1 & CPUDIV_OSC1_PLL2 & USBDIV_1);
//#pragma config CONFIG1H = 0x0
__CONFIG(2, FOSC_XT_XT & FCMEN_OFF & IESO_OFF);
//#pragma config CONFIG2L = 0x3E
__CONFIG(3, PWRT_ON & BOR_ON & BORV_3 & VREGEN_ON);
//#pragma config CONFIG2H = 0x1E
__CONFIG(4, WDT_OFF & WDTPS_32768);
//#pragma config CONFIG3H = 0x81
__CONFIG(5, CCP2MX_ON & PBADEN_OFF & LPT1OSC_OFF & MCLRE_ON);
//#pragma config CONFIG4L = 0x85
__CONFIG(6, STVREN_ON & LVP_ON & ICPRT_OFF & XINST_OFF);
//#pragma config CONFIG5L = 0x0
__CONFIG(7, CP0_ON & CP1_ON & CP2_ON & CP3_ON);
//#pragma config CONFIG5H = 0xC0
__CONFIG(8, CPB_OFF & CPD_OFF);
//#pragma config CONFIG6L = 0xF
__CONFIG(9, WRT0_OFF & WRT1_OFF & WRT2_OFF & WRT3_OFF);
//#pragma config CONFIG6H = 0xE0
__CONFIG(10, WRTC_OFF & WRTB_OFF & WRTD_OFF);
//#pragma config CONFIG7L = 0xF
__CONFIG(11, EBTR0_OFF & EBTR1_OFF & EBTR2_OFF & EBTR3_OFF);
//#pragma config CONFIG7H = 0x40
__CONFIG(12, EBTRB_OFF);
</code>

Case2: Internal 8Mhz osc
<code>
//#pragma config CONFIG1L = 0x29
__CONFIG(1, PLLDIV_2 & CPUDIV_OSC2_PLL3 & USBDIV_2);
//#pragma config CONFIG1H = 0x89
__CONFIG(2, FOSC_INTOSC_EC & FCMEN_OFF & IESO_ON);
//#pragma config CONFIG2L = 0x3E
__CONFIG(3, PWRT_ON & BOR_ON & BORV_3 & VREGEN_ON);
//#pragma config CONFIG2H = 0x1E
__CONFIG(4, WDT_OFF & WDTPS_32768);
//#pragma config CONFIG3H = 0x81
__CONFIG(5, CCP2MX_ON & PBADEN_OFF & LPT1OSC_OFF & MCLRE_ON);
//#pragma config CONFIG4L = 0x85
__CONFIG(6, STVREN_ON & LVP_ON & ICPRT_OFF & XINST_OFF);
//#pragma config CONFIG5L = 0x0
__CONFIG(7, CP0_ON & CP1_ON & CP2_ON & CP3_ON);
//#pragma config CONFIG5H = 0xC0
__CONFIG(8, CPB_OFF & CPD_OFF);
//#pragma config CONFIG6L = 0xF
__CONFIG(9, WRT0_OFF & WRT1_OFF & WRT2_OFF & WRT3_OFF);
//#pragma config CONFIG6H = 0xE0
__CONFIG(10, WRTC_OFF & WRTB_OFF & WRTD_OFF);
//#pragma config CONFIG7L = 0xF
__CONFIG(11, EBTR0_OFF & EBTR1_OFF & EBTR2_OFF & EBTR3_OFF);
//#pragma config CONFIG7H = 0x40
__CONFIG(12, EBTRB_OFF);
</code>
 

Offline EPTech

  • Regular Contributor
  • *
  • Posts: 168
  • Country: be
    • EP Technical Services
Re: PIC18F4550 dont start
« Reply #1 on: May 12, 2016, 05:29:20 pm »
Hi there,

I do not know how experienced you are,so this may be a stupid suggestion. Have you checked whether the programmer is holding the PIC in reset after programming. It is an option in the Microchip IPE. I do not know where is is in MPLAB X.

Is the Crystal or the oscillator oscillating?
Some PICs need an external capacitor for the internal voltage regulator that, I believe, also supplies the PLL and clock circuitry.

Good hunting.
Kind greetings,

Pascal.
 

Offline Skimask

  • Super Contributor
  • ***
  • Posts: 1433
  • Country: us
Re: PIC18F4550 dont start
« Reply #2 on: May 12, 2016, 06:01:49 pm »
I have connected used PIC18F4550 in one of project. Problem is PIC never start up.
How do you know?

Quote
In start of code in main function, i have toggled a pin continuously.
Which pin?

Quote
//#pragma config CONFIG4L = 0x85
__CONFIG(6, STVREN_ON & LVP_ON & ICPRT_OFF & XINST_OFF);
Section 25.10 of the datasheet
I didn't take it apart.
I turned it on.

The only stupid question is, well, most of them...

Save a fuse...Blow an electrician.
 

Offline Vindhyachal.taknikiTopic starter

  • Frequent Contributor
  • **
  • Posts: 487
Re: PIC18F4550 dont start
« Reply #3 on: May 13, 2016, 05:58:49 am »
I have tried below setting for internal oscillator & code was running. In mian code I have toggled a pin with certain delay.
Although delay was not accurate. I think that because OSCCON is set to default.
On single stepping into code by mplab I was able to debug code.

But when I tried using 4Mhz external oscilltor again code not run.
Below are setting fro external 4Mhz crystal. I have put DMM on OSC1 & OSC2 it comes out to arounf 2.1V.
But I have put CRO probe across it there is no sine wave just dc across two.

Code: [Select]
Config setting for internal osc which is working, pin is toggling:

//#pragma config CONFIG1L = 0x29
__CONFIG(1, PLLDIV_2 & CPUDIV_OSC2_PLL3 & USBDIV_2);
//#pragma config CONFIG1H = 0x89
__CONFIG(2, FOSC_INTOSC_EC & FCMEN_OFF & IESO_ON);
//#pragma config CONFIG2L = 0x3E
__CONFIG(3, PWRT_ON & BOR_ON & BORV_3 & VREGEN_ON);
//#pragma config CONFIG2H = 0x1E
__CONFIG(4, WDT_OFF & WDTPS_32768);
//#pragma config CONFIG3H = 0x81
__CONFIG(5, CCP2MX_ON & PBADEN_OFF & LPT1OSC_OFF & MCLRE_ON);
//#pragma config CONFIG4L = 0x85
__CONFIG(6, STVREN_ON & LVP_OFF & ICPRT_OFF & XINST_OFF);
//#pragma config CONFIG5L = 0x0
//__CONFIG(7, CP0_ON & CP1_ON & CP2_ON & CP3_ON);
//#pragma config CONFIG5H = 0xC0
__CONFIG(8, CPB_OFF & CPD_OFF);
//#pragma config CONFIG6L = 0xF
__CONFIG(9, WRT0_OFF & WRT1_OFF & WRT2_OFF & WRT3_OFF);
//#pragma config CONFIG6H = 0xE0
__CONFIG(10, WRTC_OFF & WRTB_OFF & WRTD_OFF);
//#pragma config CONFIG7L = 0xF
__CONFIG(11, EBTR0_OFF & EBTR1_OFF & EBTR2_OFF & EBTR3_OFF);
//#pragma config CONFIG7H = 0x40
__CONFIG(12, EBTRB_OFF);


Code: [Select]
config setting for external 4Mhz osc, which is not working:

__CONFIG(1, PLLDIV_1 & CPUDIV_OSC1_PLL2 & USBDIV_2);
//#pragma config CONFIG1H = 0x0
__CONFIG(2, FOSC_XT_XT & FCMEN_OFF & IESO_OFF);
//#pragma config CONFIG2L = 0x3E
__CONFIG(3, PWRT_ON & BOR_ON & BORV_3 & VREGEN_ON);
//#pragma config CONFIG2H = 0x1E
__CONFIG(4, WDT_OFF & WDTPS_32768);
//#pragma config CONFIG3H = 0x81
__CONFIG(5, CCP2MX_ON & PBADEN_OFF & LPT1OSC_OFF & MCLRE_ON);
//#pragma config CONFIG4L = 0x81
__CONFIG(6, STVREN_ON & LVP_OFF & ICPRT_OFF & XINST_OFF);
//#pragma config CONFIG5L = 0xF
//__CONFIG(7, CP0_OFF & CP1_OFF & CP2_OFF & CP3_OFF);
//#pragma config CONFIG5H = 0xC0
__CONFIG(8, CPB_OFF & CPD_OFF);
//#pragma config CONFIG6L = 0xF
__CONFIG(9, WRT0_OFF & WRT1_OFF & WRT2_OFF & WRT3_OFF);
//#pragma config CONFIG6H = 0xE0
__CONFIG(10, WRTC_OFF & WRTB_OFF & WRTD_OFF);
//#pragma config CONFIG7L = 0xF
__CONFIG(11, EBTR0_OFF & EBTR1_OFF & EBTR2_OFF & EBTR3_OFF);
//#pragma config CONFIG7H = 0x40
__CONFIG(12, EBTRB_OFF);
 

Offline EPTech

  • Regular Contributor
  • *
  • Posts: 168
  • Country: be
    • EP Technical Services
Re: PIC18F4550 dont start
« Reply #4 on: May 13, 2016, 10:08:45 am »
Hi There,

Try probing from ground to either pin of the crystal, not across the crystal. Does it oscillate. Have you chosen the correct loading capacitors on the crystal. It should be stated somewhere in the data sheet.

Good hunting.
Kind greetings,

Pascal.
 

Offline Vindhyachal.taknikiTopic starter

  • Frequent Contributor
  • **
  • Posts: 487
Re: PIC18F4550 dont start
« Reply #5 on: May 13, 2016, 12:17:08 pm »
I had checked, it is showing dc on both pins
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf