PDA

View Full Version : Is the Propeller the right tool to Learn C



JCee
12-17-2009, 06:37 AM
I have become familiar with the Propeller+Spin, and a little Assembly over the past 2 years. ·Prior to the Propeller, I experimented with the Basic stamp, flashing LEDs.· As my exposure to microcontrollers and other embedded projects grows I find that C is the dominant language.·
·
I have read other posts asking “Is Spin hard to learn”,· my take is that once you know how to “program” learning different a syntax is not hard it just takes time.· I found the shift from Spin to ASM much harder than from Basic to Spin. ·I had to learn how to “program” all over again with Assembly.·
·
Getting on to the question; I need to learn C and I am wondering if the propeller is the right platform.· I know Catalina and ICC are available to compile C to run on the propeller but this is not the *native* language.
·
Should I try to learn C on the Propeller or (dare I say) Arduino.·
·
Don’t take this post the wrong way, I am not trying to promote another microcontroller just trying to get more tools in my toolbox.

evanh
12-17-2009, 06:42 AM
C on the Prop will be fine.

But to *really* learn C you want to be coding a whole GUI or something substantial with large quantities of dynamic objects.

RossH
12-17-2009, 07:03 AM
@JCee,

Ok, I'm biased - but I think the Prop is a fantastic platform for C.

C is at least as "native" to the Prop as SPIN. SPIN is an interpreted byte-coded language executed by a SPIN interpreter. C compiles to PASM instructions executed via an LMM Kernel. The only thing that makes SPIN appear more "native" is that the SPIN interpreter is built into every Prop while the LMM Kernel has to be explicitly loaded on boot. But such details are all hidden from you in either language.

C for LMM programs is faster than SPIN, and for XMM programs C allows much larger programs to be run, and is still competitive with SPIN.

