• Witaj na Forum Arduino Polska! Zapraszamy do rejestracji!
  • Znajdziesz tutaj wiele informacji na temat hardware / software.
Witaj! Logowanie Rejestracja


Ocena wątku:
  • 0 głosów - średnia: 0
  • 1
  • 2
  • 3
  • 4
  • 5
Zawieszanie wyświetlacza OLED
#31
Ale on działa, tylko się zawiesza - to jest dziwne , kod jest przecież dobry - jeszcze sprawdzę zużycie pamięci według kodów "es2".
 
Odpowiedź
#32
(26-10-2018, 16:53)Automatyk231 napisał(a): jeszcze sprawdzę zużycie pamięci według kodów "es2".

Jaksie okaże, że RAM nie brakuje, to zaczną się problemy. Bez debugera może być problem.
 
Odpowiedź
#33
Najpierw muszę dojść dlaczego wyskakuje mi błąd przy tym RAM'ie Big Grin Nie poradzę sobie z tym RAM'em - na internecie brak wiadomości w ogóle o takich błędach. No cóż - widocznie za mało wiem aby móc to naprawić. Dzięki wszystkim za zainteresowanie Smile
 
Odpowiedź
#34
Znalazłem kiedyś dwa przykłady jak sprawdzić wolny RAM, zapisałem sobie "na kiedyś", na razie nie miałem potrzeby testować. Możesz sobie sprawdzić:
Kod:
size_t freeRam ()
 {
 return RAMEND - size_t (__malloc_heap_start);
 } // end of freeRam

void setup ()
 {
 Serial.begin (115200);
 Serial.println ();

 Serial.print (F("Free memory = "));
 Serial.println (freeRam ());
 }  // end of setup

void loop () { }




/* This function places the current value of the heap and stack pointers in the
* variables. You can call it from any place in your code and save the data for
* outputting or displaying later. This allows you to check at different parts of
* your program flow.
* The stack pointer starts at the top of RAM and grows downwards. The heap pointer
* starts just above the static variables etc. and grows upwards. SP should always
* be larger than HP or you'll be in big trouble! The smaller the gap, the more
* careful you need to be. Julian Gall 6-Feb-2009.
*/
/*
void check_mem() {
 //uint8_t * heapptr, * stackptr;  // I declared these globally
 stackptr = (uint8_t *)malloc(4);  // use stackptr temporarily
 heapptr = stackptr;                  // save value of heap pointer
 free(stackptr);                        // free up the memory again (sets stackptr to 0)
 stackptr =  (uint8_t *)(SP);       // save value of stack pointer
 }

check_mem(); // heappstr, stackptr have been declared (as  uint8_t * heapptr, * stackptr;)
Serial.print(" heapptr: "); Serial.println(*heapptr);
Serial.print("stackptr: "); Serial.println(*stackptr);
Serial.println ((int) heapptr);


*/
Miło być decenianym https://buycoffee.to/kaczakat
 
Odpowiedź
#35
Cytat:Znalazłem kiedyś dwa przykłady jak sprawdzić wolny RAM, zapisałem sobie "na kiedyś", na razie nie miałem potrzeby testować. Możesz sobie sprawdzić:
kaczakat czy do tych kodów nie należy użyć żadnych bibliotek? Pierwszy kod w zasadzie nie wyświetla mi nic (jeden znak zapytania jedynie). A z drugim jest problem z kompilacją.
 
Odpowiedź
#36
(26-10-2018, 16:27)Automatyk231 napisał(a): błąd przy kompilacji : expected initializer before 'NOINIT' (niewiem co on znaczy Big Grin )

Przed użyciem NOINIT dopisz
Kod:
#define NOINIT __attribute__ ((section(".noinit")))
albo zastąp NOINIT przez "__attribute__ ((section(".noinit")))"

Ciesz się, ze to nie ARM, tam musiałbyś kombinować jeszcze w opcjach kompilatora.
 
