Pages: 1 [2]   Go Down
Author Topic: 1284P - lack of SRAM but I need a high speed accessable memory for a POV-display  (Read 1830 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 27
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

finally got that damn chip to life!
I used many different bootloader and only this one worked:
https://github.com/jmgiacalone/sanguino1284p

its a mix out of many different packages available, and it work very well.
Something strange is, that the 1284p works about 20% faster than my atmega2560 running the same sketch
(i did a shift out demo for an 16bit regsister to steer the leds)
the 1284 does update the 16bit LED display at 13,5khz and the 2560 at 11,6khz (calculated on 50000 cycles each)

now I need to port my current sktches to that baby. Hopefully the flash library will work.
thx for your help!
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 549
Posts: 27427
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

"BTW.: I would like to buy a Atmel AVR ISP MKii aswell."
I bought mine from mouser.com for ~$33.
I don't trust e-bay for tools like that, nor the 3 week delivery times.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Full Member
***
Karma: 0
Posts: 162
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

mzure,
I updated my code (Reply#10) so it can handle any size SD file.
You can test it out for speed immediately.
You can use any file, even a text file or jpg, and you can even shift out to a non-connected device.

I'm claiming it should be blazingly faster than current, 5-10x or more.
Techylah 
Logged

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

@techylah

I totally agree to your idea! The sd card interface was always supposed as an animation memory. But I dont understand how to use your code snippet to read it binary.
I think it would do the same job, if I just read a binary file, and instead of an ASCII character I get the byte I want directly (8x Times faster). Is there any way to stream that bytes directly into my array - without the use of counters, comperators, and so on - (that decrease speed extremely)?
But what is a shame,  that I cant find ANY binary level file editor for windows! All "binary" editors show the value only in HEX, DEC, or ASCII! I tried a bunch of them and no one has the function to display it really binary!
Here is how I did it before (reading the ASCII):
Code:
myFile = SD.open("data1.txt")
 if (myFile) {  //does if file exists
    sd_member = 0;  //resets for array mergeing
    sd_position = 0;
    sd_layer = 0;
    while (myFile.available()) {   // reads from the file until there's nothing else in it
      data1[sd_layer][sd_member] = data1[sd_layer][sd_member] << 1;  //shifts it one position to the left
      data1[sd_layer][sd_member] |= (myFile.read() - '0');   //myFile.read acts like a serial communication - all fetched data is ASCII (for this reason -'0' : 48-48 = 0 ; 49-48=1
      sd_position++;  //counts up position
      if (sd_member == 32) {
        sd_member = 0; //resets member that new layer starts being written at the beginning member
        sd_layer++; //counts up layer to acces trough array
      }
      if (sd_position == 16) { //checks if lenth of one member is reached (as for datatype word its 16)
        sd_position = 0; //resets position that new member starts being written at the beginning
        sd_member++; //counts up member to acces trough array
      }
      }
    }
 myFile.close();    // close the file

grz mx
Logged

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

something really strange I found out now:

I am using the SD.h library on Arduino IDE r23.
I am using some interrupts and timers for my sketch.
The problem is, that the SD library crashes when the timer 1 overflow intrrupt is activated
-When i deactivate it it works very well (atmega 1284p).
Has anyone a idea??

My sketch now reads an .BIN file (i filled it up in an HEX editor - random values)
the file is 4096bytes big, and it is transfering at a speed of around 20kByte/sek.
- That still seems a little slow to me - I need to investigate a bit further to test where the speed gets so lacked down...

EDIT: same problem with an external interrupt (INT0)
EDIT2: found out that disableing cli(); before my setup fexes the INT0 problem - the overflow problem is still there and I have no f**** clue why that is happening...
« Last Edit: June 10, 2012, 03:27:47 pm by mzure » Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 162
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

mzure,
It depends on your declaration of data1. What is it?
It looks like you have a 2D array of ints (16 bits) as in:
   int   data1[8][32];
Thus the size of data is 512 bytes ( 8 * 32 * 2 ).

If the data is binary, you can read it in directly in one step with:
  myFile.stream.readBytes(data1, 512);         // If that doesn't compile, then use   "readBytes((char *)data1, 512)"   or   "readBytes(&data1[0][0], 512)"

If you want to create your patterns in an editor, as opposed to algorithmically, you're right, a hex editor is out of the question.

You could, however, let the user edit an ascii file of '.'s and 'x's, however many to the line you need, with the editor of his choice.
(it's only easy if you use an equi-spaced font like Console or Console)
Then you have a program which reads each line, converts it to binary, and writes the binary version.
For example it would take these 2 lines
......xxx.......
.....xxxxx......
and convert them to the 4 bytes for 2 ints in your array, namely
0x38, 0x7C



Logged

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

hey techylah! thx for your reply!
All your discribed methods give an compiler error...
readBytes() is not understood by r23 nor 1.0
myFile.stream.read() is also not acceptet by my compiler
only myFile.read() works.

Here is my current SD function:
Code:
void f_SdToArray() {
  sdx = 0;
  sdy = 0;
  myFile = SD.open("data2.bin");  //open file 1
  if (myFile) {  //does if file exists
    while (myFile.available()) {   // reads from the file until there's nothing else in it
     
      FRAME_1[sdx][sdy] = word(myFile.read(),myFile.read());
      sdy++;
      if (sdy == 256) {
        sdx++;
        sdy = 0;
      }
      if (sdx == 8) {
        sdx = 0;
      }
    }
  }
   myFile.close();    // close the file

data2.bin is exacly 4096 bytes bif and my array (2D) FRAME_1 is [8] [256] (4096 bytes as well)
It would be nice to achieve it whithout that massive counting´n loops and that stuff.

Anyway - I have still no clue why some interrupts interfer with the SD library... Are there some SPI interrupt flags set, which can be used normally as well?

grz mx
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 162
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Try:
Code:
myFile.readBytes(data1, 512);         // If that doesn't compile, then use   "readBytes((char *)data1, 512)"   or   "readBytes(&data1[0][0], 512)"
Logged

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

no one of these want to work for me...
compiler says:

Code:
error: 'class File' has no member named 'readBytes'
I am using the SD.h library with arduino r23

here is my code:

Code:
void f_SdToArray() {
  sdx = 0;
  sdy = 0;
  myFile = SD.open("data2.bin");  //open file 1
  if (myFile) {  //does if file exists
    while (myFile.available()) {   // reads from the file until there's nothing else in it
     // FRAME_1[sdx][sdy] = word(myFile.read(),myFile.read());
     myFile.readBytes(FRAME_1, 4096);
      sdy++;
      if (sdy == 256) {
        sdx++;
        sdy = 0;
      }
      if (sdx == 8) {
        sdx = 0;
      }
    }
  }
   myFile.close();    // close the file
}

Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 162
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

mzure,
This is my mistake.  There is another library "SdFat.h" that has the stream read and write ability.
It appears this was not exposed to the simple SD library.
Example: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1281920236

This library lets you specify a buffer and how many bytes in the read() command.
I'm an experienced programmer, not really an Arduino expert.
It might be as simple as "include "SdFat.h""
sri
Logged

Bute, Scotland
Offline Offline
Jr. Member
**
Karma: 0
Posts: 86
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I don't know much about this and cannot work out how much data you are storing so I may be completely wrong ( I usually am ) but would it be possible to store the data in progmem? That way it doesn't use the sram and I think it would be very quick to read it.
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 549
Posts: 27427
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

progmem cannot be written to by the program once  the sketch starts, only at download time.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Bute, Scotland
Offline Offline
Jr. Member
**
Karma: 0
Posts: 86
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well I knew that. My understanding was that data was being read from an SD card not written to it. hence it seemed practical to do it that way. As I said I usually am wrong   smiley-wink
Logged

Pages: 1 [2]   Go Up
Jump to: