[SOLVED] Non-blocking PWM duty cycle capture using Timer Counter

Hi drmOhr,

First, thank you so much for writing this code, it does exactly what I needed it to.

I'm wondering though if you ever tested it with multiple inputs at the same time? I tried setting up two inputs on D2 and D3, but can't seem to get it to work.

The issue I'm having seems to be where the PIO pin is configured as a peripheral. I tried just changing variable names to duplicate your code and have two running at the same time, but obviously there's more to it than that. Unfortunately, I'm not at all familiar with utilizing the datasheets to directly manipulate registers on the MCU.

Here's the part that is giving me trouble -

const PinDescription2 *config = &g_APinDescription2[CAPTURE2_PIN];
	PIO_Configure(
	  config->pPort,
	  config->ulPinType,
	  config->ulPin,
	  config->ulPinConfiguration
	);

And here's the error I'm getting out -

Arduino: 1.5.4 (Windows 7), Board: "Arduino Due (Programming Port)"

Due_Datalogger_DualFreqInput2.ino: In function 'void setup()':
Due_Datalogger_DualFreqInput2:152: error: expected initializer before '*' token

  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.

It looks to me like it's getting hung up on the "PinDescription2" title that I've given it, but as far as I can tell, that should just be a variable name, so I'm not sure why it cares. The rest of the code is identical to what you have posted here, I've just got two versions, one being titled "CAPTURE_....." and the other being "CAPTURE2_......". Renaming everything to "CAPTURE2_....." and running a single version of the code works fine, so I know it's not an issue with the naming of the capture variables.

Any help would be greatly appreciated. Thanks!

-Tyler