Can clkfreq be converted to float?
lardom
Posts: 1,659
I want to use a float number in a 'delay' expression. The following line does not work;
waitcnt(clkfreq /(float) + cnt)Calculating the distance along a circumference, C = 2pi * r, is easily done in the float objects. I want to be able to define speed as well as distance in float.
Comments
So something like this:
Like Bobb said, you could use a foating point conversion object to do this.
I think it would be best to wait to convert the difference of two times. Use interger math to do the subtraction of the two clock values and then, if you need/want to, convert this smaller number to a float. I bet just converting the final difference will save you a lot of headache.
I think I spotted an important key in this thread. Here
Since the system counter only works with integers I see that I'll have to convert my result values to integers before I insert them into a waitcnt expression. I'll move the decimal points to the right to maintain precision and try again.