Ross.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Catalina - a FREE C compiler for the Propeller - see Catalina (http://forums.parallax.com/showthread.php?p=844004)

Yoda
12-17-2009, 07:15 AM
@evanh I would have to strongly disagree - you seem to be describing C++ not C. Trying to do GUIs and dynamic objects will tend to introduce you to bad techniques for "bare metal" type programming that C is strong for. Learning to control hardware and managing memory by hand is a better way to learn. Then move to GUI's, objects, etc.

localroger
12-17-2009, 07:43 AM
No. There are tools on the Prop to do C but they exist mainly for people who learned C elsewhere and are used to it. The Prop is highly optimized for a certain kind of programming which does not rely on hardware stack frames -- when you know enough to know what I mean by that, you'll be ready to use C on the Prop if you have a good reason.

Editing to elaborate...

C is widely regarded as "portable assembly language" (an assessment I disagree with) but it gives you maximum speed with some high level conveniences and some very low level dangers.· There are very low level C environments that don't use stack frames and other features common to high-level C environments, but if you "learn C" in such an environment you really don't "know C" compared to someone who learned C on an X86 processor or heck even an Arduino.

The Prop C environments must make a variety of compromises to work at all, since the Prop has no native stack and everyone agrees trying to compile C to Pasm is a waste of time with 512 instructions per cog.· So it's either compiled to Spin bytecode, in which case Spin really works better and is more convenient, or to LMM in which case it's faster than Spin but also takes three or four times the Hub RAM to do the same thing.· (I am developing industrial controls, and have come to the conclusion that Hub RAM is the limiting factor, possibly by design on Chip Gracey's part.· Makes you learn some optimization strategy to get anything done.)· Or you can go to one of the external memory schemes which are slower than Hub RAM access but offer virtually unlimited memory, even with the efficiency hit, compared to the 32K boundary of Spin.· The problem there is that you're suddenly in seriously nonstandard territory -- you can't just buy a Demoboard and try out some code, or share what you write here with the hope that many of us can help you make it work.· Whereas with other processors for which C is native, you can do that.

So what I'm getting at is, the Prop isn't a very good tool to learn C.· It's a much better tool for learning to program, if you start with its native languages Spin and Pasm, and if you get very far at all with that you'll be able to get into C very easily because many of the concepts are the same.··But for learning to program C is a horrible language full of bear traps and kludges.· If you want to learn to program, please pick another language.· If you need to learn C in particular, you will probably have more success with a platform which supports ICE debugging, which you will need to navigate past all the bear traps and kludges.

Post Edited (localroger) : 12/17/2009 1:06:39 AM GMT

RossH
12-17-2009, 07:52 AM
@localroger,

It is the compiler's job to take care of that level of detail.

You need to know that kind of stuff to WRITE a C compiler - not to USE one.

Writing C programs for the Prop is often easier than writing the equivalent program in SPIN.

Ross.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Catalina - a FREE C compiler for the Propeller - see Catalina (http://forums.parallax.com/showthread.php?p=844004)

Peter Jakacki
12-17-2009, 08:01 AM
RossH said...

<snip>
Writing C programs for the Prop is often easier than writing the equivalent program in SPIN.
Ross.


Do you have some examples to highlight where it is easier?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
*Peter*

localroger
12-17-2009, 08:07 AM
Ross -- see edited comment which I was editing while you posted.

I realize you have done an amazing job with Catalina, and for already written C code you have performed a miracle. But the poster was asking about learning C, and I really don't see how that's easier here than on one of the many platforms that have fully integrated debugging and tracing as well as native stack support and all the other stuff that makes C work better.

lonesock
12-17-2009, 08:13 AM
In my opinion one of the most important factors when learning a language is picking *projects* that are fun. You will hit snags and rough patches when learning, and especially at those times it is good to have the project pull you back in after a break. Since you need to learn C, and assuming you find the propeller fun to work with, then yes, I think the prop would be a good platform on which to learn. If you haven't enjoyed the prop so far, or don't have a project that sparks your interest, then I would pick a different platform for learning (try game programming or similar [8^). (Note: debugging will almost certainly be easier on another platform.)

Jonathan

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
lonesock
Piranha are people too.

evanh
12-17-2009, 08:18 AM
Managing dynamic structures is the way to learn C. C++ extensions just standardise it, albeit in bloatware.

jazzed
12-17-2009, 08:38 AM
It usually happens that some kind of big stink happens when C comes up around here. I'm not trying to start it or perpetuate it with the following, I'm just saying what I think would really be helpful for a newbie C programmer and what I wish someone had told me long, long ago.

C on Propeller is fine, but you should first get comfortable with C language in a friendly environment which means use a world class compiler and a debugger that lets you see the effect of your program, then move to C on Propeller or other micro. Many C programming tutorial pages are on the net ... one of the first returned by Google search is www.cprogramming.com/tutorial/c/lesson1.html (http://www.cprogramming.com/tutorial/c/lesson1.html) ... browse that or some other tutorial. When you're ready to get serious, install a world class compiler/tool chain like GNU or MSVC++, and have at it. Learn C first and not C++. C++ is important at some point, but has weird things that will confuse you as a beginner. When you're learning C forget about using C99 inline functions and dynamic sized arrays, because neither will be available on the C89 LCC based Propeller C variations. Books are nice if you like things to hold in your hand, but the help for library functions and other resources are available everywhere.

Best of luck. C-ya!
--Steve

Mike Green
12-17-2009, 08:51 AM
One recommendation for jazzed's suggestion, try Ch (www.softintegration.com/ (http://www.softintegration.com/)). It's free for non-commercial use and there are versions for Windows, Linux, and the MacOS. It's an interpreter, so debugging is easy and feedback is immediate. There are books on using it to learn C. Once you're comfortable with C, you can use it with the Propeller with Catalina.

RossH
12-17-2009, 10:01 AM
@all,

I genuinely believe the Prop is a fantastic way for people who already know the hardware (and SPIN and PASM) to learn C (which was JCee's original question). JCee is quite correct that C is by far the dominant language for embedded work - so why not learn it on an embedded platform? The Prop is such a rewarding and interactive platform - one Prop chip and a couple bits of "glue" and you have a fully functional computer - but one that can also drive all sorts of real equipment. It really does bring the fun back into programming. Learning a new language is much more fun when you can actually see your program do real stuff - control motors, light LEDs - who cares what it actually does, as long as it does stuff? I'm not riding any Catalina hobbyhorse here - I'm sure much the same would be true of ICC.

As for C being easier than SPIN - maybe that's just what I'm used to. But I can (and just have) coded this in about 30 seconds in C ...



#include <stdio.h>
main() {
char name[11];
printf("Enter your name: ");
scanf("%10s", name);
printf(" Hello %s", name);
}


... and I'm fairly confident I can compile and run it on any Propeller platform regardless of the actual hardware devices that are connected. But it would probably take me half an hour to code the equivalent in SPIN - and even then it would probably only run on one particular Prop, and if I wanted to run it on another Prop I'd need to know what devices were connected and then change the software to suit.

Ross.

EDIT: Just read jazzed's reply and also localrogers edited reply - ok, I agree that C is a language that can get you into trouble faster than almost any other - but so what? That's the nature of C, and pretending otherwise is not teaching you about C. You may as well go say "go learn Java first, because its safer". Ys it is - but doing so won't teach you C. By the way, PASM is even worse than C in this respect - so would you also suggest to a Propeller-head who already knew the Propeller (and also knew SPIN) to go learn assembly on some other "safer" platform first and then come back and tackle PASM on the Prop? I think instead (and I've seen it happen in these forums several times) that you'd simply tell them about the Prop's specific pitfalls, point them in the direction of any documents that might help them, and then encourage them to experiment!

On the other hand, the lack of a source level debugger is a problem on the Prop for newbies - one that I hope to rectify in Catalina at some point. But if ICC has one (I don't actually know) then I'd happily recommend a C newbie to use ICC instead of Catalina. They can come back to Catalina when they get serious about C http://forums.parallax.com/images/smilies/turn.gif (<- that's me keeping an eye out behind in case Richard sneaks up and belts me!)

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Catalina - a FREE C compiler for the Propeller - see Catalina (http://forums.parallax.com/showthread.php?p=844004)

Post Edited (RossH) : 12/17/2009 4:17:38 AM GMT

jazzed
12-17-2009, 11:24 AM
JCee wrote: >> Getting on to the question; I need to learn C and I am wondering if the propeller is the right platform.

With Propeller or any other micro, you have to worry about things like having to download hardware, having to remember to disconnect your terminal program before testing code (not an issue with jtag enabled devices), or dealing with memory constraints (when you know better, you can deal with that).

RossH with Catalina and Richard@ImageCraft have given a great deal of effort to making what you ask possible. In Richard's case, he spent a money and time on the project that will never pay him any return. RossH obviously has lots of personal pride in his product as evidenced by the platforms he is supporting. I appreciate the efforts of both.

If you like Propeller enough to try it, then great ... knowing RossH and Richard, they will bend over backwards for you to help you succeed. It is exceedingly unlikely that anyone supporting GNU or at MS will help more than by delivering high quality industry standard products.

For someone just starting out though, it's probably better to learn on a great and flexible IDE.

There is nothing to get in the way of learning C on Windows/Linux/OSX PC. The finest possible world class PC/Linux/OSX tools exist to help you on your way. Things such as a good IDE, helpful compiler/linker, and vivid/simple debug tools exist there and work perfectly for understanding clearly what is happening. You don't have to wonder about whether or not the hardware is working. You don't have to have any hardware at all other than your PC to learn.

I first learned C on Unix cc and TurboC. It took me years to realize there were bugs in the TurboC compiler ... all I knew for sure at the time was that the Unix cc seemed to work much better than TurboC on the PC. The PC "platform" was very immature compared to Unix. I'm not saying anything is wrong with Catalina or ICC. I'm just saying that learning on a very well known and unquestionably solid platform with no strings (or USB cables attached) is more productive than having to decide whether or not I have issues with my platform.

Cheers.
--Steve

JCee
12-17-2009, 12:25 PM
Thanks for all good feedback. I think I will try to learn C through some other online tutorials and try back with the prop once I have a better understanding. Parallax is known for their excellent documentation I wish they had some material to introduce C.

RossH
12-17-2009, 01:32 PM
Lone Ranger: Blast - lost another one, Tonto!
Tonto: What do you mean "we", kemosabee?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Catalina - a FREE C compiler for the Propeller - see Catalina (http://forums.parallax.com/showthread.php?p=844004)

heater
12-17-2009, 02:26 PM
Q. Why did The Lone Ranger shoot Tonto dead.?
A. He found out what "kimosabe" really meant.

What ever you do take the advice here and whilst learning C do your exercises on a PC. Not sure what is the best compiler for a beginner to start with but that interpreting environment suggestion sounds great. The old Borland Turbo tools were great for this kind of thing. Something whwere you can quickly edit and compile and step through the code in a debugger.

Never mind that stuff about dynamic structures and GUI's you want to learn C with a aim of using it on micro-controller I believe. In that world you are lucky to have any dynamic structures and GUIs are a large and complicated other world away.

No, exercise those parts of C you want in an MCU, integer arithmetic, bit twiddling/shifting, the normal conditional, loops, functions, parameters etc etc. It's quite possible to use C in a very Spin like way.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.

ImageCraft
12-17-2009, 02:32 PM
RossH said...
...

On the other hand, the lack of a source level debugger is a problem on the Prop for newbies - one that I hope to rectify in Catalina at some point. But if ICC has one (I don't actually know) then I'd happily recommend a C newbie to use ICC instead of Catalina. They can come back to Catalina when they get serious about C http://forums.parallax.com/images/smilies/turn.gif (<- that's me keeping an eye out behind in case Richard sneaks up and belts me!)


We spec'ed a debugger for Propeller C, but with us moving to CodeBlocks as our V8 IDE, we will probably just go ahead and generate ELF/DWARF and use GDB instead. As we have a foot in the door, when the market is ready, we will be there. Right now, I am up to my eyeballs optimizing for the PSoC and making progress with CodeBlocks and the Dinkumware full standard compliant library. Never a dull moment.

Nick Mueller
12-17-2009, 03:31 PM
And my comment! http://forums.parallax.com/images/smilies/smile.gif
The Prop isn't a bad platform for C. The missing stack-ops have absolutely nothing to do with that. SPIN also needs a stack. So this argument was worthless.
The suggestions to start C on a different platform that does have a debugger are valid to some extend. But then, SPIN also doesn't have a debugger and you mastered (at least to some extend) that too.

So, yes, learning C on the Prop is OK as long as you already learned some debugging techniques (in SPIN, PASM, whatever). C on a µC is different. Not from the language POV, but from the techniques. And *ANY* µC is quite the same to that respect. It's more bare-bones-programming than on a PC-platform.

So take the plunge, do it on the Prop! You already have a Prop, no gain in investing into a different platform.


Nick

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Never use force, just go for a bigger hammer!

The DIY Digital-Readout for mills, lathes etc.:
YADRO (http://www.yadro.de)

Leon
12-17-2009, 05:39 PM
I'd advise buying a copy of Kernighan and Ritchie's excellent The C Programming Language and downloading the DJGPP port of gcc for the PC. The excellent gdb bugger is available and lots of code libraries. There is an IDE for it.

Leon

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Amateur radio callsign: G1HSM

Nick Mueller
12-17-2009, 05:55 PM
> and downloading the DJGPP port of gcc for the PC.

DJGPP! OMG! The worst crap I have ever used!
Download the Open-Watcom compiler. The IDE is quite ... um ... antique, but the libs and the C-implementation is rock-solid and effective.


Nick

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Never use force, just go for a bigger hammer!

The DIY Digital-Readout for mills, lathes etc.:
YADRO (http://www.yadro.de)

Ale
12-17-2009, 06:51 PM
DJGPP crap ? ! You should have used Moco$oft's C compilers (and the horrible Programmer's workbench) to know how good djgpp is!. While the watcom compiler is better at generating code, djgpp was free at the time and also used for commercial software (quake was compiled with it while the previous games used watcom). djgpp is better used with RHIDE, without it... well it is just not the same http://forums.parallax.com/images/smilies/wink.gif.
Now, the watcom compiler has been opensourced some years ago.. so maybe it is now an better alternative.
But if you like gcc, then djgpp is the way to go.

C compilers for the PC exist for DOS and for winblows. You can use Netbeans and the C compiler provided by cygwin for instance, but alternatives exist aplenty. (Or Moco$oft's Visual C(rap) I mean Studio, supposedly the "best" IDE ever blah blah ).

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Visit some of my articles at Propeller Wiki:
MATH on the propeller propeller.wikispaces.com/MATH (http://propeller.wikispaces.com/MATH)
pPropQL: propeller.wikispaces.com/pPropQL (http://propeller.wikispaces.com/pPropQL)
pPropQL020: propeller.wikispaces.com/pPropQL020 (http://propeller.wikispaces.com/pPropQL020)
OMU for the pPropQL/020 propeller.wikispaces.com/OMU (http://propeller.wikispaces.com/OMU)

Leon
12-17-2009, 07:08 PM
Nick Mueller said...
> and downloading the DJGPP port of gcc for the PC.

DJGPP! OMG! The worst crap I have ever used!
Download the Open-Watcom compiler. The IDE is quite ... um ... antique, but the libs and the C-implementation is rock-solid and effective.


Nick


What's wrong with it? It's gcc, which is a pretty good compiler.

Leon

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Amateur radio callsign: G1HSM

Dr_Acula
12-17-2009, 08:19 PM
I'm a BASIC programmer. I know nothing about C. Well, virtually nothing. I understand Printf but I get lost with Scanf. I am vaguely aware that C is probably the best language for bit manipulation. I also would hazard a guess that if you want a nifty function to do xyz, someone probably has it written in C.

So, as a total newbie, let's see if this new-fangled 'C' language can run on a propeller.

RossH has issued a challenge which I reproduce below


As for C being easier than SPIN - maybe that's just what I'm used to. But I can (and just have) coded this in about 30 seconds in C ...

#include <stdio.h>
main() {
char name[11];
printf("Enter your name: ");
scanf("%10s", name);
printf(" Hello %s", name);
}

... and I'm fairly confident I can compile and run it on any Propeller platform regardless of the actual hardware devices that are connected. But it would probably take me half an hour to code the equivalent in SPIN - and even then it would probably only run on one particular Prop, and if I wanted to run it on another Prop I'd need to know what devices were connected and then change the software to suit.


Now remember, I don't understand C. Actually, I don't really understand Spin either, though I'm getting better with PASM. But I'm going to take RossH's program and I'm going to run it on a propeller.

Actually, I'm going to do more than that. I'm going to compile it on a propeller too. And even more than that, I'm going to write it on a propeller as well.

And I'll go even further. Even though I know RossH wrote is challenge for his own compiler, I'm going to use a different C compiler. Just to really test the intercompatability of this *tiny voice* language I'm quite coming to like...

Hardware is a DracBlade, which is essentially a Prop plus a ram chip plus a vga screen, keyboard and an sd card for storage. So it is self contained and can run without a PC once all the software has been copied over.

First, write the program. I'm using Wordstar. Next, save it as a .C file called ROSSH.C and TYPE it out to check it looks like RossH's original:




B>type rossh.c

#include <stdio.h>
main() {
char name[11];
printf("Enter your name: ");
scanf("%10s", name);
printf(" Hello %s", name);
}

B>




Drive B contains the disk image of the BDS C compiler which I obtained from the SIMH archive and dropped onto the sd card as a disk image. The instruction manual is available here www.bdsoft.com/resources/bdsc.html (http://www.bdsoft.com/resources/bdsc.html) in the primary downloads section.

To compile a program (I've not done this before on a propeller but I'm just following the instruction manual here), I understand I type something like "cc rossh"

so, here is a trace of what it does:




B>cc rossh

BD Software C Compiler v1.60 (part I)
36K elbowroom

BD Software C Compiler v1.60 (part II)
33K to spare

B>




Hmm - that seemed to work ok. So, the next instruction is something called a Linker (you could write a batch file to do this if you like, but this is fun and it doesn't seem to have gone wrong so far)
"clink rossh"

and here is the trace:



B>clink rossh

BD Software C Linker v1.60

Last code address: 175C
Externals start at 175D, occupy 0006 bytes, last byte at 1762
Top of memory: E405
Stack space: CCA3
Writing output...
43K link space remaining

B>




Hey, that seemed to work. And I just noticed something nifty. I've got 43k left and I'm using a propeller with only 32k of ram. Groovy..

Oh well, can't put it off any longer. Time to run this program and see if it crashes and burns...




B>rossh

Enter your name: Dr_Acula
Hello Dr_Acula
B>





Well, there you go. It worked. Grr. Just wait till I tell my BASIC programmer friends...

Not only did it work, but RossH seems to have his own compiler which does the above even more easily.

So - is the prop a good platform for learning C? Well, I don't know any C and I just wrote a program and got it to work first time, so I reckon the answer is a resounding YES!

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller (http://www.smarthome.viviti.com/propeller)

Post Edited (Dr_Acula) : 12/17/2009 1:29:02 PM GMT

heater
12-17-2009, 08:23 PM
JCee: I think from the responses here you have just discovered why Parallax went with Spin and their Prop Tool for the Prop rather than C :)

C has some tricky features to master but first you have to figure out how on earth to get your compiler to do anything!

Then you get sucked into the wonderful world of Make files and such....

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.

heater
12-17-2009, 08:32 PM
Dr_A: Funny I did not think of that. You really can learn C actually ON the Prop. No PC required at all !

caveats:
1) Setting yourself up with a Prop + RAM that runs CP/M may not be an option.
2) The dialect of C that BDS implements is rather ancient now.

When you are done with C you can move on to explore FORTRAN, ALGOL, PASCAL, PL/M, ADA and more. All with nothing much more than Prop + RAM + SD card + keyboard + VGA :)

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.

Ale
12-17-2009, 08:33 PM
heater: if you only have one big file... you can skip make. gcc will do it all for you http://forums.parallax.com/images/smilies/wink.gif... other compilers may not. But if you are already programming in C, then using 2 or 3 command line tools shouldn't be a problem as far as you know which options to use in every case, something not always clear :-(.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Visit some of my articles at Propeller Wiki:
MATH on the propeller propeller.wikispaces.com/MATH (http://propeller.wikispaces.com/MATH)
pPropQL: propeller.wikispaces.com/pPropQL (http://propeller.wikispaces.com/pPropQL)
pPropQL020: propeller.wikispaces.com/pPropQL020 (http://propeller.wikispaces.com/pPropQL020)
OMU for the pPropQL/020 propeller.wikispaces.com/OMU (http://propeller.wikispaces.com/OMU)

heater
12-17-2009, 09:11 PM
Yeah, yeah, I know:)

Provided you know that when you compile hello.c with GCC the resulting executable is called "a.out" rather than anything sensible like "hello". Or provided you know how to tell GCC what to call the output. For a total newbie getting started with all this nonsense can be a trial. As you say "not always clear".

Might I suggest, for first steps in C use the most wonderful "Tiny C Compiler" from here bellard.org/tcc/ (http://bellard.org/tcc/)

This thing is amazing. For example:
1) Edit your first hello world program in file hello.c
2) Compile and run it with one simple command: "tcc -run hello.c"

Bingo! it compiles the thing and runs it before you can bat an eye.

Also available for Windows.

Edit: Blimey TCC can compile 10 times faster than GCC. And it can build a Linux kernel in 10 seconds!

If this tiny thing can do that Linux on the prop cannot be far away:)

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.

Post Edited (heater) : 12/17/2009 2:18:09 PM GMT

Nick Mueller
12-17-2009, 11:07 PM
> What's wrong with it? It's gcc, which is a pretty good compiler.

DJGPP used (last time I tried it was about 3 years ago) an outdated gcc. There was something with the memory-model (no choice or something like that). Compiler accepted bad constructs without warning or error, very little checking etc. don't remember that well. Only thing was that I was willing to $$$-buy one (for DOS) just to get rid of it. Code-size 20% more than Open-Watcom.


Nick

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Never use force, just go for a bigger hammer!

The DIY Digital-Readout for mills, lathes etc.:
YADRO (http://www.yadro.de)

Nick Mueller
12-17-2009, 11:25 PM
> C has some tricky features to master but first you have to figure out how on earth to get your compiler to do anything!
> Then you get sucked into the wonderful world of Make files and such....

Try ImageCraft's ICCProp! I never had to make a make-file. And for the compiler to do something ... well ... click on an icon! http://forums.parallax.com/images/smilies/smile.gif


Nick

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Never use force, just go for a bigger hammer!

The DIY Digital-Readout for mills, lathes etc.:
YADRO (http://www.yadro.de)

Leon
12-18-2009, 12:02 AM
Nick Mueller said...
> What's wrong with it? It's gcc, which is a pretty good compiler.

DJGPP used (last time I tried it was about 3 years ago) an outdated gcc. There was something with the memory-model (no choice or something like that). Compiler accepted bad constructs without warning or error, very little checking etc. don't remember that well. Only thing was that I was willing to $$$-buy one (for DOS) just to get rid of it. Code-size 20% more than Open-Watcom.


Nick


Just use switches like -Wall to get better source code checking. Checking can be about as strict as Lint with the correct switches.

Code size and speed can be optimised, as with most compilers.

Running gcc under Cygwin is another option - most of the GNU utilities are available.

Leon

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Amateur radio callsign: G1HSM

Post Edited (Leon) : 12/17/2009 5:09:09 PM GMT

Nick Mueller
12-18-2009, 01:50 AM
> Just use switches like -Wall to get better source code checking. Checking can be about as strict as Lint with the correct switches.

Done that! And it is as far away from lint as possible.
I'm always working with the highest warning level and I once had PClint.


Nick

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Never use force, just go for a bigger hammer!

The DIY Digital-Readout for mills, lathes etc.:
YADRO (http://www.yadro.de)

jazzed
12-18-2009, 01:54 AM
Yup, as expected, stinky thread :)

Code::Blocks with Mingw GNU is a close functional alternative to MSVC++.
Code::Blocks debug functionality is less useful than MSVC++ though. Both are free.

www.codeblocks.org/ (http://www.codeblocks.org/) <-- Codeblocks home page.
www.codeblocks.org/downloads/5 (http://www.codeblocks.org/downloads/5) No strings attached.

www.microsoft.com/Express/VC/ (http://www.microsoft.com/Express/VC/) Registration required.

ericball
12-18-2009, 02:16 AM
You should learn C in an environment you are familar with to accomplish tasks which you are interested in using tools which are well documented, supported and easy to use.

Personally, I first "learned" C in high school two decades ago, but I didn't really become proficient until University where I used it for both coursework and personal projects. I still have Borland's free C++ compiler installed on my work laptop for creating tools as I need them. (However, I never really got into C++. The ASM part of my brain thinks objects would generate ugly ML.)

IMHO the main advantages of C are: 1. it's relatively portable 2. the common libraries 3. fun with pointers!

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Composite NTSC sprite driver: Forum (http://forums.parallax.com/showthread.php?p=800114)
NTSC & PAL driver templates: ObEx (http://obex.parallax.com/objects/483/) Forum (http://forums.parallax.com/showthread.php?p=803904)
OnePinTVText driver: ObEx (http://obex.parallax.com/objects/480/) Forum (http://forums.parallax.com/showthread.php?p=822453)

lonesock
12-18-2009, 02:19 AM
jazzed said...
...
www.microsoft.com/Express/VC/ (http://www.microsoft.com/Express/VC/) Registration required.

Note: you are not required to register if you download the ISO image and burn it to a disc. This was to allow deployment to PCs not on a network. [8^)

Jonathan

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
lonesock
Piranha are people too.

JCee
12-18-2009, 02:49 AM
Dr_Acula
What a cool example, I need one of those board to take with me to the in-laws next week. Will it do NTSC.

Ale
12-18-2009, 04:02 AM
ericball said...
The ASM part of my brain thinks objects would generate ugly ML.)


I had the great idea of having a look at the code produce for some class programmed using C++ with all the "abstraction" and so on... and was almost the same code as an equivalent C portion... then I thought... what ? everything is a lie to the programmer !... then I just lost faith in OOP (it is just a lie) and well I continued using C and ASM and was happy ever after http://forums.parallax.com/images/smilies/wink.gif

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Visit some of my articles at Propeller Wiki:
MATH on the propeller propeller.wikispaces.com/MATH (http://propeller.wikispaces.com/MATH)
pPropQL: propeller.wikispaces.com/pPropQL (http://propeller.wikispaces.com/pPropQL)
pPropQL020: propeller.wikispaces.com/pPropQL020 (http://propeller.wikispaces.com/pPropQL020)
OMU for the pPropQL/020 propeller.wikispaces.com/OMU (http://propeller.wikispaces.com/OMU)

heater
12-18-2009, 04:14 AM
Well you should not see much "baggage" in the asm produced by a C++ compiler.

But somewhere it has to put those jump tables that dispatch execution to the right methods of polymorphic classes. vtables. Those you would normally have to code explicitly in structs in C or somewhere anyway to do "object oriented" programming in plain C. Look at the Linux kernel it is full of such tables explicitly coded in C.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.

RossH
12-18-2009, 04:55 AM
@Dr_Acula,

http://forums.parallax.com/images/smilies/roll.gif

Ross.

P.S. I particularly like how you ended up with more RAM than you started with!

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Catalina - a FREE C compiler for the Propeller - see Catalina (http://forums.parallax.com/showthread.php?p=844004)

Dr_Acula
12-18-2009, 06:21 AM
Re "P.S. I particularly like how you ended up with more RAM than you started with!".. Ha ha, cue scary Theremin music, welcome to the Twilight Zone...

Re NTSC on this board, yes it can - just a matter of putting in the 4 TV driver resistors rather than the 8 VGA resistors. You end up with 4 pins free with TV which is a bonus. But TV doesn't seem as crisp at 80x40 text. Maybe I'm using the wrong driver, but TV seems better suited for graphics and VGA for text. Oh, and I haven't linked a graphics TV driver into the code, though it probably is only a couple of lines of spin. Attached picture is quite blocky and blurry on a big TV (even though the photo has smoothed it out somewhat) and on a small 4" LCD TV it is still blocky and blurry.

Getting back to the topic, RossH, would you be able to do a similar walk-through for Catalina? Maybe it is easy, but a few things are not explicitly stated, eg when you use scanf, is that scanning a local keyboard, or is it scanning a serial port talking to a terminal program that is part of Catalina, or is it something else?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller (http://www.smarthome.viviti.com/propeller)

Post Edited (Dr_Acula) : 12/17/2009 11:38:30 PM GMT

RossH
12-18-2009, 06:51 AM
Hi Dr_Acula,

In C, printf always outputs to 'standard output' and scanf always reads from 'standard input'. You don't really need to know what this means - just remember that in Catalina, 'standard output' is always the screen driver you choose to use, and 'standard input' is always the keyboard driver.

So if your board works with the standard parallax keyboard, TV and VGA drivers, it should be a simple matter of adding the appropriate pin and clock definitions for your board into the 'Catalia_Common_Input.spin' file (I'd suggest creating a new target symbol - but you could also just temporarily hack one of the existing targets such as DEMO).

Then you're good to go:

To have Catalina use the keyboard as 'standard input' and the VGA output as 'standard output':

catalina test.c -lc -D DEMO -D VGA


To have Catalina use the keyboard as 'standard input' and the TV display as 'standard output':

catalina test.c -lc -D DEMO -D TV -D NTSC



If you need help in configuring a Catalina target, point me to the spec for your board.

Ross.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Catalina - a FREE C compiler for the Propeller - see Catalina (http://forums.parallax.com/showthread.php?p=844004)

Dr_Acula
12-18-2009, 09:22 AM
Ok, RossH, I'm keen. And for our original poster, I have no idea what I'm doing here but maybe this walkthrough might be useful to someone if we document it as we go.

First question - you typed "catalina xxx xxx" etc

Is that in a dos window or a batch file or the Run command in Windows or something else, eg an IDE of some sort?

Where I am up to - I followed your link then downloaded all the files I could find on the first few posts and extracted them all to C:\Program Files\Catalina. There are some programs and a number of folders so the structure all seems to be there.

Re the hardware, ok, let's start from scratch and install catalina on some new hardware (though for our original poster, the hardware would presumably be the demo board. Even though the 40 pin prop is pretty cool just by itself, sooner or later you want to add a keyboard and display as a bare minimum, and the demo board comes already made).

For my hardware, VGA is P16 to P23. Keyboard is P26 and P27 (standard pins I think). No mouse. SD card is P12 to P15 (DO, CLK, DI and CS in that order). The serial port is 31,30 as per the demo board. www.smarthome.viviti.com/files/documents/Propeller_v2.pdf (http://www.smarthome.viviti.com/files/documents/Propeller_v2.pdf)

Is that enough info to tweak your setup file?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller (http://www.smarthome.viviti.com/propeller)

Post Edited (Dr_Acula) : 12/18/2009 2:29:13 AM GMT

RossH
12-18-2009, 09:42 AM
Hi Dr_Acula,

Ok - I didn't realize you meant to start from quite so far back - I would encourage you to read the Catalina documents. You've probably already downloaded them - but in case you haven't they're in the 'Catalina_documents.zip' file (second post in this thread (http://forums.parallax.com/showthread.php?p=844004)).

It sounds like you've already installed correctly, so you're nearly there. One of the documents ("Getting Started with Catalina") is a step-by-step tutorial that goes through the details you need - including setting up, compiling some demo programs, customizing the Catalina_Common_Input.spin file for your platform, and loading and running the compiled result on the Propeller. As well as details on what all the command-line options I used (VGA, NTSC etc) actually mean.

But to answer your first question - yes, these commands are entered in a Windows command interpreter. For the rest, the best thing is to read the tutorial document.

I'm at work at the moment, but this evening I'll use the PIN definitions you provided to set up a Catalina_Common_Input file you can use, and post it in this thread. Or you can have a go yourself - it's not that difficult for a simple single CPU Prop platform (it gets complex for a multi-prop platforms).

Ross.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Catalina - a FREE C compiler for the Propeller - see Catalina (http://forums.parallax.com/showthread.php?p=844004)

Post Edited (RossH) : 12/18/2009 3:11:07 AM GMT

RossH
12-18-2009, 10:08 AM
@Dr_Acula,

Ok - lunchtime here, so I had a quick go at a 'Catalina_Input.spin' file. Save it over the existing version in 'C:\Program Files\Catalina\target\input\'.

I have called your board DR_ACULA, so what you need to do is add the following flags to all your compiles:

-D DR_ACULA -D VGA -D NO_MOUSE


For example:

catalina test.c -lc -D DR_ACULA -D VGA -D NO_MOUSE


If all goes well, this will result in a file called test.binary which you just load using the normal Parallax tools.

Ross.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Catalina - a FREE C compiler for the Propeller - see Catalina (http://forums.parallax.com/showthread.php?p=844004)

Dr_Acula
12-18-2009, 10:16 AM
Great, that seems pretty straightforward. I'm at work for the next 8 hours but am looking forward to getting this "hello world" example going on another compiler.

I see you have a whole lot of spin programs in one of the folders for various hardware configurations, which I think further emphasises the point that the prop is quite a valid platform for learning C.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller (http://www.smarthome.viviti.com/propeller)

RossH
12-18-2009, 10:25 AM
@Dr_Acula,

Correct - but you don't normally need to worry about them. Catalina builds the approproate run-time environment on every compile based on (1) the hardware pin definitions in the Catalina_Common file and (2) the options you specify on the command line.

I really should do some work on generating a Catalina_Common file that specifies ALL the common Prop boards - but the trouble is that if I don't have one then I can't actually test it. That's why I currently only say I support the Hydra, Hybrid, TriBladeProp and Morpheus - even the Demo board I've not actually tested (although I believe it will work ok).

Ross.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Catalina - a FREE C compiler for the Propeller - see Catalina (http://forums.parallax.com/showthread.php?p=844004)

Dr_Acula
12-18-2009, 10:43 AM
Well I guess I need to send you one. Only catch is that I have run out, but I just got an email saying the next batch have been shipped yesterday. It would be cool to have raw C running rather than C running through CP/M with every instruction emulated. I'd be expecting a speed increase.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller (http://www.smarthome.viviti.com/propeller)

RossH
12-18-2009, 11:25 AM
@Dr_Acula,

If you don't need any new drivers developed for your board, and the definitions I posted work ok, then you don't need to actually send me a board. Just let me know what I should call your board and I will include the definitions in all future releases of Catalina.

Ross.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Catalina - a FREE C compiler for the Propeller - see Catalina (http://forums.parallax.com/showthread.php?p=844004)

RossH
12-18-2009, 05:08 PM
@Dr_Acula,

A problem - I just compiled this on my Hydra, and it works fine if I make it an EMM or XMM program, but the LMM version is too large. You will probably find the same.

It seems that including 'scanf' pulls in way too much of the C library - including floating point stuff that is not necessary.

I'll investigate tomorrow and see what I can do about it.

Ross.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Catalina - a FREE C compiler for the Propeller - see Catalina (http://forums.parallax.com/showthread.php?p=844004)

Dr_Acula
12-18-2009, 05:29 PM
We have 512k of ram to store things (if you want to code the drivers to move data in and out of the ram chip, that is!) I don't know much about LMM and the other memory models - are they more suited to ram or to sd memory?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller (http://www.smarthome.viviti.com/propeller)

RossH
12-18-2009, 06:02 PM
Hi Dr_Acula,

Ok, I found the problem - I was indeed pulling in floating point stuff I didn't need. Now fixed. I will release a new version of Catalina's C library tomorrow.

I didn't realize your board had addiitonal RAM available. That means you can use Catalina to build XMM programs that use the full 512k - but you'll need an XMM driver. If you want me to write you one, then I definitely will need one of your boards. But if your board uses the same XMM scheme as Cluso's boards, then Catalina may already have a suitable driver - I've written drivers for his TriBladeProp Blades #1 and #2, so if your board uses this type of access then we can use one of those. I haven't written anything for his RamBlade yet, but I seem to remember that he uses the same scheme as the TriBladeProp Blade #2.

I'll have a closer look at your hardware schematics tomorrow.

Ross.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Catalina - a FREE C compiler for the Propeller - see Catalina (http://forums.parallax.com/showthread.php?p=844004)

Dave Hein
12-18-2009, 10:50 PM
JCee said...
I have become familiar with the Propeller+Spin, and a little Assembly over the past 2 years. ·Prior to the Propeller, I experimented with the Basic stamp, flashing LEDs.· As my exposure to microcontrollers and other embedded projects grows I find that C is the dominant language.·
·
I have read other posts asking “Is Spin hard to learn”,· my take is that once you know how to “program” learning different a syntax is not hard it just takes time.· I found the shift from Spin to ASM much harder than from Basic to Spin. ·I had to learn how to “program” all over again with Assembly.·
·
Getting on to the question; I need to learn C and I am wondering if the propeller is the right platform.· I know Catalina and ICC are available to compile C to run on the propeller but this is not the *native* language.
·
Should I try to learn C on the Propeller or (dare I say) Arduino.·
·
Don’t take this post the wrong way, I am not trying to promote another microcontroller just trying to get more tools in my toolbox.
JCee,
I think you would be better off learning C on a PC.· As someone else suggested you can download the Watcom C compiler for free.· It is a simple command-line compiler without an IDE.· Since you already know Spin you shouldn't have any trouble programming in C.· Some of your Spin programs may translate directly to C on a line-by-line basis.· You should be able to write a "Hello World" program in minutes, and you can try different things from that point.
I learned C about 20 years ago after programming in FORTRAN before that.· It was an easy transition for me, even though most of my early C programs looked a lot like FORTRAN.· The trickiest part for me was learning about pointers, and pointers to pointers.· It also took we a while to fully understand C structs.· There are still a few things in the C syntax that I have to look up on occassion, such as doing a typedef of function pointer.
Dave

ericball
12-19-2009, 03:07 AM
Dr_Acula said...
Re NTSC on this board, yes it can - just a matter of putting in the 4 TV driver resistors rather than the 8 VGA resistors. You end up with 4 pins free with TV which is a bonus. But TV doesn't seem as crisp at 80x40 text. Maybe I'm using the wrong driver, but TV seems better suited for graphics and VGA for text. Oh, and I haven't linked a graphics TV driver into the code, though it probably is only a couple of lines of spin. Attached picture is quite blocky and blurry on a big TV (even though the photo has smoothed it out somewhat) and on a small 4" LCD TV it is still blocky and blurry.
There's a reason that older computers which used TVs for display either used fewer columns (i.e. 40x25) or monochrome text - the bandwidth of composite TV doesn't allow for better.· For NTSC the color signal is modulated into the luma signal at 3.57MHz which means if your display generates around 320 active pixels or more per line you will get color artifacts unless color is disabled.


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Composite NTSC sprite driver: Forum (http://forums.parallax.com/showthread.php?p=800114)
NTSC & PAL driver templates: ObEx (http://obex.parallax.com/objects/483/) Forum (http://forums.parallax.com/showthread.php?p=803904)
OnePinTVText driver: ObEx (http://obex.parallax.com/objects/480/) Forum (http://forums.parallax.com/showthread.php?p=822453)

potatohead
12-19-2009, 03:31 AM
...or you are careful about the color used.

The interlaced display significantly improves the usefulness of composite TV graphics. The 8x8 driver I recently tossed in the OBEX was based off your NTSC template. Interlaced makes a marked difference in text quality. Was surprising how much, particularly on newer TV display devices.

I have for testing, a simple LCD running at 320x240, or something. It's resolution limited, of course. Not too useful over 40 columns, as the pixels are just not there. It acts a lot like the Zenith on color artificats too.

Zenith 80's era television, with some color filter, but not an advanced comb filter. It displays color artifacts to a much higher degree than newer devices do. It cannot render 80 column text that's useful, unless color is not part of the signal. It also appears bandwidth limited, not able to resolve smaller monochrome pixels. I think this is typical of older TVs.

SONY WEGA NTSC TV. This one actually renders composite graphics very well. Text, at well aligned color combinations (White on Blue for example), interlaced is readable. Non interlaced is probably only useful to 64 columns. Monochrome is flat out excellent. This TV has more advanced comb filters, and is a CRT display.

Newer full resolution LCD device, looks to be late 90's era. A monochrome composite signal is very good. Color composite signals are nearly as good as the SONY. Non-interlaced signals perform very poorly, interlaced ones are good to 64 columns with a fair amount of color freedom.

Hi-Definition PC capture card. This one will render 80 off a composite display, and does so with more color freedom than any other device I have. Most of my screenies posted here are from that device. Monochrome signals are monitor quality, with very good individual pixel resolution. I find the capabilities of it's composite color rendering flat out excellent. No CRT TV has matched it, though the SONY comes close.

Newer Plasma HDTV. This one exhibits many of the qualities of the capture card. I'll have to take a photo. 80 column text, from a composite display is quite useful, both monochrome and color. It's nearly on par with the capture card. The real difference it it being very picky about the actual signal, where the capture card will actually display a signal with a high percentage of out of spec elements, both sync levels and timing. The HDTV, flat out won't. It's now my regular tester for final driver vetting.

NTSC resolution PC capture card. This is the "EZ-Capture" OBC linked here for $10. It's pretty lousy at anything over 320 pixels. Non-interlaced displays work best, color artifacts are moderate. I'm generally not happy with it for pushing the boundaries. I am happy with it as a representative device though. It's all around average, meaning a useful display on it, probably is useful across the board.

What I want to know is how the HDTV circuits work. They can render color well beyond the accepted norms to the point of being nearly as useful as S-Video is. There are artifacts, but they are no where near what I am used to. Reading 80 column color text on the Plasma was surprising. It should not have worked as well as it does, given the signal characteristics.

On my next board revision, where I plan on hacking something apart, I plan to run a series of S-video captures and display tests.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller Wiki: Share the coolness! (http://propeller.wikispaces.com/)
8x8 color 80 Column NTSC Text Object (http://obex.parallax.com/objects/550/)
Safety Tip: Life is as good as YOU think it is!

RossH
12-19-2009, 07:49 AM
@Dr_Acula,

New catalina library released (see the Catalina 2.2 thread) whcih saves 8kb of RAM for programs that do not need to use floating point I/O. To compile your test program with the new library, use a command like:



catalina test.c -lci -D DR_ACULA -D VGA -D NO_MOUSE


Note the use of the option -lci instead of the previous -lc

Ross.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Catalina - a FREE C compiler for the Propeller - see Catalina (http://forums.parallax.com/showthread.php?p=844004)

rokicki
12-19-2009, 08:11 AM
The HDTV probably uses a fast A/D converter and signal processing to generate the display, and as such is not constrained by real-world analog component
limits. It's even possible it contains some models of expected content (such as two-color character cells) and optimizes for such when it detects that content.

HollyMinkowski
12-19-2009, 08:36 AM
If you want to learn C for use on controllers then I
would recommend the arduino that you mentioned.

You would probably be programming an AVR on the arduino
using the free gnu C toolchain. This is an excellent setup and
I have written a lot of C code with this free compiler for the Atmega168 chip that
is common on arduino boards.

IMO the propeller is best programmed in PASM and Spin.

winavr.sourceforge.net/ (http://winavr.sourceforge.net/)


Or for gcc with an ARM board instead of an arduino board.
winarm.scienceprog.com/winarm-tools/quick-start-using-winarm.html (http://winarm.scienceprog.com/winarm-tools/quick-start-using-winarm.html)

Post Edited (HollyMinkowski) : 12/19/2009 1:41:59 AM GMT

JimInCA
12-20-2009, 12:14 AM
jazzed said...
Yup, as expected, stinky thread :)


www.microsoft.com/Express/VC/ (http://www.microsoft.com/Express/VC/) Registration required.



JCee

There's a little gem at the bottom of the above link. In the "Easy to Learn" section, there's a free e-book. "C++ Beginner's Guide", written by Herbert Schildt. Herbert Schildt is one of my all time favorite technical authors. I have purchased many of his books over the last twenty years and find them all well written, easy to understand, and with good examples. In fact, his book "C - The Complete Reference" has a place on my bookshelf at work and I still refer to it from time to time.

Being a fan of Herbert Schildt, I down loaded all twelve chapters plus the appendix and answer sections and combined them into one pdf. It came out to be 540 pages. This is a major piece of work by a well known author, and it's FREE!

I know that you want to learn C and this e-book is C++, but I still would recommend that you down load it and read through it. The information in the first seven chapters pertain equally to both C and C++ with the only exception being the use of cout/cin instead of printf/scanf. But if you can read through and understand the first seven chapters, then picking up the differences between C and C++ will be easy.

I also agree completely with what Holly said about the Arduino. I have one and find it quite easy to use. But then I also have a prop demo board and find it easy to use as well.

Jim...

JCee
12-20-2009, 02:36 AM
Ok here are my first impressions. I have started working with C on a PC rather than another microcontroller mainly because I already have a PC. I have been using this tutorial www.cprogramming.com/tutorial/c/lesson1.html (http://www.cprogramming.com/tutorial/c/lesson1.html) and I used the Tiny C Compiler bellard.org/tcc/ (http://bellard.org/tcc/)

Here are my first C programs



#include <stdio.h>

int main()
{
printf( "Hello World.\n" );
getchar();
return 0;
}








#include <stdio.h>

int main()
{
int number;

printf( "Please enter a number: " );
scanf( "%d", &number );
printf( "You entered %d", number );
getchar();
return 0;
}





Well that was super easy. In less than an hour I was reading inputs from a keyboard and displaying it on a screen, this leaves me with mixed feelings. I am glad that it worked as expected so easily. But I feel like there is a lot going on behind the scenes that I have no clue about. From what I understand so far stdio.h is a library of functions that get compiled with my program. I assume similar to the way OBEX has functions that I can use as needed. If I was going to do something similar for the Propeller, I would need to use some sort of display driver (VGA or TV) and I would also need a keyboard driver. Or I could use fullduplexserial and a terminal program and get similar results.

C takes care of all the initialization of other functions and pin definitions like "tv.start(12)" would be needed in Spin. There has been countless times I got unexpected results because I forgot to initialize a function. I think the need to initialize functions is based more on the embedded hardware rather than the language. If i was programming C on an embedded controller I assume I would have to make some pin definitions. So comparing C to Spin is a bit of apples-to-oranges.

So far I like Spin/Propeller Tool better because of the transparency, I can tell exactly what get compiled to make up my program. Granted a lot more information is needed in the "header" section of Spin but this makes it easier to understand what is being used. From a learning perspective Spin wins, for ease-of-use C wins. I have a few more tutorials to complete before I attempt C on the Propeller.

Nick Mueller
12-20-2009, 02:43 AM
> download the Watcom C compiler for free. It is a simple command-line compiler without an IDE.

Open Watcom has an IDE. Not the most polished one, but workable with.


Nick

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Never use force, just go for a bigger hammer!

The DIY Digital-Readout for mills, lathes etc.:
YADRO (http://www.yadro.de)

jazzed
12-20-2009, 02:58 AM
JCee said...
... Super easy. In less than an hour I was reading inputs from a keyboard and displaying it on a screen, this leaves me with mixed feelings. I am glad that it worked as expected so easily. But I feel like there is a lot going on behind the scenes that I have no clue about. ....

Sure, there are lots of things going on. For the time being though, you are learning the "common part" of C programming that you can apply to using *any* micro-controller or package. When you know the fundamentals, it makes specializing easy. Embedded systems (micro-controllers and all the baggage that comes with them) is just one specialization. Enjoy the ride. There is much more to learn on the way.

Dr_Acula
12-20-2009, 07:42 AM
@RossH - I'm looking forward to checking that code when I get home from work.

@JCee, great to hear you got C working on a PC. If you are learning C this quickly you will probably learn Spin just as quickly. I read a study once showing people who are bilingual are less likely to get dementia. I'd like to think that applies to computer languages too - ie don't be afraid to learn several languages, all at the same time if you like!

Have you got a propeller running yet? I found it quite a steep learning curve getting a led to flash, but that it was quite easy going from that to a vga display, keyboard and plugging together code from the OBEX library. What is the project you are working on?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller (http://www.smarthome.viviti.com/propeller)

Post Edited (Dr_Acula) : 12/20/2009 12:52:43 AM GMT

jazzed
12-20-2009, 12:35 PM
@JCee,

I was just looking at the www.cprogramming.com/tutorial.html#ctutorial (http://www.cprogramming.com/tutorial.html#ctutorial) ... nothing better to do on Saturday night a week before Christmas :) ....

It occurred to me that the tutorial would be very good to re-write for SPIN if you have time. The program "int main(int argc, char**argv)" arguments don't apply. The varargs concept has to be done a cheater's way in SPIN. The linked-list and binary tree data structures could be skipped but that and more is possible in SPIN. Aside from those caveats, the translation should be fairly easy. If you can re-write that tutorial, then you would have accomplished learning much of both languages and many newbies who follow would be very happy too. A beginner writing for other beginners is an effective tool for all concerned. Old salts can help by keeping things correct ... but that's about it usually.

One thing you mentioned may be somewhat mis-understood: the C header files mostly define the library usage rather than implementation. This allows using binaries without having source code. By comparison SPIN is more library implementation focused than C. To get objects with C, you have to go C++ or learn how to do it "by hand" .... Too bad C++ is so weird. C# is much better to me (except the .net reputation problem).

When it comes to applying your new C skills to Propeller, many people will be happy to help. Just filter the agenda junk and keep your eye on the ball.

Best of luck.
--Steve