Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Can any one here program code for PIC?

  1. Sep 20, 2012 #1
    having issues with programming, can some one help me write a code for a push button hobby servo control?
     
  2. jcsd
  3. Sep 21, 2012 #2

    jedishrfu

    Staff: Mentor

  4. Sep 21, 2012 #3
    I just dont get it. ive looked at other codes and tried to compare the data sheet with the written code and i dont get it
     
  5. Sep 21, 2012 #4

    berkeman

    User Avatar

    Staff: Mentor

  6. Sep 21, 2012 #5

    jedishrfu

    Staff: Mentor

    what is confusing you? is the bitwise usage in the program where bits are analyzed to determine if the buttons been pressed?
     
  7. Sep 24, 2012 #6
    If you are not required to use assembly language for your project then there are free C compilers available for download that will generate binary for the PIC processors.

    If you write very simple straight forward code in C, not arrays of structs of pointers to etc, etc, etc, but just simple statements that copy bytes from ports to variables, do simple 8 bit add, subtract, compare, etc, copy bytes from variables to ports, do simple loops for timing and things like that then the compilers do a fair job creating code. And you might make fewer silly errors by not understanding one assembly instruction or another.

    There is a decent book called Programming Robot Controllers by Predko that can introduce you to C programming with the PIC. He sometimes has typos in some of his books and that can make it hard for new users, so watch out. And there are lots of versions of the compilers and the PIC development tools and the PIC toasting tools which can be frustrating to figure out how to get them all to talk to each other.

    But if you just need to do a little simple programming then this might be an option. Often a single line of C code can replace 2-6 lines of assembly code and possibly be more understandable to you. Toy programs can be a half dozen line C program instead of half a page of assembly. Even more complicated projects can be a page of C code instead of half a dozen pages of assembly. With practice you can hold a page of good C code in your head and study it to make sure it is all correct. That is much more difficult to do with half a dozen pages of assembly, often with a comment on almost every line just to keep track of what it is doing.

    It has been years since I did something like this, so make sure this information is still correct.

    You should also be warned that if you wander into many of the web forums that talk about the PIC and you ask any question about using a C compiler or C programming instead of doing everything in bare assembly code that you will get no help and often just insults because you aren't using their language their way. Buyer beware.
     
    Last edited: Sep 24, 2012
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Can any one here program code for PIC?
  1. Programming a PIC (Replies: 21)

Loading...