a couple of things, u'd need to state the eeprom that you are using
if you're buying from the likes of aliexpress beware of some vendors selling boards with substitutes and labeling after the real original chips.
i'm not familiar with i2c hence have little to contribute here.
but that you've tried spi flash, and you may like to continue that attempt
viewtopic.php?f=63&t=1085
i2c is 100-300 kbps max and unless you are keeping only a little data, you would likely run out of bandwidth trying to store adc data.
the main thing about i2c is using less wires, that's about it.
then you may like to try sdio that uses SPI, this won't be easier than the others,
viewtopic.php?f=7&t=911
it is in fact more complex due to dealing with a fat file system and sd cards. so you can expect more problems.
but then these days sd cards provides gigabytes of storage and that's the main attraction
Multiple i2c port drive & Multiple SPI port drive
Re: Multiple i2c port drive & Multiple SPI port drive
Code: Select all
#include <Wire.h>
//Christensen v3.0 extEEPROM.h
#include <extEEPROM.h>
//24C02 EEPROM 2kbits, 256 bytes, 16 byte page length
//constructor
//extEEPROM(eeprom_size_t deviceCapacity, byte nDevice, unsigned int pageSize, byte eepromAddr = 0x50);
extEEPROM eep(kbits_2, 1, 16, 0x50);
char test[] = {
"Hello-1234567890-and-abcdefghijklmnopqrstuvwxyz-Goodbye\n"
};//null terminated character array
char buffer[100]; //output buffer
void setup()
{
Serial.begin(9600);
Wire.begin();
int length = sizeof(test);
Serial.print("Length ");
Serial.print(length);
Serial.println();
//return byte z for error checking on write over end of EEPROM
//EEPROM_ADDR_ERR defined as 9 in library
byte error = eep.write (0, test, sizeof(test)); //included null terminator
Serial.print("Error status returned = ");
Serial.println(error);
if (error == 9) {
Serial.println("ERROR ADDRESS TOO LARGE FOR EEPROM");
return;
}
if (error != 0 && error != 9) {
Serial.println("I2C ERROR");
return;
}
if (error == 0) {
Serial.println("No Errors");
}
eep.read(0, buffer, sizeof(test));
Serial.println(buffer);
Serial.println();
}
void loop()
{
}
Arduino: 1.8.13 (Windows 10), Board: "Generic STM32F103C series, STM32F103C8 (20k RAM. 64k Flash), STM32duino bootloader, 72Mhz (Normal), Smallest (default)"
C:\Users\ELCOT\Desktop\test\test.ino: In function 'void setup()':
test:30:48: error: invalid conversion from 'char*' to 'byte* {aka unsigned char*}' [-fpermissive]
byte error = eep.write (0, test, sizeof(test)); //included null terminator
^
In file included from C:\Users\ELCOT\Desktop\test\test.ino:3:0:
C:\Users\ELCOT\Documents\Arduino\libraries\extEEPROM/extEEPROM.h:96:14: error: initializing argument 2 of 'byte extEEPROM::write(long unsigned int, byte*, unsigned int)' [-fpermissive]
byte write(unsigned long addr, byte *values, unsigned int nBytes);
^
test:45:35: error: invalid conversion from 'char*' to 'byte* {aka unsigned char*}' [-fpermissive]
eep.read(0, buffer, sizeof(test));
^
In file included from C:\Users\ELCOT\Desktop\test\test.ino:3:0:
C:\Users\ELCOT\Documents\Arduino\libraries\extEEPROM/extEEPROM.h:98:14: error: initializing argument 2 of 'byte extEEPROM::read(long unsigned int, byte*, unsigned int)' [-fpermissive]
byte read(unsigned long addr, byte *values, unsigned int nBytes);
^
Multiple libraries were found for "Wire.h"
Used: C:\Users\ELCOT\AppData\Local\Arduino15\packages\stm32duino\hardware\STM32F1\2021.3.18\libraries\Wire
Not used: C:\Users\ELCOT\AppData\Local\Arduino15\packages\stm32duino\hardware\STM32F1\2021.3.18\libraries\WireSlave
Multiple libraries were found for "extEEPROM.h"
Used: C:\Users\ELCOT\Documents\Arduino\libraries\extEEPROM
Not used: C:\Users\ELCOT\Documents\Arduino\libraries\extEEPROM-master
exit status 1
invalid conversion from 'char*' to 'byte* {aka unsigned char*}' [-fpermissive]
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
-
- Posts: 505
- Joined: Fri Dec 27, 2019 4:53 pm
- Location: Munich, Germany
- Contact:
Re: Multiple i2c port drive & Multiple SPI port drive
The error message is clear: you have to cast the second parameters of the function calls to
and
In addition, you have to change the size of buffer to:
Code: Select all
byte error = eep.write( 0, (byte*)test, sizeof(test));
Code: Select all
eep.read( 0, (byte*)bufer, sizeof(test));
Code: Select all
char buffer[sizeof(test)+1];