====== ATmega ======
==== PROGMEM ====
=== Strings + Array ===
#include
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 };
oder alternativ mit flash statt PROGMEM:
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 };
pgtmp_msg is const and located in flash. And it contains elements that are
pointers to const locations in flash.
=== Functionpointer===
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.
If you want to put the array in flash, then put funcArray in flash:
void func1 (void) {}
void func2 (void) {}
void func3 (void) {}
void (* const __flash funcArray[])(void) = { func1, func2, func3 } ;
void run (unsigned char funcNo){
funcArray[funcNo] ();
}
====== Quadratwurzel ======
The simplest square root algorithm is to simply subtract successive odd
numbers and count the number of subtractions:\\
(9-1=8) (8-3=5) (5-5=0)\\
Three subtractions so the sq root of nine is 3.
====== Dezimalbrüche und Brüche wandeln ======
z.B.faktor=2.12345676\\
maxima: rat(2.12345676);\\
rat' replaced 2.12345676 by 172/81 = 2.123456790123457\\
Um mit Faktor zu multiplizieren: *172/81; dividieren: *81/172
====== scanf für unsigned int ======
unsigned int getint(void)
{
unsigned int n=0;char c;
while (((c=getchar())>='0') && (c<='9')) n=10*n+(c-'0');
return n;
}
====== MSP430/gcc exec code im RAM ======
int machlang[15]={
0xe3b2, 0x0031, //xor #-1,&0x31 (emulating INV)
0x4130 //ret
};
int (*machfn)() = NULL;
machfn= (int (*)()) machlang;
machfn();