View previous topic :: View next topic |
Author |
Message |
sirmeowsalot
Joined: 18 Jan 2013 Posts: 7
|
RTOS and floating point compilation issue |
Posted: Fri Sep 27, 2013 7:44 pm |
|
|
Hi!
First things first:
CCS 4.130
MPLAB X IDE v1.60
PIC16F785
So I'm running into a problem on my project where adding one more line of code causes it to not compile and I'm not quite sure why. Did a test program that shows basically where my issue is. It works fine with the line commented out but won't compile with it uncommented:
Code: | #include <16F785.h>
#include <float.h>
#include <stdlib.h>
#use delay(clock=8000000)
#use rtos(timer=2,minor_cycle=10us)
float test1 = 1.1;
float test2 = 2.2;
float test3 = 3.3;
float test4 = 4.4;
float test5 = 5.5;
float test6 = 6.6;
float test7 = 7.7;
float test8 = 8.8;
float test9 = 9.9;
float test10 = 10.10;
#task(rate=10us,max=10us)
void task();
#task(rate=10us,max=10us)
void task2();
void task() {
test3 = test1 + test2;
test2 = test3 * test1;
test3 = test1 + test2;
test10 = test1 * test2 * test3 * test4 * test5 * test6 * test7 * test8 * test9;
}
void task2(){
test1 = test2 * test3;
test3 = test4 * test1;
test4 = test5 * test6;
test7 = test8 * test9;
test10 = test2 * test4;
test1 = test2 * test3 * test4 * test5 * test6 * test7;
//test8 = test4 * test6;
}
void main() {
setup_oscillator(OSC_8MHZ);
rtos_run();
} |
I was thinking it's some kind of memory limitation or issue, but MPLAB X is telling me I still have some room left. Any ideas? |
|
|
jeremiah
Joined: 20 Jul 2010 Posts: 1346
|
|
Posted: Fri Sep 27, 2013 8:32 pm |
|
|
version 5.011 compiles it fine with the line added. I will say this is probably not the PIC you want to be using for floating point operations. Going to be tight. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Fri Sep 27, 2013 11:33 pm |
|
|
An understanding of just how long fp maths takes is also worth having.
99.9% of things that are done on PIC's don't need fp. Scaled integers, are smaller, and faster.
Now your top task performs nine fp multiplications, and two additions. On an 8MHz PIC16, these will take about 4500uSec, yet you ask for the task to repeat at 10uSec intervals. Ouch....
You are asking the chip to do too much, too fast. Never going to properly work.
Best Wishes |
|
|
sirmeowsalot
Joined: 18 Jan 2013 Posts: 7
|
|
Posted: Tue Oct 01, 2013 12:18 pm |
|
|
Cool, thanks for the information! I've actually only recently changed over to floating point for the project to test because I was converting everything to integers for a while and the math ended up a bit funky, so I'm trying floating point to see if maybe my conversion is off somewhere or if something else is wrong.
jeremiah: Ah, dang. So... partially compiler issue then
Ttelmah: Thanks! I'll slow it down a bit then and give it a shot since what I'm testing with fp doesn't need to be fast |
|
|
|