How to port arduino library ?

Go To Last Post
10 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Guys,

Does anyone of you have an experience on porting arduino library to ATMEGA128 ?
Or similar ?
Is it possible ?

It would be nice if I can, since I saw a lot of library there in my arduino directory and I wanna port it...

Thanks

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What do you want to achieve? Run Arduino on the m128? Or use the libraries in your own code?

There's been lots written about this. Do a search.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:
What do you want to achieve? Run Arduino on the m128? Or use the libraries in your own code?

There's been lots written about this. Do a search.

Yes, I wanna use library from arduino in my code
Is it possible to put arduino into my ATMEGA128 ? enough memory for it ?

May I know the keyword for it ?

thanks

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You really haven't done any research have you? The standard Arduino UNO has a mega328 - the mega128 has more ram, flash and peripherals.
I Googled arduino library avrgcc

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:
You really haven't done any research have you? The standard Arduino UNO has a mega328 - the mega128 has more ram, flash and peripherals.
I Googled arduino library avrgcc

Oh, Ok, I'll try uploading arduino into my mega128 then...thanks..

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Arduino is written for the following:

E:\arduino-1.0.4\hardware\arduino>grep ".mcu" boards.txt
uno.build.mcu=atmega328p
atmega328.build.mcu=atmega328p
diecimila.build.mcu=atmega168
nano328.build.mcu=atmega328p
nano.build.mcu=atmega168
mega2560.build.mcu=atmega2560
mega.build.mcu=atmega1280
leonardo.build.mcu=atmega32u4
esplora.build.mcu=atmega32u4
micro.build.mcu=atmega32u4
mini328.build.mcu=atmega328p
mini.build.mcu=atmega168
ethernet.build.mcu=atmega328p
fio.build.mcu=atmega328p
bt328.build.mcu=atmega328p
bt.build.mcu=atmega168
LilyPadUSB.build.mcu=atmega32u4
lilypad328.build.mcu=atmega328p
lilypad.build.mcu=atmega168
pro5v328.build.mcu=atmega328p
pro5v.build.mcu=atmega168
pro328.build.mcu=atmega328p
pro.build.mcu=atmega168
atmega168.build.mcu=atmega168
atmega8.build.mcu=atmega8

No mega128 in that list I'm afraid. So you may find some porting work is required. It's possible the mega1280/2560 support is close to what you will need.

But as Kartman says there is loads written about this on the internet so you should Google as someone may have done the work to adapt for mega128 already as it's such a popular (if now hugely outdated) target.

EDIT: this board is a 128 based Arduino:

http://www.chip45.com/products/c...

and therefore they have a link to:

http://download.chip45.com/chip4...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

For example from arduino :

// Aquire time from the RTC chip in BCD format and convert it to DEC
void DS1307new::getTime(void)
{
  Wire.beginTransmission(DS1307_ID);
  Wire.write((uint8_t)0x00);
  Wire.endTransmission();
  Wire.requestFrom(DS1307_ID, 7);       // request secs, min, hour, dow, day, month, year
  second = bcd2dec(Wire.read() & 0x7f);// aquire seconds...
  minute = bcd2dec(Wire.read());     // aquire minutes
  hour = bcd2dec(Wire.read());       // aquire hours
  dow = bcd2dec(Wire.read());        // aquire dow (Day Of Week)
  dow--;							//  correction from RTC format (1..7) to lib format (0..6). Useless, because it will be overwritten
  day = bcd2dec(Wire.read());       // aquire day
  month = bcd2dec(Wire.read());      // aquire month
  year = bcd2dec(Wire.read());       // aquire year...
  year = year + 2000;                   // ...and assume that we are in 21st century!
  
  // recalculate all other values
  calculate_ydn();
  calculate_cdn();
  calculate_dow();
  calculate_time2000();
}

Can I use it directly in ATMEGA128, or I need to port ( modify ) so I can reuse it ?
thanks

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

it's not directly to the chip pin since there's a function "wire.*".....

Any clues ?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You will need to modify the arduino libraries for the m128. If you look at the library code you will see the #ifdef stuff for the different avrs that are supported. You need to add m128 and the code to cope with the m128 specifics. Didn't Cliff give a link to some m128 libraries?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I would guess that the library should build ok for all TWI enabled AVRs. The TWI registers are all named the same.

However, you will have to check for yourself.

David.