# pic16f84 program problem

#### ht systems

Joined Aug 2, 2011
71
hello , i learned c++ language and i wrote a very simple program :
void main()
{
loop:
TRISA=0B00000000;
PORTA=0B00000001;
goto loop;
}
then i transform it to my programer and transform it into hex code but when i tried it , the chip didnt work as it should be
the chip is : pic16f84
4 M hz
i am sure that my circuit is write
i tried other examples but the same problem
i think that the problem is in the programmer
my programmer is : top win
thanks

#### ht systems

Joined Aug 2, 2011
71

#### ErnieM

Joined Apr 24, 2011
8,108
You waited a whole 25 minutes to post again?

WOW

Can this programmer do a code verification to see what you wrote actually got there?

#### ht systems

Joined Aug 2, 2011
71
yes it does , and the program is in the microchip .

#### t06afre

Joined May 11, 2009
5,934
In PICs it is something named configuration word(s). This should be described in the "SPECIAL FEATURES OF THE CPU" section of the data sheet. Have you given these settings any thought

#### Eric007

Joined Aug 5, 2011
1,156
t06afre made a good point I sometimes used to forget about the 'Config' thing...
Without it nothing gets done!

#### ht systems

Joined Aug 2, 2011
71
ok , thank you and i will recheck about the 'config' even i did it

#### spinnaker

Joined Oct 29, 2009
7,835
hello , i learned c++ language and i wrote a very simple program :
void main()
{
loop:
TRISA=0B00000000;
PORTA=0B00000001;
goto loop;
}
then i transform it to my programer and transform it into hex code but when i tried it , the chip didnt work as it should be
the chip is : pic16f84
4 M hz
i am sure that my circuit is write
i tried other examples but the same problem
i think that the problem is in the programmer
my programmer is : top win
thanks
Buy a PICKit 2 or PICKit 3. You will be able to debug and even look at the hex code to make sure it actually go to the PIC.

It is bad practice to use gotos in programming.

Your code would be better written like this:

Rich (BB code):
void main()
{
while(1)
{
TRISA=0B00000000;
PORTA=0B00000001;
}

}
or better like this:

Rich (BB code):
void main()
{

TRISA=0B00000000;
PORTA=0B00000001;
while(1);

}
This is assuming you do not want to do anything else in the loop.

There is certainly no reason to put the setting of TRISA in a loop.

Also check your datasheet and see if the PORTA pin has a corresponding analog input. If it does you may need to set it's ANS bit to 0 to get the pin to function as a binary pin.

#### ht systems

Joined Aug 2, 2011
71
ok , i will try that , thank you

#### ht systems

Joined Aug 2, 2011
71
is there any website that gives the steps for programming pic16fxx , it would really help , thank you

#### spinnaker

Joined Oct 29, 2009
7,835
And if you buy the Microchip demo board mentioned in the ad, it should come with a tutorial.

You might be able to download the tutorial without buying the board but you might need to make a few adjustments to the code.

But if you are going to buy something then I would suggest the 18f45k22 demo board. It comes with a great tutorial. You might find the 18F a bit easier to work with if you are programming in C.