Jump to content

Recommended Posts

Hi,

 

I have spent half my day trying to get a new board with an 18F4550 up and running. All I have on the board at this point is power, the clock and the ICD2 connector. I'm using the dedicated ICPORT to program the device. I can program the device just fine, but the PIC just doesn't seem to want to wake up. I have had the PIC flash an LED a couple times, but it doesn't seem to be consistent.

 

This is a new chip to me, so I'm not sure if maybe I have something screwed up in the config bits.

 

Can anybody see anything wrong in my config bits here? I know this is a big question, but is there something else that could be holding the PIC in a reset state or something?

 

Painfully,

 

Dan

 

 

// Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0

// CONFIG1L — — USBDIV CPUDIV1 CPUDIV0 PLLDIV2 PLLDIV1 PLLDIV0

// 0 0 0 0 0 0 0 0

 

#pragma DATA _CONFIG1L, 0x00

 

// Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0

//CONFIG1H IESO FCMEN — — FOSC3 FOSC2 FOSC1 FOSC0

// 0 0 0 0 0 1 1 0

 

#pragma DATA _CONFIG1H, 00000110b // Set PortA bit 6 to RA6.

 

// Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0

// CONFIG2L — — VREGEN BORV1 BORV0 BOREN1 BOREN0 PWRTEN

#pragma DATA _CONFIG2L, 00000001b

 

 

// Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0

// CONFIG2H — — — WDTPS3 WDTPS2 WDTPS1 WDTPS0 WDTEN

// 0 0 0 1 1 0 0 1

#pragma DATA _CONFIG2H, 00011000b // WDTEN = 1 = enabled

 

// Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0

// CONFIG3H MCLRE — — — — LPT1OSC PBADEN CCP2MX

// 0 0 0 0 0 1 0 1

#pragma DATA _CONFIG3H, 00000101b

 

// ~DEBUG = Background debugger. 1 = RB6 and RB7 are general purpose I/O

// XINST = Extended instruction set enable

// ICPRT = Dedicated ICD port enable

// LVP = Low voltage programming enabled.

// STVREN = Stack overflow reset enable.

 

// Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0

// CONFIG4L DEBUG XINST ICPRT — — LVP — STVREN

// 0 0 1 0 0 0 0 1

 

#pragma DATA _CONFIG4L, 10100001b

 

#pragma DATA _CONFIG5L, 0x0F

#pragma DATA _CONFIG5H, 0xC0

#pragma DATA _CONFIG6L, 0x0F

#pragma DATA _CONFIG6H, 0xE0

#pragma DATA _CONFIG7L, 0x0F

#pragma DATA _CONFIG7H, 0x40

Link to post
Share on other sites

I got it working. I set the oscillator bits...

 

From this:

0110 = EC oscillator, PLL enabled, port function on RA6 (ECPIO)

 

To this:

0100 = EC oscillator, port function on RA6 (ECIO)

 

I don't know why this makes it work, but at least it is now, so I can at least have one configuration that does something.

Link to post
Share on other sites
I got it working. I set the oscillator bits...

 

From this:

0110 = EC oscillator, PLL enabled, port function on RA6 (ECPIO)

 

To this:

0100 = EC oscillator, port function on RA6 (ECIO)

 

I don't know why this makes it work, but at least it is now, so I can at least have one configuration that does something.

 

The PLL multiplies the clock signal by 4. It maybe that with th ePLL enabled the resuting clock is too fast.

Link to post
Share on other sites
  • 2 weeks later...

Picixe, danmc77,

 

The PLL in the 18F4550 is a little more finicky. It is designed to multiply a 4MHz input to 96MHz. This is a 24x multiply.

 

For this PLL to work well the input must be very close to 4MHz. Anything faster or slower runs the risk fo the PLL locking on to an alias of 4MHz.

 

When using the PLL you are limited to crystals or oscillators that are 4MHz multiples of the PLL Prescaler selections of divides by 1, 2 , 3, 4, 5, 6, 10, and 12. This means frequencies of 4, 8, 12, 16, 20, 24, 40 and 48 MHz. If your crystal is not one of these then the PLL may not work.

 

If you are going to use USB then you must use the Primary oscillator at one of those frequencies and set the PLLDIV configuration bits correctly.

Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...