Page 1 of 1

Timer 3 int

Posted: Mon Sep 14, 2009 11:02 am
by Mikat
Does Flowcode4 support timer 3 interrupt?
I tried edit the fcd file,like in flowcode3 but i didnt get the timer3 interrupt at the interrupt list.
So how can i use timer3 interrupt? I need timer3,because 0 and 2 dont give enought low interrupt rates,and the tmr1 is used other thing.
And is there way to limit a floating point calculation precision,like 1,2 or 3 decimal?

Mika

Re: Timer 3 int

Posted: Mon Sep 14, 2009 1:02 pm
by Benj
Hello Mika

Which target are you trying to enable the timer 3 interrupt on? As far as I am aware I added the timer 3 interrupt to all devices that are capable of using it in V4.

I dont think there is a way to limit the precision of the floating point maths but you may be able to add an extra section of code to allow you to do this.

Re: Timer 3 int

Posted: Mon Sep 14, 2009 1:23 pm
by Mikat
Target is 18F4620,i get the tmr3 int working at fc3,but not in fc4.
I dont really need the limit the fp precision,but is there "easy" way limit the number behind the dot,so that i can print the float value like 12.7 not 12.7563..
Or is the only way to get float back to int,and to it in int numbers?

Re: Timer 3 int

Posted: Mon Sep 14, 2009 2:02 pm
by Benj
Hello

The interrupt should be allowed to work if you like attach your FCD file to the forum topic and Ill have a look for you. One think to check is the overall number of interrupts specified at the start of the [Interrupt] section.

Thankfully I anticipated this float request. The C code call that is generated for the Float to string function looks like this when my float variable is named f and my string variable is named s in Flowcode.

Code: Select all

FCI_FLOAT_TO_STRING(FCV_F,6,FCV_S,FCSZ_S);
Flowcode defaults to 6 characters of precision when using the function in the string manipulation icon. You could use a C code icon to change this.

This would give you one character of precision.

Code: Select all

FCI_FLOAT_TO_STRING(FCV_F,1,FCV_S,FCSZ_S);

Re: Timer 3 int

Posted: Mon Sep 14, 2009 2:06 pm
by Mikat
Great,thanks Ben.
Can that be used multiple times,eg. adjust the precision do one calculation in 2 decimal precision then adjust the precision again,next calculation in 3 decimal etc..

Re: Timer 3 int

Posted: Mon Sep 14, 2009 4:02 pm
by Benj
Hello Mika

Yes you can use as you wish in as many different combinations. The Flowcode function will always use a value of 6 but if your calling the function from C then you can specify any value you wish (within reason). We picked 6 as a default as this works quite nicely for GPS.