Writing Code in the Arduino IDE, need help porting to C

Hello,

So I am familiar with the Arduino IDE and also the language of it, although I am finding that the TI MSP430's are cheap and need little power as compared to the Atmega's so I am hoping to be able to port the code over from the Arduino IDE to the compilers for the MSP430.

Does anybody have any solutions?
Also, there are libraries that the arduino has for the arduino IDE, How would I port those over to the compilers for the MSP430?

What do I have to do to be able to copy the code from this and put it in that?

Well, MSPGCC is a port of GCC and will accept the same language as Arduino, which is based on AVR-GCC. The MSP port looks quite a bit less mature than the AVR one, so that may be a challenge.

The main issue will be with porting libraries and all the myriad dependencies on the hardware environment.

Yea i see what you mean with the regular code. I don't exactly get what you mean by myriad libraries. Do you know if there is any support for porting the TLC5940 LIbraries?

Googling "TLC5940 MSP430" found me this: http://www.ti.com/lit/an/slva267a/slva267a.pdf

That didn't really help me. I don't understand any of it. thanks though.

funkyguy4000:
So I am familiar with the Arduino IDE and also the language of it, although I am finding that the TI MSP430's are cheap and need little power as compared to the Atmega's so I am hoping to be able to port the code over from the Arduino IDE to the compilers for the MSP430.

The Arduino is C++. It isn't its own language.

funkyguy4000:
Also, there are libraries that the arduino has for the arduino IDE, How would I port those over to the compilers for the MSP430?

The compiler isn't usually the stumbling block. The libraries are based on resources (and specifically registers) in the AVR chips. So to "port them" you need to take each library and examine what it does. Once you determine if it uses AVR resources, you can determine how to map those into resources on the MSP430.

There isn't a "simple" solution. You're trying to move from one architecture to another. That's a significant effort any way you look at it.

funkyguy4000:
I am finding that the TI MSP430's are cheap and need little power as compared to the Atmega's so I am hoping to be able to port the code over from the Arduino IDE to the compilers for the MSP430.

You must have pretty low-power requirements. My investigations recently found that the Atmega running at 3.3V uses only around 1 mA (depending on what it is doing of course) and that by sleeping the processor you can get consumption down to around 6 uA. At this rate, most batteries will self-discharge faster than that, so the limiting factor is battery technology, not how much the microprocessor is drawing.

Writing Code in the Arduino IDE, need help porting to C

Your subject line caught my attention because the Arduino is in C (and C++ depending on the file). So it hardly needs porting to C.

funkyguy4000:
I am finding that the TI MSP430's are cheap ...

Without knowing the exact part number it is hard to compare, but a quick look at Digi-Key seems to indicate the prices of various models of the MSP430 are comparable to the Atmega. Of course, to compare apples to apples you would have to specify an exact speed, program memory size, RAM size, number of IO ports etc.

But processors like the Attiny45 are around $2.30. You would have to be buying a lot to make it worthwhile spending months porting libraries across to save maybe the $1 difference (if that much) between the Atmega and the TI.

I'm not exactly concerned with what hardware i'm using. I'm using the MSP430 launchpad as well because it is easy in terms of getting the programmer and everything. Its my own fault that I'm not knowledgeable in coding in C and the libraries that are for arduino.

How would I be able to port the TLC5940 Library over to a way that I could use it for programming the MSP430 launchpad

How would I be able to port the TLC5940 Library over to a way that I could use it for programming the MSP430 launchpad

That's hardly an Arduino question. Why don't you ask that on the MSP forum?

Well the arduino library is written for the IDE, I was hoping somebody could enlighten me on how said library was made so I could try my hand at it for the MSP430

As already stated, the library was written for the Atmel hardware, which is not the the same as the TI. Googling for TLC5940 and MSP430 shows that others have made the combination work, so looking at their code would seem to be a good way forward.

OOOOhhhkay so they have already done the conversion work it just doesn't seem to be in as nice a package as the library for the arduino.

One last question, I can't seem to find the MSPGCC , anybody else know where it is?

Again, not really an Arduino question. Google suggests http://mspgcc.sourceforge.net/. It also found http://tech.groups.yahoo.com/group/msp430/ where you may find more help.

Well the arduino library is written for the IDE

No, it's written for the arduino platform. The ide is just a nicety.

so say I wanted to include tlc_fades.h from the TLC5940 Library from the arduino platform, I could just boom boom copy paste?

You could try, but I doubt it would work. The line ...

#include <avr/interrupt.h>

certainly wouldn't work.

I don't understand why you are asking Arduino users how to port a library to another architecture. You should be asking other MSP430 users if they have a library that does what you want.

Well the code is written for the arduino. Was thinking that maybe i could get something out of asking people here because they would understand how the library is written and why its written that so that i could decipher the arduino library and maybe be able to piece together what i need for the other platform b/c i don't know what the library for the arduino consists of right now.

i don't know what the library for the arduino consists of right now.

But you have the source

I have it but I don't understand it.

I don't get what all the #'s are for
What does #endif mean?

Is there a webpage that explains it all?