pic16f84 program problem

Thread Starter

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
 

ErnieM

Joined Apr 24, 2011
8,377
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?
 

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
 

spinnaker

Joined Oct 29, 2009
7,830
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.
 

spinnaker

Joined Oct 29, 2009
7,830
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.
 

Thread Starter

ht systems

Joined Aug 2, 2011
71
im not sure if i can find it in the market and i cant buy it from the net so i will see anyway thank you so much for your help .
 
Top