pic16f84 program problem

Discussion in 'Embedded Systems and Microcontrollers' started by ht systems, Nov 9, 2011.

  1. ht systems

    Thread Starter Member

    Aug 2, 2011
    71
    1
    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
     
  2. ht systems

    Thread Starter Member

    Aug 2, 2011
    71
    1
    no answer ........ !!!!
     
  3. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,392
    1,605
    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?
     
  4. ht systems

    Thread Starter Member

    Aug 2, 2011
    71
    1
    yes it does , and the program is in the microchip .
     
  5. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    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
     
  6. Eric007

    Senior Member

    Aug 5, 2011
    1,044
    33
    t06afre made a good point I sometimes used to forget about the 'Config' thing...
    Without it nothing gets done!
     
  7. ht systems

    Thread Starter Member

    Aug 2, 2011
    71
    1
    ok , thank you and i will recheck about the 'config' even i did it
     
  8. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,887
    1,014
    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:

    Code ( (Unknown Language)):
    1.  
    2.  
    3. void main()
    4. {
    5.    while(1)
    6.    {
    7.        TRISA=0B00000000;
    8.        PORTA=0B00000001;
    9.    }
    10.  
    11. }
    12.  
    or better like this:

    Code ( (Unknown Language)):
    1.  
    2. void main()
    3.  {
    4.  
    5.     TRISA=0B00000000;
    6.     PORTA=0B00000001;
    7.     while(1);
    8.  
    9.  }
    10.  
    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.
     
  9. ht systems

    Thread Starter Member

    Aug 2, 2011
    71
    1
    ok , i will try that , thank you
     
  10. ht systems

    Thread Starter Member

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

    Moderator

    Dec 15, 2009
    2,517
    785
  12. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,887
    1,014
    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.
     
  13. ht systems

    Thread Starter Member

    Aug 2, 2011
    71
    1
    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 .
     
Loading...