Micro SD and RTC on Atmega 2560 AVR

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

"Hello community, i have to build a datalogger, and i have to save data on a micro sd card with real time, so i need a library that let me write and read and other one for rtc ds3231 that works great on atmega 2560. thanks for all your possible help."

Last Edited: Mon. Mar 19, 2018 - 09:24 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Arduino has it all. The mega2560 is used on the Arduino mega boards, so it is fully supported. Do a Google on how to get the hex file from the Arduino tools.

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

Greetings Zoguis and welcome to AVR Freaks.

 

The first question is VERY important. Is this a one-off project or is it something that is going to be built in quantity?

 

On a Mega2560, there is a "Real Time Counter with Separate Oscillator". This is designed to explicitly work with 32.768KHz crystals and produce 1 second ticks. This runs in the background so writing to the uSD card will not interfere with time keeping. Minutes, hours, and such, can be derived though software counting from the 1 second ticks. The time.h library will handle all this for you.

 

The Elm Chan SPI memory card library does an excellent job of dealing with FAT-formatted memory media. Together, these work quite nicely,

 

If you look at the link below my signature, you will see a battery powered logger that records acceleration at up to 100Hz, and writes to a uSD card. It has a hardware/software real time clock and is based on M328P.

 

Best wishes

Jim

 

 

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

Last Edited: Mon. Mar 19, 2018 - 06:06 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ka7ehk wrote:
The Elm Chan SPI memory card library
Just to be clear, Jim is talking about FatFs which I think is pretty much what everyone using plain AVRs uses when they want SD/MMC access. It's very good. It contains a "hooK" where you feed the readings from your RTC into it so it can date/time stamp the files it creates.

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

clawson wrote:
FatFs ... I think is pretty much what everyone using plain AVRs uses when they want SD/MMC access.

Thoroughly Agreed. And it's not just AVRs - I think FatFs is pretty much what everyone using any microcontroller uses when they want SD/MMC access.

 

It is widely - if not universally - used by other manufacturers in their demos/examples of SD Card usage.

 

 It's very good.

Indeed it is.

 

 

#SDCardUseFatFs

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Mon. Mar 19, 2018 - 09:37 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

thanks for all your help, im using the arduino board, but i have to program it on atmel studio in C, so how i import the FatFS libreary to that Uc(atemga2560).

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

Have you visited the FatFs main page - http://elm-chan.org/fsw/ff/00index_e.html - and studied the information there?

 

In particular, the 'Resources' at the end of that page?

 

Or just googled for examples?

 

 

EDIT

 

Or, if it's "How To Get Started With Atmel Studio" you're looking for:

 

https://www.google.co.uk/search?q=atmel+studio+getting+started

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Mon. Mar 19, 2018 - 03:03 PM