CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

RTOS and floating point compilation issue

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
sirmeowsalot



Joined: 18 Jan 2013
Posts: 7

View user's profile Send private message

RTOS and floating point compilation issue
PostPosted: Fri Sep 27, 2013 7:44 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Sep 27, 2013 8:32 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Sep 27, 2013 11:33 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Oct 01, 2013 12:18 pm     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group