Showing results for 
Show  only  | Search instead for 
Did you mean: 
Registered: ‎05-21-2009

Problem with PowerPC SDK float division



I don't know if this is an SDK issue or PowerPC issue, so I'm posting it here.


I wrote some code in SDK for PID control. To test this control, I'm running it on the SDK by using the hardware debugger and stepping through the code.


The problem is I can't step past the line marked "Problem Line" (T = 1.0/fs). Initially I got a window saying "Source not found", but after changing a bunch of stuff, I'm not even getting that window again. Now the program suspends at that line, and if I step again I get the error: "Single stepping until exit from function _start, which has no line number information."


Anyone have any ideas what is going on? Did I do something wrong in the SDK? Should I add anything to use floats? I thought the issue was I had no FPU, but the problem stayed the same after adding the FPU. Did I maybe add it wrong?


Any help will be appreciated.



// #Includes

#include "method_1.h"

#include "method_2.h"

#include "method_3.h"

#include <math.h>

#include "stdio.h"

//#include "float.h"



// Defines

#define METHOD (1,2,3)


// Constants

float fs = 20000.0F ; // Sampling frequency



// PID parameters

int Kp = 20000 ; // Proportional gain

int Ki = 3 ; // Integraton constant

int Kd = 38 ; // Differential constant


// PID control variables

long a0 = 0 ;

long a1 = 0 ;

long a2 = 0 ;

long b1 = -1 ;

long b2 = 0 ;

float a0_f = 0;

float a1_f = 0;

float a2_f = 0;


// Other variables

float T = 0.0F ; // Sampling period

int x = 0 ; // PID input value

int y = 0 ; // PID output value



// Arrays

long m[3] = {0} ; // Array to store intermediate values



// Counter declaration

int k = 0 ;


// Memory pointers

volatile signed int *mem_pter = 0x0;

unsigned int mem_counter = 0x0;

signed int readpointer = 0 ;

signed long writepointer = 0 ;


// Function declarations

long method_func1(signed int x, long *m, long b1, long b2, long a0, long a1, long a2) ; // Function is in method_1.h






k = 1 ;


T = 1.0/fs ; // <======================= Problem line ======================


a0_f = Kp + (Ki*T/2) + (Kd/T) ;  

a1_f = -Kp + (Ki*T/2) + (2*Kd/T) ;  

a2_f = Kd/T ;  


a0 = (

a1 = (long)a1_f;

a2 = (


for (mem_counter = 0x11000000 ; mem_counter <= 0x11001000 ; mem_counter += 4)


mem_pter = (
unsigned int*) mem_counter ;

readpointer = 0 - *mem_pter ;


writepointer = method_func1(readpointer, m, b1, b2, a0, a1, a2) ;


"%ld\n",writepointer) ;




return 0;



Message Edited by rikusleroux on 07-13-2009 01:56 AM
0 Kudos
3 Replies
Registered: ‎05-21-2009

I've tracked this error down to an SDK problem. SDK 10.1 is absolute rubbish. I've downloaded SDK 11.1 as a trail version, but it is still not that much better.


I can't believe no-one experienced this error before.

0 Kudos
Registered: ‎02-25-2008

rikusleroux wrote:

I've tracked this error down to an SDK problem. SDK 10.1 is absolute rubbish. I've downloaded SDK 11.1 as a trail version, but it is still not that much better.

Exactly what is this "SDK problem" ??


I can't believe no-one experienced this error before.

I've never used floating point in an embedded design.



----------------------------Yes, I do this for a living.
0 Kudos
Registered: ‎05-21-2009

In SDK 10.1, when using floating point calculations and the internal floating point libraries, the compiler is able to calculate a basic command (while stepping through the code on a hardware emulation) such as T = 1.0/20000.0 (where T is float). However, the moment I try to do something such as: T = 1.0/fs (with T and fs float, and fs = 20000.0), I get an error saying "source not found". This happens for every floating point calculation. Whether it is summation, subtraction or multiplication. After instantiating the APU-FPU, this error changes to:  "Execution is suspended because of an error" or the emulation continues to loop to infinity, newer stepping past the floating point calculation, whether it is  T = 1.0/20000.0 or T = 1.0/fs. If I just run the code, with no breakpoints, it also continues to loop to infinity.


After porting my code from EDK 10.1 to 11.1 and changing nothing in the code, the compiler is able to step past the lines with floating point calculations, but every once in a while, it still crashes with the same error(s) as in SDK 10.1. However, if I just run the code (no stepping and no breakpoints), after a few tries, the correct output is recieved from the code.


So, I have no idea what the possible cause might be, and I was hoping someone could give me some insight on this problem, but it looks to me like a compiler issue.

0 Kudos