View previous topic :: View next topic |
Author |
Message |
acm45
Joined: 29 Dec 2008 Posts: 18 Location: Italy
|
H4 vs HS |
Posted: Fri Dec 18, 2009 1:08 pm |
|
|
I'm using a 18F4431 and I've some problems with the oscillator configuration, when I use HS with a 10MHz crystal all works fine.
Now I need to increase the MIPS, so I decided to use the PLL to have 10MHz X4 (without change crystal).
So I changed from
Code: | #FUSES HS
#use delay(clock=10M) |
to
Code: | #FUSES H4
#use delay(clock=40M) |
With this settings the pic don't work like before!
Why? |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1934 Location: Norman, OK
|
|
Posted: Fri Dec 18, 2009 1:22 pm |
|
|
Please be a more specific.
What do you mean by "it doesn't work like before"?
Also, what version are you using? _________________ Google and Forum Search are some of your best tools!!!! |
|
|
acm45
Joined: 29 Dec 2008 Posts: 18 Location: Italy
|
|
Posted: Fri Dec 18, 2009 1:58 pm |
|
|
The PIC is connected to a 2x16 LCD display, after the change I've the first row of the display full (all black) and no answer to other inputs.
I think (but I'm not sure) the problem comes from the timing options
#use delay(...)
I'm using version 4.093
Thank you. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Dec 18, 2009 3:19 pm |
|
|
Try a simple LED blinking program. Does it work ?
Code: | #include <18F4431.h>
#fuses H4, NOWDT, NOPROTECT, PUT, BROWNOUT, NOLVP
#use delay(clock=40000000)
//====================================
void main()
{
// Blink the LED once per second.
while(1)
{
output_high(PIN_B0);
delay_ms(100);
output_low(PIN_B0);
delay_ms(900);
}
} |
|
|
|
acm45
Joined: 29 Dec 2008 Posts: 18 Location: Italy
|
|
Posted: Fri Dec 18, 2009 3:45 pm |
|
|
Thank you for the idea but...
The code you posted don't work!
Work as expected if I change H4 to HS
and clock 40M to 10M |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Fri Dec 18, 2009 3:55 pm |
|
|
That's pretty weird.
You can leave out the H4 and HS and use:
#use delay(clock=40M, crystal=10M)
or
#use delay(clock=10M, crystal=10M)
to switch back and forth.
From there, I would look at the fuse settings to make sure they're right.
I've used the 18F4431 in 40MHz mode with no problem. Your compiler version IS new enough that it shouldn't be throwing out issues.
While a scope would tell you the 10MHz is running, can you verify that it continues to run when set for 40MHz (I'm wondering if the Oscillator's HS function is being shut off)
-Ben _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Dec 18, 2009 4:04 pm |
|
|
It worked for me. I installed vs. 4.093 and compiled that exact program
in MPLAB. I programmed it into a 18F4431 and ran it on my PicDem2-Plus
board. I installed a 10 MHz crystal on the board. I timed the LED flashes
with a stopwatch, and it blinks at a 1 Hz rate. It's working.
Therefore, there's probably something wrong (or different) with your hardware. |
|
|
acm45
Joined: 29 Dec 2008 Posts: 18 Location: Italy
|
|
Posted: Sat Dec 19, 2009 4:35 am |
|
|
I will check the hardware but, in both cases HS and H4, the crystal is working at 10MHz, only with HS the PIC works fine.
I've also replaced the PIC but no difference.
Moreover I don't know if is normal that with H4 I can't use the ICD2 to debug the code. |
|
|
Ttelmah Guest
|
|
Posted: Sat Dec 19, 2009 11:17 am |
|
|
Try adding a series resistor between the crystal and the PIC.
In the 'old days' (on older PICs than this), there was a common problem with the PLL not running, if the gain of the crystal was too large. Though most modern PICs seem to have fixed this, the description is exactlty what happens if this is the case.....
Best Wishes |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1934 Location: Norman, OK
|
|
Posted: Sat Dec 19, 2009 11:48 am |
|
|
One thing I encounter when using the ICD for programming. If I reprogram
the chip using the ICD and then perform a reset and run the PLL will not kick
in. I have to power the chip off and back on before the PLL will work. _________________ Google and Forum Search are some of your best tools!!!! |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Sat Dec 19, 2009 4:03 pm |
|
|
That makes no sense whatsoever.
I never saw that when working with the 18F4431.
-Ben _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1934 Location: Norman, OK
|
|
Posted: Sat Dec 19, 2009 4:24 pm |
|
|
Whether you think it makes sense or not, I was the one to document this as
a problem a few years ago and it was confirmed by Microchip at the time.
I feel sure PCM remembers this as he has repeated it a few times. I don't
know how widely it affects the Microchip processor line ( I know it affected
the 16F and the early 18F series) but i felt it needed to be mentioned. I have
gotten into the habit of always doing it as a matter of course.
Take it for what it's worth, which in your case apparently is zero. _________________ Google and Forum Search are some of your best tools!!!! |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Sat Dec 19, 2009 4:31 pm |
|
|
I'm not trying to be argumentative.
Just lacking a helpful reply as I've never ever seen something like that with all the 18F projects I've undertaken -- and having switched the H4 fuse back and forth in my testing with no problems.
I wish I could help further - but I can't. :(
Sorry,
-Ben _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
Ttelmah Guest
|
|
Posted: Sun Dec 20, 2009 5:59 am |
|
|
Switching the fuse in an ICD setup, does not stop the chip working, but the actual operating speed doesn't change till the next power reset. This applies to many chips, where the PLL, is only enabled through fuses. On ones where the PLL is controllable from software, the change is immediate.
Microchip document this in the paperwork for their ICD's now, as a 'limitation', for many chips. It makes sense if you think about it, with the PLL being controlled by hardware, which only resets the oscillator circuit, during a POR. In many cases, people make the change, and are not even aware that the hardware has not switched speed.
This would be the problem here, if the original poster was saying 'the chip only runs at 1/4 the speed it should', but the poster is saying that the chip doesn't run at all, so this is not the problem.
Best Wishes |
|
|
Ken Johnson
Joined: 23 Mar 2006 Posts: 197 Location: Lewisburg, WV
|
|
Posted: Sun Dec 20, 2009 9:01 am |
|
|
This would have no impact on a "blinking led test", but . . .
Check the timing requirements for the lcd enable or write pulses; at 40 MHz the pulse may be too fast for the lcd ? ? ?
Ken |
|
|
|