EmbeddedRelated.com
Forums
Memfault Beyond the Launch

C arrays (variable[element]) and storing in flash

Started by asel34 October 3, 2004

Hey,
Does anyone know how to store and retrieve the contents of an array 
to and from flash memory in C? In other words, 

int array[10];
array[(element 0 thru 9)] = (some data stored in flash);

Probably simple, I could do it in ASSY, but I'd rather keep it all in 
C if possible. If you're interested, I'm trying to use a f149 for a 
Mass Air Flow - sensor based EFI system... A-D the maf and o2 sensor, 
use a lookup table to come up with injector PW. So far it works, but 
I want a simple way to use real calib data, and store it to ram so it 
doesn't get overwritten by my dummy table filling data routine every 
time I power down and back up and ram gets wiped...
Thanks!







Beginning Microcontrollers with the MSP430

There are app. notes from Ti covering this for both C and assembly. If 
you want a decent EFI system here are a few tips:_

O2 sensor. If you reference your system from chassis ground you will 
discover a varying signal around 2.6V between this and the engine ground 
used by the EGO sensor. I recommend the use of an LM9044 dedicated EGO 
signal conditioner to overcome this, although you can also roll your own 
circuits. If you refence your system from engine ground you will have 
similar problems with the other sensors.

Table should be MAP/MAF vs RPM. Don't try mapping from the O2 sensor, it 
has a very sharp cut off.

Fuel maps are NOT linear. space RPM at least every 500, and have at 
least 16 divisions for MAF. Do a 4 way interpolation between points.

Make sure you account for inlet air temp, engine temp, hot start, cold 
start, and cranking issues.

It's no use throwing fuel at the engine once you've hit peak
acceleration.

Increasing inlet airflow volume and efficiency, and the same for the 
exhaust will yield significant benefits on many older cars.

Turn off the AC during hard acceleration.

These are just a few of the basics. Once you've got these sorted there 
are lots of other things to tinker with. Like adaptive learn in several 
flavours, acceleration strategies, closed loop etc.

The '149 is a great part for an ECU, I built a credit card sized one a 
few years ago with built in data logger, wireless logger/programmer, and 
a few other nice bits and pieces. I stayed with 6 injector and 6 
ignition drivers (I think V8's are dinosaurs) so that I could play 
around with Sequential Direct Injection, but moved on to other things. 
It was designed to run both petrol and high pressure liquid propane 
injection systems. (I also built a full blown adaptive ECU using a 
PIC12C674 many years ago, just for the hell of it).

Have fun

Al


asel34 wrote:
> 
> 
> Hey,
> Does anyone know how to store and retrieve the contents of an array 
> to and from flash memory in C? In other words, 
> 
> int array[10];
> array[(element 0 thru 9)] = (some data stored in flash);
> 
> Probably simple, I could do it in ASSY, but I'd rather keep it all in 
> C if possible. If you're interested, I'm trying to use a f149 for
a 
> Mass Air Flow - sensor based EFI system... A-D the maf and o2 sensor, 
> use a lookup table to come up with injector PW. So far it works, but 
> I want a simple way to use real calib data, and store it to ram so it 
> doesn't get overwritten by my dummy table filling data routine every 
> time I power down and back up and ram gets wiped...
> Thanks!
> 



Memfault Beyond the Launch