View Single Post
Old 05-04-2012, 06:45 AM   #373 (permalink)
meelis11
EcoModding Apprentice
 
meelis11's Avatar
 
Join Date: Feb 2009
Location: Estonia
Posts: 199

Green frog - '97 Audi A4 Avant 1.9TDI 81kW
Diesel
90 day: 43.1 mpg (US)
Thanks: 19
Thanked 40 Times in 28 Posts
You dont have to change crystal, change code.
http://opengauge.googlecode.com/svn/...no/mpguino.cpp
cpp file has section where you comment 20mhz part out and 16mhz part in. Only few lines needs changing.

change this part...
Quote:
//use with 20mhz
#define cyclesperhour 4500
#define dispadj 800
#define dispadj2 1250
#define looptime 1250000ul/loopsPerSecond //1/2 second
#define myubbr (20000000/16/9600-1)
#define injhold (parms[injectorSettleTimeIdx]*5)/4

#define outhi(port,pin) PORT##port |= ( 1 << P##port##pin )
#define outlo(port,pin) PORT##port &= ~( 1 << P##port##pin )
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))

//use with 16mhz, not tested
//#define cyclesperhour 3600
//#define dispadj 1000
//#define dispadj2 1250
//#define looptime 1000000ul/loopsPerSecond //1/2 second
//#define myubbr (16000000/16/9600-1)
//#define injhold parms[injectorSettleTimeIdx]
...to this:
Quote:
//use with 20mhz
//#define cyclesperhour 4500
//#define dispadj 800
//#define dispadj2 1250
//#define looptime 1250000ul/loopsPerSecond //1/2 second
//#define myubbr (20000000/16/9600-1)
//#define injhold (parms[injectorSettleTimeIdx]*5)/4

#define outhi(port,pin) PORT##port |= ( 1 << P##port##pin )
#define outlo(port,pin) PORT##port &= ~( 1 << P##port##pin )
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))

//use with 16mhz, not tested
#define cyclesperhour 3600
#define dispadj 1000
#define dispadj2 1250
#define looptime 1000000ul/loopsPerSecond //1/2 second
#define myubbr (16000000/16/9600-1)
#define injhold parms[injectorSettleTimeIdx]

Other option is, that you use older version - it is arduino compatible withiout changes:
http://opengauge.googlecode.com/svn/...no/mpguino.pde

Meelis

Last edited by meelis11; 05-04-2012 at 06:53 AM.. Reason: typos fixed, code part pasted in
  Reply With Quote