learning C for pic - Page 1
Forum section: electronics / beginners

author: Simon
author_rank: Unknown
timestamp: November 21, 2010, 09:22:25 pm
content: ok so people keep telling me that I should use C not Basic (still don't know the advantage but then I don't know any C). So what should I do ? I currently use the mikroe Basic compiler, is their C compiler recommended or are there better options that are free.OK so should I learn C as a language or follow the manual for the compiler that explains the language assuming there is a such a manual ?

author: jahonen
author_rank: Super Contributor
timestamp: November 21, 2010, 09:27:06 pm
content: I think both would be a good idea. I originally learned C on PC, and much later used it in embedded systems. Of course you must realize that embedded system, there is no operating system to do the housekeeping for you, and resources are scarce. Otherwise no problem learning the C in general sense.I think it is best to develop computational algorithms on powerful PC environment, and only when it works properly on the PC, transfer it to embedded environment. Debugging in PC is much easier than in embedded system. Of course, not everything can be done this way, and less if the application is heavily dependent on the HW.Regards,Janne

author: Kiriakos-GR
author_rank: Super Contributor
timestamp: November 21, 2010, 09:31:41 pm
content: I bet that "Basic" still haves some life in it.Mostly because its old and backwards compatible.In got my first training on "Basic" at 1988 , like the first class in college ( The Greek educational system are different) after high-school we have other naming about schools.

author: Simon
author_rank: Unknown
timestamp: November 21, 2010, 09:50:32 pm
content: well all I care for is achieving what I want to achieve, but is C has more mileage in it best learn now than carry on with basic and then have to relearn it all in C

author: DaveW
author_rank: Frequent Contributor
timestamp: November 21, 2010, 09:55:25 pm
content: The main advantage of C (at work anyway), is being able to reuse code and change processors-if you want to do this, its good to learn the basic C, most of the proprietary I've used has just been extra functions so its not too hard other versions. For the pure C this is quite a good book, a free downloadhttp://publications.gbdirect.co.uk/c_book/Because its old it teaches C that also runs on embedded stuff, no GUI bits!Oh, and a vote for MikroC, good bit of kit, although found it expensive when I bought it (as a student)

author: Unknown
author_rank: Unknown
timestamp: November 21, 2010, 10:01:28 pm
content: Quote from: Kiriakos-GR on November 21, 2010, 09:31:41 pmBackwards compatible? Don't make me laugh. It would probably be hard to find two compilers/interpreters that can run the same non-trivial program, and many of the older compilers don't exist anymore (including the Microsoft one). Is there even a standard BASIC, like ANSI C, that most vendors implement?For embedded work, it's nice that C is closer to hardware, for example bitwise operations, pointers, bit fields and fixed-width data types (eg. uint8_t). If BASIC compilers implement this it all, it will be (yet another) vendor-specific extension.I believe the MikroE compilers translate it into some sort of intermediary language, which makes them produce worse code. Never verified this myself, though.

author: Simon
author_rank: Unknown
timestamp: November 21, 2010, 10:01:54 pm
content: I thought mikroe products had free versions or limitations on the pro version, my projects are small. for the basic compiler they limit you to 2K of program, I doubt I used a micro yet with that much memory

author: Mechatrommer
author_rank: Super Contributor
timestamp: November 22, 2010, 12:40:33 am
content: basic and C is just like english and spanish or france or german language or whatever.... well.... i hate to say it long.... in short, if you already familiar with basic, step by step of translating yourself into competent C should be easier than if you know nothing of any programming language. both got if, loop, for, +, - etc.

author: migsantiago
author_rank: Frequent Contributor
timestamp: November 22, 2010, 12:48:31 am
content: Use C.Eventually, it will let you jump to higher platforms such as C++, C# or Java.Basic won't.

