PwmIn (at least the library I found) uses the timer.read function, which returns the time in seconds, but with floating point precision. In other words, if you want the period in microseconds, simply multiply it by one million.
If you already tried that, then I assume you accidently did a conversion to integer (too soon). If you want to work with integers, make sure you first multiply it by a million, and then convert it to integer, otherwise it will first round the float. Lets say your period is 20ms, so 0.02 seconds. If you round that first, the result is zero.
hello everyone. I would like to read an input frequency from a humidity sensor on my mbed; So I dowloaded the PwmIn library, but I don't now the current accuracy of the pin which is configurate with the PwmIn. I read a period by using the fonction period() in second, and i would like now to read a period in microsecond. Is it possible to increase the precision of the PwmIn entry? Is the mbed enough precise to detect variations in order to microsecond. Because i want to detect little frequencie's variations. I'have already try to use the fonction period_ms() or period_us() but they don't work. Thank Mat