Can any one here program code for PIC?

  • Thread starter Thread starter pickerguy
  • Start date Start date
  • Tags Tags
    Code Program
Click For Summary

Discussion Overview

The discussion revolves around programming a PIC microcontroller for controlling a push button hobby servo. Participants are seeking assistance with writing code and understanding existing examples, particularly in relation to using assembly language versus C programming.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant expresses difficulty in programming a push button control for a hobby servo and requests help with writing code.
  • Another participant shares a link to an example code for turning an LED on and off with a push button, suggesting it as a useful resource.
  • A participant indicates confusion over the code, stating challenges in comparing the datasheet with the written code.
  • Another participant reiterates the shared example and praises it as a nice resource.
  • One participant inquires about the specific aspects of the code that are confusing, particularly regarding bitwise operations used to detect button presses.
  • A suggestion is made that if assembly language is not a requirement, using free C compilers could simplify the programming process, as C code may be more straightforward and less error-prone for beginners.
  • The participant notes that while C can reduce the amount of code needed compared to assembly, there may be challenges in finding compatible development tools and warns about potential negative responses in forums when discussing C programming.

Areas of Agreement / Disagreement

Participants do not appear to reach a consensus on the best approach to programming the PIC microcontroller, with differing opinions on the use of assembly language versus C programming. The discussion remains unresolved regarding the most effective coding strategy.

Contextual Notes

There are mentions of potential typos in programming resources and the complexity of integrating various development tools, which may affect the learning experience for new users.

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:

Similar threads

Replies
38
Views
4K
  • · Replies 40 ·
2
Replies
40
Views
2K
Replies
7
Views
4K
Replies
11
Views
3K
Replies
37
Views
6K
  • · Replies 11 ·
Replies
11
Views
2K
Replies
7
Views
3K
  • · Replies 3 ·
Replies
3
Views
1K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 2 ·
Replies
2
Views
1K