ghetto programming

how do i program a avr micro processer with perl? and where will i get guides on how to do this?

sort by: active | newest | oldest
1-10 of 27Next »
cris1133 (author) 9 years ago
is there any difference between c and c# ?
gmoon cris11339 years ago
Yep. C# is an object oriented language, similar to Java and sort of what C++ could have been...

You probably won't use either C++ or C#. The more complex and OO features will likely make the code too bloated for a microcontroller. And the C library for AVRGCC, avrlibc doesn't have a C++ equivalent (although there might be wrapper out there by now.)

But all these other languages (Java and PHP, too) are C based. So time spent learning C is well spent....
cris1133 (author)  gmoon9 years ago
gmoon cris11339 years ago
When I wrote 'based,' I was referring to language syntax, not the underpinnings of execution. PHP, Perl and C all share similar syntax, and it's based on 'C.'

Isn't writing programs your main concern?

All three languages share many of the same control structures (if, while, for, etc.), use bracketing {}, are function based ( as in: myfunction() ), and terminate statements with a semi-colon.

Both perl and PHP are interpreted scripting languages, and both run interactively in the shell. Perl and PHP code can also be stored in a script file, and executed by invoking the file name. Both are commonly embedded in HTML files, and operate as server-side scripting.

However, PHP and perl are very much abstracted compared to 'C.' One example is variable definition. While you can define certain variable types (scalars, arrays, etc.) they are often implied types, not explicit types.

It's simple to declare an array of 8 bytes in C:

uint8_t my_array[] = {85, 86, 89, 90, 101, 102, 105, 106;

or (using a general syntax for unsigned short (byte) integer)

unsigned short int my_array[] ={85, 86, 89, 90, 101, 102, 105, 106};

Declared as such, this array occupies exactly 8 bytes, and the memory can also be accessed directly using the variable name (very important for micro controllers.)

There's no way to do that in perl or PHP--variables are abstracted, and integers are automatic and 'general.' A PHP or perl integer might take 4 bytes, 8 bytes, 12 bytes (or whatever) to store, and the user is insulated from even knowing how they are stored.

So in perl (or PHP) an array of 8 bytes might occupy 64 bytes (and more, with overhead.) That's pretty bad, if you only have 256 or 512 bytes of RAM in the micro controller.

(oh, and there are C interpreters (interactive shell) available....even if 99.9% of C programmers compile.)
gmoon gmoon9 years ago
The forums won't display square brackets, so the C array declarations above aren't correct (and I dropped a curly bracket editing one, also.) But you get the gist....
Try shutting off caps lock... or take your finger off shift... PHP is based on C, Perl is based on shell...
Yes, C# is more streamlined and powerful and better equipped to be used inside of .NET
cris1133 (author) 9 years ago
what about java?
cris1133 (author) 9 years ago
ive been trying vb, and its not that bad the code is well together and not as ugly as c
gmoon cris11339 years ago
Hehe. Them's fightin' words...;-)

Actually, if you're already familiar with perl, what's the biggie about C? They share the much the same syntax and control structures. You'll get use to explicitly declaring variables, etc. (actually, BASIC originally handled variables that way, too.)

For all it's power, C is one of the smallest (in defined terms) languages devised. The vast majority of the 'standard C' language is function based, and that functionality was moved to libraries (stdio, math, stdlib, string, etc.) There are very few 'key words' in C, unlike VB or scripting languages.

I know that's frustrating for programmers who are used to using verbose languages; for complex ADTs, string manipulation, etc. But that is exactly the strength of it for micro's very 'lean and mean.'
1-10 of 27Next »