How to use PIC32MZ EF FPU?

General discussion on mikroC PRO for PIC32.
Post Reply
Author
Message
den1892
Posts: 6
Joined: 24 May 2020 11:30

How to use PIC32MZ EF FPU?

#1 Post by den1892 » 25 May 2020 14:14

Hello! I am a newbie in PIC32 theme and I have a question about Floating Point Unit in PIC32 EF family. How can I use this module? For example, I need to devide 3,792 by 1.673. Give me an example code pls. Best regards!

User avatar
stefan.filipovic
mikroElektronika team
Posts: 1135
Joined: 18 Dec 2018 10:30

Re: How to use PIC32MZ EF FPU?

#2 Post by stefan.filipovic » 26 May 2020 10:43

Hi,

Here's a simple example:

Code: Select all

float x = 3.792;
float y = 1.673;

float res = 0;
void main() {
    res = x/y;
    
    while(1);
}
In generated listing file you will notice FPU instructions:

Code: Select all

LWC1        S1, Offset(_y+0)(GP)  
LWC1        S0, Offset(_x+0)(GP)  
DIV.S         S0, S0, S1          
SWC1        S0, Offset(_res+0)(GP)
Kind regards,
Stefan Filipović

den1892
Posts: 6
Joined: 24 May 2020 11:30

Re: How to use PIC32MZ EF FPU?

#3 Post by den1892 » 26 May 2020 14:04

Hello dear friend! Thank you for you help! Everything is perfectly clear!

Post Reply

Return to “mikroC PRO for PIC32 General”