Odpowiedź
#37
Kod działa prawidłowo, jak czegoś nie wyświetlał to pewnie źle ustawiłeś baudrate w oknie terminala. Nic nie trzeba instalować dodatkowo, a jak użyjesz i co zobaczysz  oraz jakie wyciągniesz wnioski to już zależy od Ciebie. Te funkcje z komentarzy wymagały rozpisania kodu zgodnie z opisem. Na pewno działają na AVR (NANO, UNO, itp), nie potrzebują bibliotek.
Inaczej użyte:
Kod:
uint8_t * heapptr, * stackptr;
size_t freeRam ()
  {
  return RAMEND - size_t (__malloc_heap_start);
  } // end of freeRam

void setup ()
  {
  Serial.begin (115200);
  Serial.println ();

  Serial.print (F("Free memory = "));
  Serial.println (freeRam ());
  }  // end of setup

void loop () {
  
    Serial.print (("Free memory = "));
  Serial.println (freeRam ());

  
  check_mem(); // heappstr, stackptr have been declared (as  uint8_t * heapptr, * stackptr;)
 Serial.print(" heapptr: "); Serial.println((int) heapptr);
Serial.print("stackptr: "); Serial.println((int) stackptr);
Serial.println ((int) stackptr-(int) heapptr);
 Serial.println();

  Serial.println( jakies_obliczenia(12));
 Serial.print(" heapptr: "); Serial.println((int) heapptr);
Serial.print("stackptr: "); Serial.println((int) stackptr);
Serial.println ((int) stackptr- (int) heapptr);
   delay(1000);

  }

uint32_t jakies_obliczenia(uint32_t sumka)
{
    Serial.println(F("Dane ze srodka funkcji"));
  Serial.print(F("Free RAM:"));
  uint32_t dana1=56, dana2=234234, dana4;
  uint32_t cosik=freeRam();
  dana4=dana1*dana2+sumka;
  check_mem();
  dana1=dana4-dana2;
  return cosik;
  
  
}

/* This function places the current value of the heap and stack pointers in the
* variables. You can call it from any place in your code and save the data for
* outputting or displaying later. This allows you to check at different parts of
* your program flow.
* The stack pointer starts at the top of RAM and grows downwards. The heap pointer
* starts just above the static variables etc. and grows upwards. SP should always
* be larger than HP or you'll be in big trouble! The smaller the gap, the more
* careful you need to be. Julian Gall 6-Feb-2009.
*/
 
void check_mem() {
  //uint8_t * heapptr, * stackptr;  // I declared these globally
  stackptr = (uint8_t *)malloc(4);  // use stackptr temporarily
  heapptr = stackptr;                  // save value of heap pointer
  free(stackptr);                        // free up the memory again (sets stackptr to 0)
  stackptr =  (uint8_t *)(SP);       // save value of stack pointer
  }
Miło być decenianym https://buycoffee.to/kaczakat
 
Odpowiedź
#38
W wyniku działania programu ( dziękuje kaczakat) otrzymałem wynik iż wolna pamieć to 1422 RAM . Tylko dziwne okazało się dla mnie to że zawsze świeciła mi się dioda od strefy nieczułości , nawet w momencie gdy nie miała prawa świecić - np. przy warunku  "if(wartosc>(WILG+2))". Taka wolna pamieć ram jest chyba dopuszczalna.
 
Odpowiedź
#39
(28-10-2018, 13:23)Automatyk231 napisał(a): W wyniku działania programu ( dziękuje kaczakat) otrzymałem wynik iż wolna pamieć to 1422 RAM .
Po kompilacji w raporcie jaki jest pokazane zużycie RAM?
 
Odpowiedź
#40
(28-10-2018, 13:37)es2 napisał(a): Po kompilacji w raporcie jaki jest pokazane zużycie RAM?



Szkic używa 14708 bajtów (45%) pamięci programu. Maksimum to 32256 bajtów.

Zmienne globalne używają 625 bajtów (30%) pamięci dynamicznej, pozostawiając 1423 bajtów dla zmiennych lokalnych. Maksimum to 2048 bajtów.
 
Odpowiedź
  


Skocz do:


Przeglądający: 1 gości