How can I count the number of pulses using a microcontroller (any), provided the following conditions:
- Can not use any interrupt (no interrupt on pin change allowed)
- Can not use any of uC's hardware features (counter, timer etc.)
The width of the pulse is random and can not be predicted in advance. This pulse train is given to one of the general purpose IO pins. The solution should be purely software based ( C/assembly).
The software debouncing method which reads pin status as a series of 0's and 1's is a possible option but you need to hardcode the transition pattern, which means that you need to know the pulse width in advance and hence its can not be accepted.
PS: This question was asked on a technical interview with one of the major automotive component supplier.