View previous topic :: View next topic |
Author |
Message |
stoyanoff
Joined: 20 Jul 2011 Posts: 375
|
PIC18F66J60 is running very slowly |
Posted: Mon Oct 19, 2015 3:32 am |
|
|
Greetings! I have PIC18F66J60 on a pcb with 25MHz quartz. The problem is it's running very slowly. I'm conducting a blink test:
Code: |
#include <18F66J65.h>
#fuses NOWDT,HS
#use delay(clock=25M)
void main()
{
output_drive(PIN_A1);
while(1)
{
output_high(PIN_A1);
delay_ms(1000);
output_low(PIN_A1);
delay_ms(1000);
}
}
|
Till now I've changed the quartz with new one and the Vcap. No change!
Any other suggestions?
Thanks!
PP: I have two PCBs with the same problem! I think it`s not a hardware problem! I`m using Pic Kit 2(I have 3 too if that is a problem), MPlab v 8.91 and CCS v5.024! |
|
|
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Mon Oct 19, 2015 6:33 am |
|
|
Hi,
You have threads going back 4 years on this very chip, so you should be very familiar with it! Is this the the first time you've actually tried the classic 'LED flash' test? If not, then you need to tell us what is different from the previous four years!! New board, new compiler, what???
You should also tell us what 'very slowly' means! In other words what was the observed flash rate?
Undoubtedly, your main oscillator is not running, and is falling back to the fail safe. Add the NOFCMEN fuse to verify! _________________ John
If it's worth doing, it's worth doing in real hardware! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19477
|
|
Posted: Mon Oct 19, 2015 8:21 am |
|
|
The obvious 'expectation' would be for it to possibly run about 1/800th the speed...
By default FCMEN is enabled. So if the crystal does not start, the chip will run off the 31KHz internal oscillator. These chips are quite critical of their crystals, especially using one right at the maximum supported frequency. So what is the make of crystal, what load capacitors are you using, and parallel resistance, etc. etc.?. |
|
|
stoyanoff
Joined: 20 Jul 2011 Posts: 375
|
|
Posted: Mon Oct 19, 2015 10:30 am |
|
|
Here is the datasheet of the quartz Click
I'm using 15pF caps. They are close to the chip. I don't have parallel resistance.
I've noticed sometimes the chip works fine, sometimes doesn't! May be the crystal can't start! What do I have to do? How can I check Congig2L register?!
I haven't use this chip for a while. This is a new schematic! I'm sorry if I have forgotten!
Thanks! |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Oct 19, 2015 10:55 am |
|
|
Did you possibly buy the third overtone crystal instead of the fundamental one ?
That could explain your problem.
You didn't tell us the manufacturer or part number of your crystal.
Also, if even if you did give us the part number, the data sheet doesn't
provide a description of the part number elements. For example, down
at the bottom of this ECS data sheet, it shows the components of a ECS
crystal part number:
http://ecsxtal.com/store/pdf/hc-49usx.pdf |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19477
|
|
Posted: Mon Oct 19, 2015 11:34 am |
|
|
Try a little experiment.
Put a 1MR resistor straight across the crystal.
The chip has an internal resistor, that is 'meant' to help start the crystal, but if the gain of your one is rather low, it may not be enough to get it to start. Microchip have an application note suggesting trying the resistor to help the crystal start.
If it starts working reliably, you need to consider either adding a resistor permanently, or changing to a crystal which is a closer match to the ones suggested by Microchip. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9215 Location: Greensville,Ontario
|
|
Posted: Tue Oct 20, 2015 5:16 am |
|
|
Another potential way it'll run slooooow, is to have programmed the chip with MPLAB in 'DEBUG' mode and not 'Release' mode.
The default has always been 'debug' so you have to change that to 'release'.
Just something else to look at !
Jay |
|
|
stoyanoff
Joined: 20 Jul 2011 Posts: 375
|
|
Posted: Fri Oct 23, 2015 4:54 am |
|
|
Hi! Just for the record! I have MCP2515 connected to the controller. I can't make it work this time! I always receive error - RXEP or TXEP flag. I think everything is connected fine. Could it be the same problem with the quartz?
I'm using 10MHz quartz with 2x15pF caps!
Thanks! |
|
|
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Fri Oct 23, 2015 9:42 am |
|
|
stoyanoff,
Come on, what about the previous issue you reported? Did you ever get that to work? How can you expect us to remain interested in helping you when you jump from one problem to another without any feedback about past problems?
Is your PIC running correctly? Can you perform the classic 'LED flash' test and verify that the PIC is running at the correct speed? Can you send data successfully from the UART? If so, any problems you now face are unlikely to be related to the 'quartz'..... _________________ John
If it's worth doing, it's worth doing in real hardware! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19477
|
|
Posted: Fri Oct 23, 2015 10:14 am |
|
|
Also, '10MHz quartz', is _not_ a crystal specification. It's like saying 'a motor car'. There are literally dozens of different crystal cuts, and as PCM_Programmer has pointed out, it might well be an overtone crystal. You need a full part number and manufacturer. |
|
|
wangine
Joined: 07 Jul 2009 Posts: 98 Location: Curtea de Arges, Romania
|
|
Posted: Mon Oct 26, 2015 2:19 pm |
|
|
I just look random in the forum and some comments take my attention, I'm really confused now. The above function
Code: | {
output_high(PIN_A1);
delay_ms(1000);
output_low(PIN_A1);
delay_ms(1000);
}
|
delay_ms() and delay_us() matter on 25M or 16M osc ? The function don't calculate itself on each type of processor speed? If don't, then where is the point to use? I understand delay_cycles() as nop, matter on each type of osc, but .... i miss something or what ? Is true i never use delay functions in last 6-8 years, just counting variable and timers, but I'm still curious. |
|
|
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Mon Oct 26, 2015 2:41 pm |
|
|
Hi wangine,
No, delay_us, and delay_ms are independent of processor speed, as you surmised. The compiler calculates the necessary values based on the #use delay statement. Your confusion is understandable because the OP, stoyanoff, seems to have randomly shifted gears in mid-thread without ever giving anyone any feedback about what he is doing, or what continuing successes and failures he has had. This forum user, stoyanoff, in my opinion, exhibits a very inconsiderate trait which is unfortunately very common here on the forum - asking lots of questions without ever closing the loop on the problem that they sought help/advise on! Ultimately, this is a disservice to other forum users such as yourself who stumble into these random, disorganized threads! _________________ John
If it's worth doing, it's worth doing in real hardware! |
|
|
wangine
Joined: 07 Jul 2009 Posts: 98 Location: Curtea de Arges, Romania
|
|
Posted: Mon Oct 26, 2015 5:15 pm |
|
|
yeea, thanks for answer, OFF topic I didn't touch all my projects in last two years, i was so busy, and now it's little strange for me, i feel like on basic, ON topic. I just ask because many answers but not on the point, the test code was completely wrong. With that code the difference can be observed only below 4Hz crystal , simple and efficient with toggle in one timer because timers depend on osc fuse. (if miss any instrument to measure that blink), and long long time ago i had same problem, with similar 18 family device. The difference, my pic work like i expect with 8MHz osc/12p cap but with internal RC, run at 5.x MHz.
I know the tolerance of any RC osc, I'm hardware engineer, programming its a hobby (time is limited). But i just give up to solve the problem. I buy other device on different type and the problem was solved. On topic again, personally even take much time, before to start a new project. I test individually all necessary Peripherals with simple functions, all type of osc, and after i am sure everything will be fine in final project. |
|
|
stoyanoff
Joined: 20 Jul 2011 Posts: 375
|
|
Posted: Tue Oct 27, 2015 1:53 am |
|
|
This starts to annoy me! Now I can't start the controller in the release mode! In debug everything is fine, but when I change to release it doesn't start! I have 1Mohm in parallel of the quartz. I'm using MPlab 8.91 and in configuration I have no build configuration!
What's happening here?!
Thanks! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19477
|
|
Posted: Tue Oct 27, 2015 3:05 am |
|
|
You are sure that MCLR is pulled up?.
Remember when the debugger is connected, this line is controlled by the debugger.
Double check your ground and power connections. Again when the debugger is attached these lines are connected to it. |
|
|
|