PDA

View Full Version : PIC18f4550 error



williamlaw
- 14th May 2009, 12:22
hi all

i am currently trying to program a PIC18f4550 with a pickit 2, at the moment i am just trying to send PortB high, so my code is pretty simple, and i currently am useing a simulater called proteus to simulate my code and that works fine, so there is nothing wrong with my code. At the moment i have the 18f4550 set up on a bread board with its vdd pins at 5v and its vss pins at gnd. I am currety using the LVP for the pic, setting the PGM pin high to 5v, but it seems to work fine if you ground the PGM pin. I have tried unsucessfully tried to use HVP by setting MCLR to 10v whle grounding PGM, but that dosent work either

I am using MPlab with the CC18 compler, but i have been using the Pickit 2 programmer as well.

Mplab and the Pickit 2 programer can read and write to the pic, the hex file can be loaded, and it can be written to the pic, the problem is that nothing happens at the portb pins.........
and here is where things get interesting, i have had it working on lvp where the program does what is expected, but it just stoped working, the only thing that may give some hints is that when i sent the program to the pic, instead of just making the portb pins 5v, it makes every pin 5v.
i read in a post before that you need to set your lvp config bits, and i have done that by making a header file (PIC18f4550w.h) with all the config bits that i want. here is the code just to make sure i havent blown the obvious.

#include <p18f4550.h>
#include <PIC18f4550w.h>

void main(void)
{

TRISD = 0;
PORTD = 0xff;
while (1)
{
}
}


and yes i do have a cap across the vdd and vss pins

and help would be apreciated
thanks will

ScaleRobotics
- 14th May 2009, 19:27
the problem is that nothing happens at the portb pins.........
#include <p18f4550.h>
#include <PIC18f4550w.h>

void main(void)
{

TRISD = 0;
PORTD = 0xff;
while (1)
{
}
}

Looks more like C than PicBasic to me, but to state the obvious, you want port B to go high, but you are telling port D to go high?

Also, if using PicBasic, you can use Darrels handy dandy all digital to set up all your pins to be digital. This saves some time. But you will have to use basic commands that PicBasic will accept.

See http://www.picbasic.co.uk/forum/showthread.php?t=11100