Forums

PIC 18F4455 simple project help

Started by CMOS February 3, 2008
hi,
i've started playing with 18F4455 device. im using MPLAB with c18
compiler student version.
as a start what am trying to do is to light an LED connected to pin 6
(RA4). here is the code.

#include <p18cxxx.h>
#pragma config WDT = OFF

void main()
{
	ADCON1 = 0x0F;
	CMCON = 0x07;
	TRISA = 0xCF;
	LATAbits.LATA4 	= 1;
	while(1);
}

how ever the LED in the target circuit does not light !. please let me
know whether there is any problem with the above code. ( how ever i am
able to debug it using ICE 2 without any problem)
my device is 18F4455.

thanks
CMOS wrote:
> hi, > i've started playing with 18F4455 device. im using MPLAB with c18 > compiler student version. > as a start what am trying to do is to light an LED connected to pin 6 > (RA4). here is the code. > > #include <p18cxxx.h> > #pragma config WDT = OFF > > void main() > { > ADCON1 = 0x0F; > CMCON = 0x07; > TRISA = 0xCF; > LATAbits.LATA4 = 1; > while(1); > } > > how ever the LED in the target circuit does not light !. please let me > know whether there is any problem with the above code. ( how ever i am > able to debug it using ICE 2 without any problem) > my device is 18F4455. > > thanks
Did you build the board yourself or did you buy it from somewhere ?? How is the LED wired, LATAbits.LATA4 = 1; means the pin will go HIGH to 3 volts. Is the LED wired with the anode of the LED connected to pin 6 with a resistor in series of the PIC and the cathode connected to ground ?? Thanks for sharing. donald
On Feb 3, 9:36 pm, donald <Don...@dontdoithere.com> wrote:
> CMOS wrote: > > hi, > > i've started playing with 18F4455 device. im using MPLAB with c18 > > compiler student version. > > as a start what am trying to do is to light an LED connected to pin 6 > > (RA4). here is the code. > > > #include <p18cxxx.h> > > #pragma config WDT = OFF > > > void main() > > { > > ADCON1 = 0x0F; > > CMCON = 0x07; > > TRISA = 0xCF; > > LATAbits.LATA4 = 1; > > while(1); > > } > > > how ever the LED in the target circuit does not light !. please let me > > know whether there is any problem with the above code. ( how ever i am > > able to debug it using ICE 2 without any problem) > > my device is 18F4455. > > > thanks > > Did you build the board yourself or did you buy it from somewhere ?? > > How is the LED wired, LATAbits.LATA4 = 1; means the pin will go HIGH to > 3 volts. > Is the LED wired with the anode of the LED connected to pin 6 with a > resistor in series of the PIC and the cathode connected to ground ?? > > Thanks for sharing. > > donald
thanks for the reply.. Im sure about the hardware side because i have done lot of projects in the past with PIC's (sorry i forgot to mention that). but i almost forgot firmware side of it, so im not sure whether the above code is complete. specifically not sure whether i've missed out any configuration, etc. (the oscillator config is set using the IDE - not in the source).
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

