Glad I could help :)
Originally Posted by
spfautsch
Quick question - it should probably be obvious but why are you using these read functions 'pgm_read_word(&rpmReference[rpmIndex])' to read the table cells?
When you place data in program (flash) memory (PROGMEM attribute), you have to inform the code that tries to read it, that the data is in fact in flash, not in RAM. That's why we use pgm_read_xxx functions. Without this, the program would fail as the code would try to read from RAM using FLASH addressing.
Important thing I noticed and changed. There even were warnings about it during compilation. When using pointers to port addresses in "cylinders" structure, you MUST retain the volatile attribute for port addresses:
Code:
typedef struct {
int cylNo; // user readable cylinder no
int armed; // set to 1 = armed for dwell, set to 0 = est signal caught - prevents dwell routine from dwelling recently fired coil
volatile uint8_t *portAddr; // used at a pointer to the output registers so coil drivers can be controlled directly (faster than using digital[write/read]() arduino functions)
byte bitMask; // the bit mask of each output pin - see the ATmega datasheet for more info on this and timers
} cylinders;
Without volatile, compiler could optimize out some output pin operations.
One more thing, of course I mislabelled RPM_TO_MS macro - it should be called RPM_TO_US.
Bookmarks