I am trying to port my program that worked fine on MSP430 to Arduino.
I need to measure the current that flows trough the load, measurement about 8 times in a second, measuring the voltage over a current sense resistor connected to the ADC. So measurement is only possible when current is flowing, and to get good results the current must have been flowing for a little time before the measurement is taken (voltage drop of the battery affecting results)
So I measured the ADC always when PWM count was at a certain value.
So my code was waiting that the PWM counter reached a certain count ( for example if the PWM counter was counting up to 255, the measurement was done when counter was at 20) before making the measurement and then exiting and returning the value. This way it worked.
So can I somehow use Arduino similarly, or is it too high level language for that?