Page 1 of 1

How to access Roger's libraries

Posted: Thu Oct 22, 2020 2:39 am
by k1rjl
Please excuse my ignorance. I'm a new user trying to build code dependent on Roger's core. I'm using the latest Arduino (1.8.13). I think I've setup the IDE and Roger's code per the instructions. This is on a mac running current versions of the Apple software. Roger's core is in ~/Documents/Arduino/hardware/Arduino_STM32-master. The code I'm trying to build needs Roger's EEPROM library. The correct code is there along with other necessary libraries but isn't being referenced. How do I get the IDE to use those libraries? The library manager doesn't seem to see them.

Re: How to access Roger's libraries

Posted: Thu Oct 22, 2020 9:23 am
by stevestrong
You should first select a board and then you will see the EEPROM examples in Arduino under File->Examples->Examples for...board.
Which board do you use?

Re: How to access Roger's libraries

Posted: Mon Nov 23, 2020 11:19 pm
by FerroFerido
Man, anyone can help me? I need save 7200 bytes in EEPROM On BluePill, but I'm not able to save more than 508 Bytes, know you who save more bytes in EEPROM?

Code: Select all

#include <EEPROM.h>


#include "EEPROM.h"
#define espacoEEPROM 57600
#define botao PB12
#define botao2 PB13
int x;
int potenciometro;
float i;
#define Sensor5 PA5
byte temp5 ;

int estadocircuito = 0;

int estadobotao;
int estadobotao2;

int estadoanteriorbotao;
int estadoanteriorbotao2;

//const int addressEEPROM_min = 0;              // Specify the address restrictions you want to use.
//const int addressEEPROM_max = 4095;

void setup() {
  // put your setup code here, to run once:
  pinMode(Sensor5, INPUT_ANALOG);
  pinMode(botao, INPUT_PULLDOWN);
  pinMode(botao2, INPUT_PULLDOWN);
  pinMode(PC13, OUTPUT);

  estadoanteriorbotao = digitalRead(botao);
  estadoanteriorbotao2 = digitalRead(botao2);
}

void loop() {
  /*/ put your main code here, to run repeatedly:
    potenciometro = analogRead(PA5);
    EEPROM.write(1,potenciometro);//EEPROM.write(endereço, dado);
    i = EEPROM.read(1);
    Serial.begin(9600);
    Serial.print("valor na eeprom é:");
    Serial.println(i);
  */

  /* AQUI É TUDO RELACIONADO AO BOTAO*/
  estadobotao = digitalRead(botao);
  if ((estadobotao == HIGH) && (estadoanteriorbotao == LOW)) {

    if (estadocircuito < 2) {
      estadocircuito = estadocircuito + 1;

    } else {
      estadocircuito = 0;
    }
  }

  estadoanteriorbotao = estadobotao;

  estadobotao2 = digitalRead(botao2);
  if ((estadobotao2 == HIGH) && (estadoanteriorbotao2 == LOW)) {

    if (estadocircuito == 0) {
      estadocircuito = estadocircuito + 2;

    } else {
      estadocircuito = 0;
    }
  }

  estadoanteriorbotao2 = estadobotao2;
  /* AQUI ACABA TUDO RELACIONADO AO BOTAO*/
      EEPROM.PageBase0 = 0x801F000;
      EEPROM.PageBase1 = 0x801F800;

      EEPROM.PageSize  = 0x800;

  if (estadocircuito == 0) {
    digitalWrite(PC13, HIGH);
    delay(1000);
    digitalWrite(PC13, LOW);
    delay(1000);
    Serial.begin (9600);
    Serial.println("Aperta pra gravar");


    // Serial.println(analogRead(Sensor5));*/
  }
  if (estadocircuito == 1) {
    int b = 0;
    

    for (int a = 0; a < 720; a++) {



      digitalWrite(PC13, HIGH);
      temp5 = ((analogRead(Sensor5)) * (3.6 / 4095)) / 0.01;

      EEPROM.write(b, temp5);
      Serial.print(b);
      Serial.print("<------");
      Serial.println(EEPROM.read(b));
      delay(500);

      b++;



    }
    estadocircuito = 0;

  }

  if (estadocircuito == 2) {
    int b = 0;

    for (int a = 0; a < 7200; a++) {
 
      Serial.print("Sensor 5 fez medição ");
      Serial.print(b);
      Serial.print(" como temperatura");
      Serial.print(EEPROM.read(b));
      Serial.println (temp5);
      b++;


    }
    estadocircuito = 3;
  }

  if (estadocircuito == 3) {
    EEPROM.format();
    digitalWrite (PC13, HIGH);
    delay(2000);
    estadocircuito = 0;
  }


}
This is my code, i don't know what i can do.

Re: How to access Roger's libraries

Posted: Mon Nov 23, 2020 11:44 pm
by stevestrong
The EEPROM library is only suitable to store couple of data, up to 500 bytes.
For many kBytes you have to use compete FLASH pages to store data.
For that I recommend to study how data is written into the flash by differnt bootloaders (DFU, HID, CDC).

Re: How to access Roger's libraries

Posted: Tue Nov 24, 2020 1:44 am
by GonzoG
If you want that much data in EEPROM consider using external I2C/SPI EEPROM.
STM32F1 does not have hardware EEPROM and STM core and Roger's core use software emulation in FLASH memory. It's really destructive for the FLASH as it writes/erases whole flash page with every write.

Re: How to access Roger's libraries

Posted: Tue Nov 24, 2020 2:16 am
by mrburnette

Re: How to access Roger's libraries

Posted: Tue Nov 24, 2020 6:11 pm
by FerroFerido
stevestrong wrote: Mon Nov 23, 2020 11:44 pm The EEPROM library is only suitable to store couple of data, up to 500 bytes.
For many kBytes you have to use compete FLASH pages to store data.
For that I recommend to study how data is written into the flash by differnt bootloaders (DFU, HID, CDC).
I don't know where to start

Re: How to access Roger's libraries

Posted: Tue Nov 24, 2020 6:11 pm
by FerroFerido
GonzoG wrote: Tue Nov 24, 2020 1:44 am If you want that much data in EEPROM consider using external I2C/SPI EEPROM.
STM32F1 does not have hardware EEPROM and STM core and Roger's core use software emulation in FLASH memory. It's really destructive for the FLASH as it writes/erases whole flash page with every write.
Good Idea man

Re: How to access Roger's libraries

Posted: Tue Nov 24, 2020 6:36 pm
by fredbox
24C256 modules are cheap and available from the usual sources. This gives you 32K of EEPROM to use as you see fit. There are libraries that support these devices, although basic read/write is easy enough that you can access the part directly without any extra libraries. See http://www.learningaboutelectronics.com ... rduino.php for an example.