Show Posts
Pages: [1]
1  Forum 2005-2010 (read only) / Syntax & Programs / Re: SPI EEPROM Help on: January 15, 2009, 05:38:27 pm
Thanks so much for your help on that, I looked and looked but still didn't get that I had to resend the address. It was all there in the datasheet, I know.

Thanks again for helping!!!
2  Forum 2005-2010 (read only) / Syntax & Programs / SPI EEPROM Help on: January 14, 2009, 10:27:31 pm
I'm trying to interface an AT25256 EEPROM to my Arduino for a project but I'm having no luck. I can write the first 64 bytes no problem, but then when I write to address 64 it wraps around and writes to address 01 again.

To test my hardware I'm us the "Interfacing a Serial EEPROM Using SPI" code from the arduino site.

I'm using an at25256 but the EEPROM from the example code I use is a AT25HP512. Could this be by problem?

This is my first go at SPI so I'm well out of my depth here, any help would be appreciated.

#define DATAOUT 11//MOSI
#define DATAIN  12//MISO
#define SPICLOCK  13//sck
#define SLAVESELECT 10//ss

#define WREN  6
#define WRDI  4
#define RDSR  5
#define WRSR  1
#define READ  3
#define WRITE 2

byte eeprom_output_data;
byte eeprom_input_data=0;
byte clr;
int address=0;
//data buffer
char buffer [128];

void fill_buffer()
  for (int I=0;I<128;I++)

char spi_transfer(volatile char data)
  SPDR = data;                    // Start the transmission
  while (!(SPSR & (1<<SPIF)))     // Wait the end of the transmission
  return SPDR;                    // return the received byte

void setup()

  pinMode(DATAIN, INPUT);
  digitalWrite(SLAVESELECT,HIGH); //disable device
  // SPCR = 01010000
  //interrupt disabled,spi enabled,msb 1st,master,clk low when idle,
  //sample on leading edge of clk,system clock/4 rate (fastest)
  SPCR = (1<<SPE)|(1<<MSTR);
  //fill buffer with data
  //fill eeprom w/ buffer
  spi_transfer(WREN); //write enable
  spi_transfer(WRITE); //write instruction
  spi_transfer((char)(address>>8));   //send MSByte address first
  spi_transfer((char)(address));      //send LSByte address
  //write 128 bytes
  for (int I=0;I<128;I++)
    spi_transfer(buffer[I]); //write data byte
  digitalWrite(SLAVESELECT,HIGH); //release chip
  //wait for eeprom to finish writing

byte read_eeprom(int EEPROM_address)
  int data;
  spi_transfer(READ); //transmit read opcode
  spi_transfer((char)(EEPROM_address>>8));   //send MSByte address first
  spi_transfer((char)(EEPROM_address));      //send LSByte address
  data = spi_transfer(0xFF); //get data byte
  digitalWrite(SLAVESELECT,HIGH); //release chip, signal end transfer
  return data;

void loop()
  eeprom_output_data = read_eeprom(address);
  if (address == 128)
    address = 0;
  delay(500); //pause for readability
3  Forum 2005-2010 (read only) / Exhibition / Re: Arduino Pong on: August 28, 2007, 09:56:40 pm
Hi  tvdbon,
I'm using the 168.
4  Forum 2005-2010 (read only) / Exhibition / Re: Arduino Pong on: August 23, 2007, 08:28:15 pm
Ok ignore what I just said in the post above.  cli(); in set-up works just fine.
I was running software version 0007, I just downloaded 0009 and it all works fine now.

I can play pong now, my life is complete!!!

Thanks for sharing a great project.
5  Forum 2005-2010 (read only) / Exhibition / Re: Arduino Pong on: August 23, 2007, 08:02:01 pm
I'm getting the same blurred screen.
No change when I put the cli(); code in the first line of setup. Is there something else I need to do other then enter cli(); into the first line of  set-up, recompile then upload to the micro?
If I comment out the interupt code in wired.c the title screen has no blurring but the screen goes blank and the micro locks up after that.

oh I've got a Pal tv(australia) and all resistor values are very close.

Is there something I'm missing?  

Oh and fantastic project Alastair.

Pages: [1]