View previous topic :: View next topic |
Author |
Message |
stoyanoff
Joined: 20 Jul 2011 Posts: 375
|
PIC 18F25K50 doesn't accept oscillator FUSE settings |
Posted: Mon Nov 23, 2015 3:22 am |
|
|
Greetings! I'm using Mplab v 8.91, CCS v5.050 and PIC18F25K50! I'm experiencing problems with oscillator settings! The compiler doesn't accept HS, XT, PPL4 and so on settings, in spite of they are in the header! It returns error on compilation! I'm want to use 10MHz quartz!
Can you tell me what to do?!
Thanks! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19492
|
|
Posted: Mon Nov 23, 2015 5:01 am |
|
|
Show us what you are actually trying to use?.
HS, won't exist in the header (HSM, or HSH).
PPL4, again won't exist (PLL4X or PLL3X).
The compiler merrily accepts settings that exist:
Code: |
#include <18F25K50.h>
#fuses PLL4X
#fuses HSM
#use delay(CLOCK=40MHz)
|
|
|
|
stoyanoff
Joined: 20 Jul 2011 Posts: 375
|
|
Posted: Mon Nov 23, 2015 12:03 pm |
|
|
I think I have mixed the header from older compiler with newer! My fault!
Thanks! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19492
|
|
Posted: Mon Nov 23, 2015 12:22 pm |
|
|
Makes sense. Been there.... |
|
|
stoyanoff
Joined: 20 Jul 2011 Posts: 375
|
|
Posted: Thu Nov 26, 2015 11:13 am |
|
|
Can anyone tell me how to activate the internal oscillator? I need those 16MHz to activate the USB...
Thanks! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19492
|
|
Posted: Thu Nov 26, 2015 3:35 pm |
|
|
Have a look at this thread:
<http://www.ccsinfo.com/forum/viewtopic.php?t=54592>
The settings are basically the same. You cannot just use the oscillator, you have to be using ACT (active clock tuning), which effectively phase locks the oscillator onto the external USB clock. |
|
|
stoyanoff
Joined: 20 Jul 2011 Posts: 375
|
|
Posted: Thu Dec 03, 2015 2:48 am |
|
|
Hi, again! I`m experiencing problems with enabling of the PLL.
Here are my fuse settings!
Code: |
#fuses NOWDT
#fuses PLLEN
#fuses PLL4X
#fuses HSM
#fuses NOCPUDIV
|
I have 12MHz quartz attached and I`m expecting 48MHz clock
Code: |
#use delay(CLOCK=48M)
|
The problem is I`m recieving only 12!
Where is the problem?! Thanks! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19492
|
|
Posted: Thu Dec 03, 2015 3:44 am |
|
|
For a crystal, you can only use the PLL, with HSH (don't know why..). This is shown in table 3-1. The PLL won't actually enable, unless the FOSC bits are 010x, 0010, or 100x.
So you have to select HSH (even though it is not recommended for 12MHz...).
You should also explicitly enable the primary oscillator:
Code: |
#fuses NOWDT
#fuses PLLEN
#fuses PLL4X
#fuses HSH
#fuses NOCPUDIV
#fuses PRIMARY
|
|
|
|
stoyanoff
Joined: 20 Jul 2011 Posts: 375
|
|
Posted: Thu Dec 03, 2015 6:02 am |
|
|
Thanks! Now the speed is fine!
I`m trying to make a simple program base on ex_usb_hid.c example! My controller doesn`t have a PIN_USB_SENSE so I set it to a pin which is always high! I have a delay of 5s at the begging of the program! Still I can`t detect it on a PC! I`ve tried with WIN XP and 7!
The main cycle is running, but there is nothing on the other side of the line -> no USB connected!
I`m using female USB connector and here are my connections:
connector pin(left to right) - > controller pin
pin 1 -> pin 14 (Vusb3V3)(this pin is not connected to the Vcc of the PCB, I think this is right)
pin 2 -> PIN_15(D-)
pin 3 -> PIN_16(D+)
pin 4 -> GND
I don`t think I`ve made a mistake with the pcb, but just in case!
Can you tell me what I`m doing wrong?!
Thanks! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19492
|
|
Posted: Thu Dec 03, 2015 8:38 am |
|
|
Are you running the F, or the LF chip?.
Vusb, does need to be connected to a 3.3v source. Can be from the PIC supply, or using a regulator from the USB.
Key is that on 'high voltage' PIC's (5v - so the 'F; variant, running off at least 4.2v), they have an internal regulator to drive this pin. On 'low voltage' PIC's (3.3v etc. - the LF variant), this has to be driven by you.
It requires a capacitor with a good HF performance. Typically something like 0.47uF polyester. Not a aluminium electrolytic.
The USB 5v connection, _must not connect directly to the PIC. It can be used to feed the whole circuit, or with a suitable resistor network to feed the sense pin. If you are feeding this directly into Vusb 3.3, then you are overvoltaging the USB transceivers. The USB provides 5v power, but runs off 3.3v.
Look at Fig 24.1. Note how the VUSB3.3, is fed either from the internal regulator, with the note "PIC18F2X/45K50 devices only", or from an external regulator. _not_ from the USB 5v.
USB_SENSE, is actually required by the USB specifications, unless the device is powered from the USB.... However you can run without it, by just using:
#define USB_CABLE_IS_ATTACHED() TRUE
The device will fail to re-attach, if the PC goes into deep suspend mode, and powers down the connection. You need to ensure the power settings on the PC involved do not allow this. Much better to have the pin connected.... |
|
|
stoyanoff
Joined: 20 Jul 2011 Posts: 375
|
|
Posted: Thu Dec 03, 2015 10:30 am |
|
|
If I understood you right, you are telling me to break USB pin 1 and Vusb3V3 connection and to connect Vusb to 4.2V?! Is that right?!
Thanks! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19492
|
|
Posted: Thu Dec 03, 2015 12:04 pm |
|
|
No!.....
You may well have blown the transceivers. This pin requires 3.3v.
You are trying to feed the 3.3v transceivers off 5v....
If you have the F variant, and are running off a supply of 4.2v or more, there is an internal regulator from the supply, that will generate 3.3v on this pin for you. All it needs is the capacitor.
On the LF variant there is no internal regulator, and _you_ have to supply the pin with 3.3v.
This is one of those 'hidden complexities', since the chips can both run off voltages well below the USB voltages needed. The Vusb requires 3v minimum, and 3.6v max. The internal regulator needs 4.2v minimum, but the chip can run well below this..... |
|
|
stoyanoff
Joined: 20 Jul 2011 Posts: 375
|
|
Posted: Thu Dec 03, 2015 12:29 pm |
|
|
OK! See I`m using F version! So I think I haven`t blown anything! So I`ll disconnect this pin and attach a small cap. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19492
|
|
Posted: Fri Dec 04, 2015 2:18 am |
|
|
You have still been pushing 5v, into a pin with a max rating of 3.6v.
However the transceivers are fairly rugged, so may well have survived.
Fortunately the regulator would have just switched off, when the voltage went above 3.3v. However if the USB was attached, when the unit was switched off, the regulator would have been reverse biased, and trying to power the board from the USB, 'backwards' through the regulator.... |
|
|
|