Hello
I am about to make a revolution counter on an atmega32 and I need to use at least float or double variables to calculate the time that passed per pulse.
the problem is, that I do this inside of an interrupt, because I want to have the exact value of the time that is counted by another timer interrupt.
when I declare a float inside of the main macro, the variable won't be available in the interrupt because it is not declared globally, and the parameter passing to the interrupt doesn't work as well because it is a self defined value.
do you have any idea how to solve this problem? or is there a way to globally declare a variable outside of the main macro?
thanks in advance, nils
using float variable in an interrupt
ok, I figured something myself out:
as long as I do the calculating INSIDE the macro, I can use self defined float variables. then I do my calculations, and afterwards do a narrowing cast by assigning the float to a FCV_ variable that may be an INT or BYTE. it doesn't work out the decimal point thing, but it may help if you want to do something like 5000 / 25000 that would be zero if calculated with an INT
as long as I do the calculating INSIDE the macro, I can use self defined float variables. then I do my calculations, and afterwards do a narrowing cast by assigning the float to a FCV_ variable that may be an INT or BYTE. it doesn't work out the decimal point thing, but it may help if you want to do something like 5000 / 25000 that would be zero if calculated with an INT