Category:Memory

From ElectroDragon
Jump to: navigation, search

Instruction

There are three pools of memory in the microcontroller used on avr-based Arduino boards :

  • Flash memory (program space), is where the Arduino sketch is stored.
  • SRAM (static random access memory) is where the sketch creates and manipulates variables when it runs.
  • EEPROM is memory space that programmers can use to store long-term information.

Flash memory and EEPROM memory are non-volatile (the information persists after the power is turned off). SRAM is volatile and will be lost when the power is cycled.

The ATmega328 chip found on the Uno has the following amounts of memory:

  • Flash 32k bytes (of which .5k is used for the bootloader)
  • SRAM 2k bytes
  • EEPROM 1k byte

The ATmega2560 in the Mega2560 has larger memory space :

  • Flash 256k bytes (of which 8k is used for the bootloader)
  • SRAM 8k bytes
  • EEPROM 4k byte

SPI FLASH VS EEPROM:

Flashmemorylayout.png
  • EEPROM have smaller capacity (typically in Kbit size) will Flash have a larger capacity (typically in Mbit size)
  • SPI bus is more commonly seen in Flash device due to high serial speed (in MHz range, e.g. 40/60MHz)
  • Flash has divided memory into three levels of granularity, namely: pages, blocks, sectors(This apply to Atmel DataFlash/Adesto DataFlash)
  • EEPROM data memory is seen as a block of continuous memory, each data with respective address. Each data byte is access by its respective memory address.

SPI Flash

  • SST - SST25VF016B-50-4C-S2AF
  • Winbond - W25Q64FVSSIG
25Q128FVSG.png
  • Simple wiring
D13, D12, D11, D10 of arduino to SPI flash - CLK, DO, DI and CS, 
3V3 arduino to 3v3, wp, hold, and GND of arduino to GND
  • Data need to be erased before write again.
  • flash winbond W25Q SPI Flash

W25Q SPI Flash.jpeg

EEPROM

Arduino EEPROM Demo Code and Wiring

#include <Wire.h>
#define EEPROM_END 0x50
String text = "electrodragon.com";
int start = 0;
int count = 0;
void setup(){
 Wire.begin();
 Serial.begin(9600);
 Serial.println("Writing in EEPROM...");
 for (int x=start; x<text.length(); x++){
 i2c_eeprom_write(EEPROM_END, x, byte(text.charAt(x)));
 delay(5);
 }
 Serial.println("written completed!!!");
 Serial.println("");
}
void loop(){
 for (int x=start; x<text.length(); x++){
 Serial.print(i2c_eeprom_read(EEPROM_END, x));
 }
 Serial.print(" count number: ");
 Serial.println(count);
 count+=1;
 delay(1000);
}
 
void i2c_eeprom_write(int end_eeprom, unsigned int end_memoria, byte valor)
{
 Wire.beginTransmission(end_eeprom);
 Wire.write((int)(end_memoria >> 8));
 Wire.write((int)(end_memoria & 0xFF));
 Wire.write(valor);
 Wire.endTransmission();
}
 
char i2c_eeprom_read(int end_eeprom, unsigned int end_memoria)
{
 Wire.beginTransmission(end_eeprom);
 Wire.write((int)(end_memoria >> 8));
 Wire.write((int)(end_memoria & 0xFF));
 Wire.endTransmission();
 Wire.requestFrom(end_eeprom, 1);
 byte dado;
 if (Wire.available()){
 dado=Wire.read();
 }
 Wire.endTransmission();
 return dado;
}

SD Card Read

  • Wiring
5V - VCC, GND - GND
D13 - SD_CLK, D12 - SD_OUT, D11 - SD_IN, D10 - SD_CS
  • Arduino library, and upload SD card example sketch.

Demo code

For Stm32:

Schematic

Documents

This category currently contains no pages or media.