Monday, 7 November 2016

software - Counting pulse in firmware without interrupt


How can I count the number of pulses using a microcontroller (any), provided the following conditions:



  1. Can not use any interrupt (no interrupt on pin change allowed)

  2. 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.


Any idea?



PS: This question was asked on a technical interview with one of the major automotive component supplier.




No comments:

Post a Comment

arduino - Can I use TI's cc2541 BLE as micro controller to perform operations/ processing instead of ATmega328P AU to save cost?

I am using arduino pro mini (which contains Atmega328p AU ) along with cc2541(HM-10) to process and transfer data over BLE to smartphone. I...