CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Migration from 16F877 to 18F452 problems

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Ronald
Guest







Migration from 16F877 to 18F452 problems
PostPosted: Sat Dec 18, 2004 7:52 am     Reply with quote

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
daveroll
Guest







PostPosted: Sat Dec 18, 2004 11:23 am     Reply with quote

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
lesotter



Joined: 21 Sep 2003
Posts: 5

View user's profile Send private message

PostPosted: Sat Dec 18, 2004 6:38 pm     Reply with quote

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
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Sun Dec 19, 2004 9:12 am     Reply with quote

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.
Ttelmah
Guest







PostPosted: Sun Dec 19, 2004 11:31 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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