PDA

View Full Version : Help, problems first time with 18F452 PIC



MikeTamu
- 13th August 2005, 23:52
Hello, I just recieved my MELABS seriel programmer and PIC Basic Pro. I tried doing the initial 'Blink' program with no success. Let me begin by telling my process for programming in case I am doing something wrong.

1) I first select the right PIC and write my code in MicroCode Studio, my program is:

DEFINE OSC 10
loop: High PORTB.1 ' Turn on LED connected to PORTB.1
Pause 200 ' Delay for .2 seconds

Low PORTB.1 ' Turn off LED connected to PORTB.1
Pause 200 ' Delay for .2 seconds

Goto loop ' Go back to loop and blink LED forever

End

As you can see I am operating at 10 Mhz with a 10 Mhz ceramic resonator with built in capacitors.

2) Next, I compile to get the Hex file for the program. I open Melabs Programmer, select the correct PIC, load my Hex file, Erase the PIC, check for blank, then Program the PIC. I then turn off the seriel programmer and remove the PIC, followed by placing it in my circuit.

My circuit consists of a 5 Volt supply, a 10 uf and .1 uf decoupling capacitors across the +5 and ground, and the ceramic 3 pin resonator (with built in caps) connected to the 2 resonator pins and the ground pin tied to ground. Portb.1 is tied to a 1k resistor and led in series.

Results:

When the power is turned on, Portb.1 outputs 5 volts for about 1 second, shuts off and then nothing else happens. I have tried troubleshooting this problem with no success whatsoever.

Is there anything wrong with my PicBasic Pro code that I am not seeing here?

Thanks for any help.

MikeTamu
- 14th August 2005, 00:38
Update:

After struggling with this problem for half a day, I have learned my lesson well. In Melabs Programmer, XT was the selected speed mode whereas HS should of been for 10 Mhz. Doh!

sougata
- 19th August 2005, 14:04
Hi there,

Did you know that you can run your PIC18F452 @ 40MHz using the same 10MHz resonator! The config is then HS_PLL (It does a x4 PLL multiply)

Happy PICing

Regards

Sougata

MikeTamu
- 19th August 2005, 14:45
Wow, I didn't know that. Thanks.

Where do I put this 'config' command and what is the full command to use?

Also, does PBP know that I will be doing this and adjust its pause times accordingly?


Thanks.

sougata
- 19th August 2005, 20:49
Hi there,

As far as I remember Melanie did give a full reference on the @config issues. I do it in a different way. I edited the 18F452.inc file in the pbp folder and change the XT_OSC to HS_PLL. Actually I run almost all my 18F452 @40MHz. That gives me fastest running code however practical serial communication is limited to 9.6K. Higher rates yield high baud rate error. BTW a simple define "DEFINE osc 40" will make your timing correct under PBP. Keep exploring.

Regards

Sougata