Pages: [1]   Go Down
Author Topic: Ardino as AVR Programmer -> ATtiny85 -> SD Library Pin help??  (Read 1974 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello.

I have an ATtiny85 which I can successfully program with my Arduino, however, I wish to connect an SD Shield to my ATtiny85 to read and write data, there are enough pins but I am unsure on how to re-map them to the ATtiny85 pins.

Can anybody help me out?

Bioshox.
Logged

0
Offline Offline
Edison Member
*
Karma: 64
Posts: 1634
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The ATtiny85 has too little SRAM to write an SD with a file system. 

An SD block is 512 bytes and the entire block must be written.  File systems require a block to be read, updated, and rewritten.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What about an ATtiny84?
Logged

0
Offline Offline
Edison Member
*
Karma: 64
Posts: 1634
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ATtiny84 also has only 512 bytes of SRAM, too little to write an SD with a file system.
Logged

Denmark
Offline Offline
Edison Member
*
Karma: 35
Posts: 1071
Happy Hobbyist
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Petit Fat claims that it can be used with RAM sizes less than sector size

http://elm-chan.org/fsw/ff/00index_p.html

The Energia library for the TI launchpad use it, and AFAIK the chip used also only has 512bytes of RAM
« Last Edit: April 30, 2013, 05:30:54 pm by Erni » Logged

0
Offline Offline
Edison Member
*
Karma: 64
Posts: 1634
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Petit Fat is extremely limited for file write.

Quote
The write function has some restrictions listed below:

    Cannot create file. Only existing file can be written.
    Cannot expand file size.
    Write operation must start/stop on the sector boundary.

File write operation must be done in following sequence.

    pf_lseek(ofs); read/write pointer must be moved to sector boundary prior to initiate write operation or it will be rounded-down to the sector boundary.

    pf_write(buff, btw, &bw); Initiate write operation. Write first data to the file.

    pf_write(buff, btw, &bw); Write next data. Any other file function cannot be used while a write operation is in progress.

    pf_write(0, 0, &bw); Finalize the write operation. If read/write pointer is not on the sector boundary, left bytes in the sector will be filled with zero.

The read/write pointer in the file system object increases in number of bytes written. After the function succeeded, *BytesWritten should be checked to detect end of file. In case of *BytesWritten < ByteToWrite, it means the read/write pointer reached end of file during the write operation. Once a write operation is initiated, it must be finalized or the written data can be lost.
Logged

Denmark
Offline Offline
Edison Member
*
Karma: 35
Posts: 1071
Happy Hobbyist
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks fat16lib,

I just found this, using an ATtiny84 - I haven't tryed it out

http://harizanov.com/2012/05/toying-with-attiny84-and-sd-card-in-arduino-ide/

Update:
It actually worked reading a file.
I use ATtiny84 running @8MHz, and 3,3V, so no level converter needed
« Last Edit: May 01, 2013, 06:56:31 am by Erni » Logged

0
Offline Offline
Edison Member
*
Karma: 64
Posts: 1634
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Read is not a problem.  

Write always has severe restrictions for small memory since you can't create or extend files without a 512 byte buffer.

You can rewrite selected portions of an existing file assuming each write starts on a 512 byte boundary and the write record will be filled to the next 512 byte boundary, usually with zeros.
« Last Edit: May 01, 2013, 12:10:49 pm by fat16lib » Logged

Denmark
Offline Offline
Edison Member
*
Karma: 35
Posts: 1071
Happy Hobbyist
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Write always has severe restrictions for small memory

Thanks for the information

I was looking at the Petit Fat documentation for writing files.
As far as I can see it is not easy to do as you also point out

Anyway, I think it's impressive to see my little ATtiny85 sit and read a big file.
I am sure that a read only solution can be useful in various projects with tiny's
Logged

Pages: [1]   Go Up
Jump to: