![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
Ronald Guest
|
Migration from 16F877 to 18F452 problems |
Posted: Sat Dec 18, 2004 7:52 am |
|
|
Hi,
i've been having problems getting a simple LED to light on my 18F452. Works perfectly well for my 16F877 but not 18F452.
both are 40 pin DIL/PDIP, and i've been working with the 16f877 till today, when i discovered it was lacking in RAM. So i took out my 18F452 and stuck it in its place on my breadboard. prior to that i check that the pins were the same, except for the LVP pin which i didnt care abt. (If i'm wrong to just replace it pin for pin, can someone pls let me know)
env is MPLAB, ICD2, with CCS PCWH compiler.
code is basic:
#include <18F452.h>
#device ICD = true
#fuses XT, NOWDT, NOLVP, NOPROTECT
main()
{
output_high (PIN_A2);
}
works perfectly well for the 16f877 (just by changing the header file), but not 18f452.
osc is a 4 legged 20Mhz.
compiles correctly, programs very well, but the LED just doesnt light up. I've tried it with other pins too, but they dont work as well.
Greatly appreciate any help. If someone could tell me what to put in the config bits part i'll be most happy.
thanks,
ronald |
|
![](templates/subSilver/images/spacer.gif) |
daveroll Guest
|
|
Posted: Sat Dec 18, 2004 11:23 am |
|
|
check the osc waveform for correct applitude
change xt to hs.
add the fuse nodebug
program the device with programmer not debuger
unplug the icd2 after programing it
power down the 452 and power it up |
|
![](templates/subSilver/images/spacer.gif) |
lesotter
Joined: 21 Sep 2003 Posts: 5
|
|
Posted: Sat Dec 18, 2004 6:38 pm |
|
|
Not sure if this is yur problem, but when I ported an app from 16f877 to 18f452 I needed to add
#byte PORTA = 0xf80 // for 18f452
before any activity could be used on the A port.
Also, try disabling the a/d by :-
SETUP_ADC_PORTS(NO_ANALOGS);
and
set_tris_a(0); //to make A port outputs |
|
![](templates/subSilver/images/spacer.gif) |
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Sun Dec 19, 2004 9:12 am |
|
|
Quote: | #fuses XT, NOWDT, NOLVP, NOPROTECT
main()
{
output_high (PIN_A2);
}
works perfectly well for the 16f877 (just by changing the header file), but not 18f452.
osc is a 4 legged 20Mhz. |
I find it difficult to believe this same setup is working for the 16f877 because according to the datasheets with the XT oscillator setting your maximum frequency is limited to 4MHz.
When using a 20MHz crystal both for the 18F452 and 16F877 the oscillator mode should be set to HS. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Sun Dec 19, 2004 11:31 am |
|
|
The reason it 'works', is because he is using an external oscillator (4pin crystal in the original post), so the gain of the internal oscillator, doesn't really matter (which is what XT/HS changes). I agree EC would be a better 'choice'.
The code is incorrect for both chips, because the ADC, is not disabled. The reason for the difference though, is that the I/O behaviour is fractionally different, on the two chips, with the 877, overriding the peripheral, if the pin is selected as an output, while the 452, _requires_ you to disable the periperal. Adding 'setup_adc_ports(NO_ANALOGS);', should make the code work.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|