Author Topic: learning C for pic  (Read 7604 times)

0 Members and 1 Guest are viewing this topic.

Offline Simon

  • Global Moderator
  • *****
  • Posts: 13128
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
learning C for pic
« on: November 22, 2010, 08:22:25 am »
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 ?
https://www.simonselectronics.co.uk/shop
Varied stock of test instruments and components including EEVblog gear.
Also, if you want to get ripped off: https://www.ebay.co.uk/usr/simons_electronics?_trksid=p2047675.l2559
 

Offline jahonen

  • Super Contributor
  • ***
  • Posts: 1045
  • Country: fi
Re: learning C for pic
« Reply #1 on: November 22, 2010, 08:27:06 am »
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
 

Offline Kiriakos-GR

  • Super Contributor
  • ***
  • Banned!
  • Posts: 3525
  • Country: gr
  • User is banned.
    • Honda AX-1 rebuild
Re: learning C for pic
« Reply #2 on: November 22, 2010, 08:31:41 am »
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.  
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 13128
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: learning C for pic
« Reply #3 on: November 22, 2010, 08:50:32 am »
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
https://www.simonselectronics.co.uk/shop
Varied stock of test instruments and components including EEVblog gear.
Also, if you want to get ripped off: https://www.ebay.co.uk/usr/simons_electronics?_trksid=p2047675.l2559
 

Offline DaveW

  • Frequent Contributor
  • **
  • Posts: 275
  • Country: gb
    • WattCircuit
Re: learning C for pic
« Reply #4 on: November 22, 2010, 08:55:25 am »
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 download
http://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)
 

alm

  • Guest
Re: learning C for pic
« Reply #5 on: November 22, 2010, 09:01:28 am »
Mostly because its old and backwards compatible.
Backwards 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.
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 13128
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: learning C for pic
« Reply #6 on: November 22, 2010, 09:01:54 am »
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
https://www.simonselectronics.co.uk/shop
Varied stock of test instruments and components including EEVblog gear.
Also, if you want to get ripped off: https://www.ebay.co.uk/usr/simons_electronics?_trksid=p2047675.l2559
 

Offline Mechatrommer

  • Super Contributor
  • ***
  • Posts: 8849
  • Country: my
  • reassessing directives...
Re: learning C for pic
« Reply #7 on: November 22, 2010, 11:40:33 am »
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.
if something can select, how cant it be intelligent? if something is intelligent, how cant it exist?
 

Offline migsantiago

  • Frequent Contributor
  • **
  • Posts: 381
  • Country: 00
    • MigSantiago's Web Site
Re: learning C for pic
« Reply #8 on: November 22, 2010, 11:48:31 am »
Use C.

Eventually, it will let you jump to higher platforms such as C++, C# or Java.

Basic won't.
 

Offline TheDirty

  • Frequent Contributor
  • **
  • Posts: 440
  • Country: ca
Re: learning C for pic
« Reply #9 on: November 22, 2010, 11:54:51 am »
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.
Mark Higgins
 

Offline Mechatrommer

  • Super Contributor
  • ***
  • Posts: 8849
  • Country: my
  • reassessing directives...
Re: learning C for pic
« Reply #10 on: November 22, 2010, 12:15:04 pm »
C is be far and away the most popular language for microcontrollers.
not just microcontroller, C is number one in any programming language, its the closest thing to assembly.
if something can select, how cant it be intelligent? if something is intelligent, how cant it exist?
 

Offline TheDirty

  • Frequent Contributor
  • **
  • Posts: 440
  • Country: ca
Re: learning C for pic
« Reply #11 on: November 22, 2010, 12:42:55 pm »
not just microcontroller, C is number one in any programming language, its the closest thing to assembly.

I 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.
Mark Higgins
 

alm

  • Guest
Re: learning C for pic
« Reply #12 on: November 22, 2010, 01:00:10 pm »
I don't know of anyone that uses K&R or ANSI C for programming PC's now-a-days.
Assuming 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.
 

Offline TheDirty

  • Frequent Contributor
  • **
  • Posts: 440
  • Country: ca
Re: learning C for pic
« Reply #13 on: November 22, 2010, 01:08:48 pm »
Quote
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.
This 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.
Mark Higgins
 

Offline Hypernova

  • Supporter
  • ****
  • Posts: 654
  • Country: tw
Re: learning C for pic
« Reply #14 on: November 22, 2010, 03:41:09 pm »
not just microcontroller, C is number one in any programming language, its the closest thing to assembly.

I 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.

Of course not for FPGA's, those take hardware descriptions not software instructions.
 

Offline joelby

  • Frequent Contributor
  • **
  • Posts: 634
Re: learning C for pic
« Reply #15 on: November 22, 2010, 06:37:11 pm »
Of course not for FPGA's, those take hardware descriptions not software instructions.

Actually there are translators for using (non-ANSI) C/C++/SystemC on FPGAs, though I'm not sure how popular this is.
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 13128
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: learning C for pic
« Reply #16 on: November 22, 2010, 06:48:27 pm »
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  ;D). But with the future in mind and the rest of the programming world speaking C I guess I should too
https://www.simonselectronics.co.uk/shop
Varied stock of test instruments and components including EEVblog gear.
Also, if you want to get ripped off: https://www.ebay.co.uk/usr/simons_electronics?_trksid=p2047675.l2559
 

Offline Mechatrommer

  • Super Contributor
  • ***
  • Posts: 8849
  • Country: my
  • reassessing directives...
Re: learning C for pic
« Reply #17 on: November 22, 2010, 10:55:19 pm »
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.
« Last Edit: November 22, 2010, 10:56:54 pm by shafri »
if something can select, how cant it be intelligent? if something is intelligent, how cant it exist?
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 13128
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: learning C for pic
« Reply #18 on: November 22, 2010, 11:35:29 pm »
and i'm only talking basic versus c in pics
https://www.simonselectronics.co.uk/shop
Varied stock of test instruments and components including EEVblog gear.
Also, if you want to get ripped off: https://www.ebay.co.uk/usr/simons_electronics?_trksid=p2047675.l2559
 

Offline Mechatrommer

  • Super Contributor
  • ***
  • Posts: 8849
  • Country: my
  • reassessing directives...
Re: learning C for pic
« Reply #19 on: November 23, 2010, 12:08:36 am »
and i'm only talking basic versus c in pics
i'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 ;)
if something can select, how cant it be intelligent? if something is intelligent, how cant it exist?
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf