If I run the following program:
I would expect the following output:
Instead I get something like this:
The output depends on the program I did execute before this program. The output you see is for the case that the program is the first after powering up the teensy 4.0.
It seems that printf uses some wrong memory. The error has been observed only at 24MHz CPU frequency. With other frequencies I don't see the error. Any idea what goes wrong here?
Code:
extern "C" uint32_t set_arm_clock(uint32_t frequency);
float x1,x2 ;
float b11,b12,b21,b22 ;
float xshb1,xshb2 ;
void setup() {
Serial.begin(115200);
while(!Serial) ;
Serial.println("teensy40timingMat22Mul1printError1...") ;
set_arm_clock(24000000) ;
b11=cos(1) ;
b12=sin(1) ;
b21=-sin(1) ;
b22=cos(1) ;
x1=1.0 ; x2=0.0 ;
xshb1=b11*x1+b12*x2 ;
xshb2=b21*x1+b22*x2 ;
Serial.print("x1 =") ; printFloat(x1) ;
Serial.print(" x2=") ; printFloat(x2) ; Serial.println(" ") ;
Serial.print("xshb1=") ; printFloat(xshb1) ;
Serial.print(" xshb2=") ; printFloat(xshb2) ; Serial.println(" ") ;
}
void printFloat(float x){
Serial.printf(" ::%15.10f",x) ;
//Serial.print(x) ;
}
void loop() {
}
Code:
teensy40timingMat22Mul1printError1...
x1 = :: 1.0000000000 x2= :: 0.0000000000
xshb1= :: 0.5403022766 xshb2= :: -0.8414709568
Code:
teensy40timingMat22Mul1printError1...
x1 = :: 1.0000000000 x2= :: 0.0000000000
xshb1=ùÇ\…ÊÐG¡mGH‹3µæ¾š™Öû}/AÞŸ×û�ãÅk<„ù�Hi€k/ë(ÀÀª¯¯{Ì°§¬Å^'Ä‘ý xshb2= :: -0.8414709568
The output depends on the program I did execute before this program. The output you see is for the case that the program is the first after powering up the teensy 4.0.
It seems that printf uses some wrong memory. The error has been observed only at 24MHz CPU frequency. With other frequencies I don't see the error. Any idea what goes wrong here?