why pow() is not working in codewarrior?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

why pow() is not working in codewarrior?

906 Views
khalidsakib
Contributor I

I like to turn on a specific 7-segment display (total 4 7segment display) in Dragon12 plus development board. I want to select a specific 7-segment display (out of 4) and light with a specific no. (here i am showing 6 (to show 6 i put 125(decimal) ). Now in the following program x1=2 (that means 1st 7-segment should be on and it works, (counted like 0th, 1st, 2nd and 3rd ) ) and shows 6 that i want to show . But I want to use x1=pow(2, ) . So when I used x1=pow(2, 1) it select the right 7-segment display but it does not show 6. instead it shows something wired (nothing meaningful in that 7segment display). WHY???     

 

// Example 1a: Turn on every other segment on 7-seg display

#include <hidef.h>      /* common defines and macros */

#include <mc9s12dg256.h>     /* derivative information */

#include "math.h"

#pragma LINK_INFO DERIVATIVE "mc9s12dg256b"

#include "main_asm.h" /* interface to the assembly module */

 

void main(void) {

int s;

float b ;

float x ;

float x1;

 

  PLL_init();        // set system clock frequency to 24 MHz

  DDRB  = 0xff;       // Port B is output

  DDRJ  = 0xff;       // Port J is output

  DDRP  = 0xff;       // Port P is output

  PTJ = 0x02;         // disable LED  0x02

  PTP = 0xff;         // disable all 7-segment displays

  PORTB   = 0x00 ;

 

  s =125;

    

    b=1;

    x1=pow(2,b);

    x=15-x1;

   PTP = x;

   PORTB = s;

}

Labels (1)
0 Kudos
1 Reply

689 Views
trytohelp
NXP Employee
NXP Employee

Hi Khalid,

I've created a project with the wizard for 9s12DG256B.

This example is using the Full Chip Simulator (FCS).

The pow instruction seems to be running fine.

Now I added a part of your code and for me it's running fine.

Attached the project and the debugger view.


Have a great day,
Pascal

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos