megaAVR to AVR migration

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello,

 

Got a bit of a stumper on this. I'm thinking I have to look back in some earlier files to find it, but I have the following code. The specific issue I am having is the lack of definition for __PIO2. Any ideas or guidance where to look for this would be great. Thank you.

 

  case 6:
  // calculate new params based on mean excursion and oscillation time of bangbang
  fNh =(float)(Nheat); fNc = (float)(Ncool);
  Eh = acc4/fNh; Ec =acc5/fNc; Th = fNh*Ts; Tc = fNc*Ts; 
  Tosc = ((Th+Tc)*(Th+Tc) + 4. * Th*Tc) / (2.* (Th+Tc));
  Ampl = (__PIO2)*(Eh - Ec);
  
  db_fpoke(&_Ti, 0.896 * Tosc);
  if (Ampl < 2.* h)   
    {
    db_fpoke(&_Td, 1.1);            // ensure within db limits
    db_fpoke(&_Prop_band, 2.6 * Ampl* bb_Tune_Stiffness);
    }
  else               
    {
    db_fpoke(&_Td, 0.152 * Tosc);  
    db_fpoke(&_Prop_band, 1.3 * Ampl* bb_Tune_Stiffness);
    }
    
    if(SPrr_tune != 0.) 
      {
      y = SPrrfactor*Ampl*10./Tosc;         //calc a controllable rate
      y = macro_max (y, min_SPrr);
      db_fpoke(&_SPrr_tune,y );             // always set this if poss to condition alarms
      }
      
  PID.OP = PID.OPlast =  Th/(Th+Tc);        // prepare for bumpless to OP mean
  clr_tune_fail;                            // assume successful
  db_fpoke(&_Tuned_at_addr, (float)this_zone_addr);   // validate PID parameters
  tune_phase = 8;
  break;

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

the lack of definition for __PIO2.

Usually definitions are in the io.h file, perhaps you can show a bit more of your code to see how it is included in the project.

John Samperi

Ampertronics Pty. Ltd.

https://www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Um...  Looks like "__PIO2" is used some places  (IAR?) math.h as "Pi over 2", and the more common symbol is:

 

/** The constant \a pi/2.	*/
#define M_PI_2		1.57079632679489661923	/* pi/2 */

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

That is exactly what it is. I had to install and old version of IAR to find it in the math.h file. I appreciate it very much.