CMOS wrote:
> thanks for the reply.. > Im sure about the hardware side because i have done lot of projects in > the past with PIC's (sorry i forgot to mention that). but i almost > forgot firmware side of it, so im not sure whether the above code is > complete. specifically not sure whether i've missed out any > configuration, etc. (the oscillator config is set using the IDE - not > in the source). >
Check that the oscillator is running first. Set it to external oscillator (Can't remember if the 18F4552 has an internal one) and probe the oscillator pins for a signal with an oscilloscope. Try setting the oscillator with the code. For example: #pragma config OSC = HSPLL Sets it to high speed oscillator with 4x PLL (quick copy & paste from a recent 18F4620 project). -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (MingW32) iD8DBQFHpgHCuv4tpb9qDZQRAmUNAJ9Rm3iUPKvTHCryZNfL4gA07x6vRwCgiktj aykIkYLEjtRgatBCcVSf79E= =mNg1 -----END PGP SIGNATURE-----
On Feb 3, 11:02 pm, Brendan Gillatt
<brendanREMOVET...@brendanREMOVETHISgillatt.co.uk> wrote:
> -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > CMOS wrote: > > thanks for the reply.. > > Im sure about the hardware side because i have done lot of projects in > > the past with PIC's (sorry i forgot to mention that). but i almost > > forgot firmware side of it, so im not sure whether the above code is > > complete. specifically not sure whether i've missed out any > > configuration, etc. (the oscillator config is set using the IDE - not > > in the source). > > Check that the oscillator is running first. Set it to external oscillator > (Can't remember if the 18F4552 has an internal one) and probe the > oscillator pins for a signal with an oscilloscope. > > Try setting the oscillator with the code. For example: > > #pragma config OSC = HSPLL > > Sets it to high speed oscillator with 4x PLL (quick copy & paste from a > recent 18F4620 project). > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.7 (MingW32) > > iD8DBQFHpgHCuv4tpb9qDZQRAmUNAJ9Rm3iUPKvTHCryZNfL4gA07x6vRwCgiktj > aykIkYLEjtRgatBCcVSf79E= > =mNg1 > -----END PGP SIGNATURE-----
im getting this error when i try to set the oscilator config from code.. Error [1224] configuration setting 'OSC' not recognized my device is 18f4455. any idea?
On Feb 3, 11:02 pm, Brendan Gillatt
<brendanREMOVET...@brendanREMOVETHISgillatt.co.uk> wrote:
> -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > CMOS wrote: > > thanks for the reply.. > > Im sure about the hardware side because i have done lot of projects in > > the past with PIC's (sorry i forgot to mention that). but i almost > > forgot firmware side of it, so im not sure whether the above code is > > complete. specifically not sure whether i've missed out any > > configuration, etc. (the oscillator config is set using the IDE - not > > in the source). > > Check that the oscillator is running first. Set it to external oscillator > (Can't remember if the 18F4552 has an internal one) and probe the > oscillator pins for a signal with an oscilloscope. > > Try setting the oscillator with the code. For example: > > #pragma config OSC = HSPLL > > Sets it to high speed oscillator with 4x PLL (quick copy & paste from a > recent 18F4620 project). > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.7 (MingW32) > > iD8DBQFHpgHCuv4tpb9qDZQRAmUNAJ9Rm3iUPKvTHCryZNfL4gA07x6vRwCgiktj > aykIkYLEjtRgatBCcVSf79E= > =mNg1 > -----END PGP SIGNATURE-----
im getting this error when i try to set the oscilator config from code.. Error [1224] configuration setting 'OSC' not recognized my device is 18f4455. any idea?
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

CMOS wrote:
> im getting this error when i try to set the oscilator config from > code..
> Error [1224] configuration setting 'OSC' not recognized
> my device is 18f4455. > any idea?
Like I said, that was just an example for a PIC18F4620. See the microchip configuration options manual available here: http://sips.inesc-id.pt/~jjap/TFC/c18_config_settings_51537e.pdf Specifically page 146 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (MingW32) iD8DBQFHp1epuv4tpb9qDZQRAhvnAJ9t4kzIKRVpk3+EzSb1wWRCvfMvAgCfZTb1 FN0bxsYaOCkxUTq1R8zM154= =3wzV -----END PGP SIGNATURE-----
CMOS wrote:
> hi, > i've started playing with 18F4455 device. im using MPLAB with c18 > compiler student version. > as a start what am trying to do is to light an LED connected to pin 6 > (RA4). here is the code. > > #include <p18cxxx.h> > #pragma config WDT = OFF > > void main() > { > ADCON1 = 0x0F; > CMCON = 0x07; > TRISA = 0xCF; > LATAbits.LATA4 = 1; > while(1); > } > > how ever the LED in the target circuit does not light !. please let me > know whether there is any problem with the above code. ( how ever i am > able to debug it using ICE 2 without any problem) > my device is 18F4455. > > thanks
Check your data sheet, on most 18fxxxx devices pin A4 is open drain. It won't source current. Paul Probert
On 2008-02-05, Paul Probert <paulprobert@sbcglobal.net> wrote:
> CMOS wrote:
>> i've started playing with 18F4455 device. im using MPLAB with c18 >> compiler student version. >> as a start what am trying to do is to light an LED connected to pin 6 >> (RA4). here is the code.
> Check your data sheet, on most 18fxxxx devices pin A4 is open drain.
Most 18F devices released in the last several years (including the 18F4455) do not have an open drain on RA4. -- John W. Temples, III