Can any one here program code for PIC?

  • Thread starter Thread starter pickerguy
  • Start date Start date
  • Tags Tags
    Code Program
AI Thread Summary
The discussion centers on programming a PIC microcontroller for a push button hobby servo control, with users expressing confusion over existing code examples. A suggestion is made to use simple C programming instead of assembly language, as it can reduce complexity and errors. Resources like the book "Programming Robot Controllers" by Predko are recommended for learning C programming, though caution is advised due to potential typos. Users are warned that seeking help on forums may lead to negative responses if C programming is mentioned over assembly language. Overall, using straightforward C code can simplify the programming process for PIC microcontrollers.
pickerguy
Messages
12
Reaction score
0
having issues with programming, can some one help me write a code for a push button hobby servo control?
 
Technology news on Phys.org
I just don't get it. I've looked at other codes and tried to compare the data sheet with the written code and i don't get it
 
what is confusing you? is the bitwise usage in the program where bits are analyzed to determine if the buttons been pressed?
 
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:
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...
Back
Top