On Tue, Sep 02, 2008 at 06:58:25AM -0400, Vitaliy wrote: > Jason Hsu wrote: > > In the process of trying to get started, I can see why Assembly > > language is MUCH more popular among hobbyists than C. > > I am surprised by the fact people who replied so far, seem to agree with > you. Is it really so, that the majority of hobbyists use assembly in their > projects? Many do. It's simply exposure. There are tons of resources for building projects in assembly, along with detailed tutorials of getting everything installed. Another plus is that all of the tools are completely free. Once you start talking about C, there is a wide diversity of tools with a wide range in prices and capabilities. So there's no universality. > In my opinion, unless your project is a very high-volume, extremely > price-sensitive commercial product, you shouldn't be using the PIC16F, or > programming in Assembly. I know this statement has the potential of starting > a flame war, but please bear with me as we look at the facts. Let's hear it. > > The 16F is cheaper than the 18F or the 16-bit PICs, but for one-off or > low-volume projects, the difference is negligible (about $1). See for > yourself -- click on the product series, and sort by price in ascending > order (also pay attention to what you get for the money): Agreed. It's one of the reasons that I argue that using a PIC that's fully packed with peripherals as opposed to parts with limited functionality. > PIC16F: http://tinyurl.com/9akkz > PIC18F: http://tinyurl.com/2yg3zw > PIC24H: http://tinyurl.com/2x9k2w Absolutely. The problem in the past has been programming tools. Also with the 24H the packaging is an issue. For a hobbyist, DIP will continue to be a prime motivator. So actually the dsPIC30F would package better than the PIC24H. > > For anything but high-volume projects (many thousands), or projects > requiring very little code, you will spend *more* per unit if you go with > the PIC16F. I don't think price is the true motivation for most hobbyist. They generally want to bite off something they can chew. If you want to see where they gravitate, look for the setup with the most hands on step by step tutorials. > Microchip has free Student versions of the C18 and C30 compilers. > Programming in C has many advantages over assembly, but the main one is that > it makes the code much easier to write, understand, and reuse. It lets you > focus more on the design, rather than the implementation details, of your > program. Another big advantage for a beginner, is that there are many more > resources available for C (books, websites, expert programmers), than for > the PIC16F flavor of Assembly. I agree for C in general, but not necessarily for C for embedded systems and even more specifically C for Microchip controllers. For example as a Linux based Pic guy, I'd probably start here: http://www.micahcarrick.com/04-25-2005/pic-c-programming-linux.html Note that it meets my specific target. > Some folks argue that writing in C results in bloated code, especially on > Microchip's compilers. However, for most hobbyist projects, performance and > even the amount of available memory is irrelevant. Even if it wasn't, for > less than an extra $1, you get a processor with at least 10 times as much > memory, running at up to 20 times as fast. If that's still not enough (here > we're assuming that a compiler is 20 times worse at producing assembly than > a newbie), drop down to inline assembly for the performance-critical > portions of your program. > > I think most of us are familiar with the curve showing the ratio of hardware > vs software cost over time. Hardware is getting ridiculously cheap. People's > time, on the other hand, is becoming increasingly more expensive. Pretty > soon, the 16- and 32-bit PICs will literally cost less than a pack of gum. > > The bottom line is, if you are new to PICs, get the Explorer 16 board, or at > least an 18F, download the free C compiler, and remember that you're writing > code for humans first, and for computers second. Err on the side of > readability, even if it comes at the expense of memory locations, or machine > cycles. The only caveat that I would add is that anyone working with PICs still needs to have a reading level knowlege of assembly. The reason is that often PIC assembly is the linguq franca of algorithms. Microchip themselves do this by putting out most of their code in PIC assembly. BAJ -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist