Site Tools


Hotfix release available: 2025-05-14b "Librarian". upgrade now! [56.2] (what's this?)
Hotfix release available: 2025-05-14a "Librarian". upgrade now! [56.1] (what's this?)
New release available: 2025-05-14 "Librarian". upgrade now! [56] (what's this?)
Hotfix release available: 2024-02-06b "Kaos". upgrade now! [55.2] (what's this?)
sw:uc

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
sw:uc [2009/01/25 12:18] – angelegt 172.22.1.222sw:uc [2024/04/15 00:43] (current) – external edit 127.0.0.1
Line 1: Line 1:
 +====== ATmega ======
 +==== PROGMEM ====
 +=== Strings + Array ===
 +
 +<code c>
 +  #include <avr/pgmspace.h>
 +  const char ptmpUP_msg[]      PROGMEM = "Upper Temp";
 +  const char ptmpDN_msg[]      PROGMEM = "Lower Temp";
 +  const char ptmpCLG_msg[]     PROGMEM = "Chiller Temp";
 +  const char* const pgtmp_msg[]  PROGMEM =
 +  { ptmpUP_msg, ptmpDN_msg,  ptmpCLG_msg };
 +</code>
 +
 +oder alternativ mit flash statt PROGMEM:
 +
 +<code c>
 +  const __flash char ptmpUP_msg[]  = "Upper Temp";
 +  const __flash char ptmpDN_msg[]  = "Lower Temp";
 +  const __flash char ptmpCLG_msg[] = "Chiller Temp";
 +  const __flash char* const __flash pgtmp_msg[] =
 +  { ptmpUP_msg, ptmpDN_msg,  ptmpCLG_msg };
 +</code>
 +
 +<code>
 +  pgtmp_msg is const and located in flash.  And it contains elements that are 
 +  pointers to const locations in flash.
 +</code>
 +
 +=== Functionpointer===
 +
 +<code>
 +Your functions are of prototype "void (*)(void)", not of "void (*)()".
 +And the return type is "void", not "__flash void"; avr-gcc throws a
 +diagnostic on this.
 +</code>
 +If you want to put the array in flash, then put funcArray in flash:
 +
 +<code c>
 +void func1 (void) {}
 +void func2 (void) {}
 +void func3 (void) {}
 +
 +void (* const __flash funcArray[])(void) = { func1, func2, func3 } ;
 +
 +void run (unsigned char funcNo){
 +   funcArray[funcNo] ();
 +   }
 +</code>
 +
 +
 ====== Quadratwurzel ====== ====== Quadratwurzel ======
 The simplest square root algorithm is to simply subtract successive odd The simplest square root algorithm is to simply subtract successive odd
Line 4: Line 54:
 (9-1=8) (8-3=5) (5-5=0)\\ (9-1=8) (8-3=5) (5-5=0)\\
 Three subtractions so the sq root of nine is 3. Three subtractions so the sq root of nine is 3.
- 
 ====== Dezimalbrüche und Brüche wandeln ====== ====== Dezimalbrüche und Brüche wandeln ======
 z.B.faktor=2.12345676\\ z.B.faktor=2.12345676\\
sw/uc.1232882292.txt.gz · Last modified: 2024/04/15 00:43 (external edit)