PIC18F4550 dont start - Page 1
Forum section: electronics / beginners

author: Vindhyachal.takniki
author_rank: Frequent Contributor
timestamp: May 12, 2016, 03:34:37 pm
content: 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 CROProgramming in MCU is done by PICkit3 debugger & software programmer(Beta version) & software version 0.2.0.2Case1: 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>

author: EPTech
author_rank: Regular Contributor
timestamp: May 12, 2016, 05:29:20 pm
content: 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.

author: Skimask
author_rank: Super Contributor
timestamp: May 12, 2016, 06:01:49 pm
content: Quote from: Vindhyachal.takniki on May 12, 2016, 03:34:37 pmHow do you know?QuoteWhich pin?QuoteSection 25.10 of the datasheet

author: Vindhyachal.takniki
author_rank: Frequent Contributor
timestamp: May 13, 2016, 05:58:49 am
content: 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: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: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);

author: EPTech
author_rank: Regular Contributor
timestamp: May 13, 2016, 10:08:45 am
content: 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.

author: Vindhyachal.takniki
author_rank: Frequent Contributor
timestamp: May 13, 2016, 12:17:08 pm
content: I had checked, it is showing dc on both pins