author: TheDirty
author_rank: Frequent Contributor
timestamp: November 22, 2010, 12:54:51 am
content: Like mentioned, C is be far and away the most popular language for microcontrollers. There is usually a few C compilers for any popular architecture. I'm currently using 3 different architectures and share basic code between them. I've also stolen code from Linux drivers, Arduino libraries, and libraries for other microcontrollers.If you are currently using PIC's and have no interest in moving to other platforms or doing larger scale development, stick with what you have, but not learning C is going to be a big hindrance to you if you want to move on.

author: Mechatrommer
author_rank: Super Contributor
timestamp: November 22, 2010, 01:15:04 am
content: Quote from: TheDirty on November 22, 2010, 12:54:51 amnot just microcontroller, C is number one in any programming language, its the closest thing to assembly.

author: TheDirty
author_rank: Frequent Contributor
timestamp: November 22, 2010, 01:42:55 am
content: Quote from: shafri on November 22, 2010, 01:15:04 amI don't know of anyone that uses K&R or ANSI C for programming PC's now-a-days. I was just going to say C is the most popular for embedded, but it's not for FPGA/CPLD.

author: Unknown
author_rank: Unknown
timestamp: November 22, 2010, 02:00:10 am
content: Quote from: TheDirty on November 22, 2010, 01:42:55 amAssuming that includes current ANSI versions like C99: How many system programmers do you know? What language is the Win32 API written in? Many Windows components? The kernel of any current Unix-like OS? A significant part of Gnome? But you're right if you claim that many development is focused on higher level languages these days. The same will probably happen to MCU's once the hardware will exceed requirements, and development time starts to get more expensive than extra silicon.

author: TheDirty
author_rank: Frequent Contributor
timestamp: November 22, 2010, 02:08:48 am
content: QuoteThis is were you should have started and ended your thread. Yes, I'm right, the majority of software development for the PC would be higher level languages. Because I don't know people that do Linux kernel development or write device drivers doesn't make that not true.I mean technically I do know someone as I've done small linux throw away programs in C, but I did not claim that C is not used in PC development at all.

author: Hypernova
author_rank: Unknown
timestamp: November 22, 2010, 04:41:09 am
content: Quote from: TheDirty on November 22, 2010, 01:42:55 amOf course not for FPGA's, those take hardware descriptions not software instructions.

author: joelby
author_rank: Frequent Contributor
timestamp: November 22, 2010, 07:37:11 am
content: Quote from: Hypernova on November 22, 2010, 04:41:09 amActually there are translators for using (non-ANSI) C/C++/SystemC on FPGAs, though I'm not sure how popular this is.

author: Simon
author_rank: Unknown
timestamp: November 22, 2010, 07:48:27 am
content: well I don't know what the future holds. currently my pic projects are small, basically replacing a number of IC's with one pic or doig some simple math function that conventional IC just would not do (unless I made my own mcu out of them). But with the future in mind and the rest of the programming world speaking C I guess I should too

author: Mechatrommer
author_rank: Super Contributor
timestamp: November 22, 2010, 11:55:19 am
content: i was emphasizing TheDirty's point beyond mcu domain. that post should not be taken seriously, as it is clearly OT or OD (out of domain). and i cannot prove 100% of my statement, but i'm certain it will not be basic or delphi or others, non that i have heard. FPGA is not a true native programming, ie serial execution, its just connecting wires among gates in varying different manner, afaik.

author: Simon
author_rank: Unknown
timestamp: November 22, 2010, 12:35:29 pm
content: and i'm only talking basic versus c in pics

author: Mechatrommer
author_rank: Super Contributor
timestamp: November 22, 2010, 01:08:36 pm
content: Quote from: Simon on November 22, 2010, 12:35:29 pmi'm trying to talk globally, to show the importance of C, so any newbies reading wont wander far off. if you know it earlier, you would have been a competent C programmer by now. and if you really get what i mean (my implicit semantics) you'll further rant just why not you have started opening the "bible of C" 10 yrs ago. But i would like to keep the option open as to not being marked as a funboy. Cheers