printf error at 24 MHz with teensy4.0

Status
Not open for further replies.

ossi

Well-known member
If I run the following program:
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() {
   }
I would expect the following output:
Code:
teensy40timingMat22Mul1printError1...
x1   = ::   1.0000000000     x2= ::   0.0000000000 
xshb1= ::   0.5403022766  xshb2= ::  -0.8414709568
Instead I get something like this:
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?
 
I've seen that as well - seems it was more intermittent so continue code and printing and see what happens - but generally worked. Not sure if T4 is spec'd to have USB at 24 MHz - Paul will likely comment when he sees your post.

For now try 25 or 26 MHz request and check F_CPU_ACTUAL - bumping up the next notch may be work-around- but won't result in the same power profile as it Voltage drops again at 24 MHz.

Though one clock until TD 1.48 was at 30 MHz in 24 MHz mode - general tests here may predate that - though sure I tested as I discovered coding error behind the 30 MHz issue.
 
We should probably configure the USB PHY to only work at 12 Mbit speed when 24 MHz is configured.

Really, it's pretty amazing it works at all. I believe NXP has a minimum speed spec for USB to get enough memory bandwidth. I don't recall the number, but I remember it had 3 digits! 24 MHz is so far below what is supposed to be able to work at all.
 
Status
Not open for further replies.
Back
Top