Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC Benchmarking

Status
Not open for further replies.
Looking at the data sheet, it seems the times are consistent with Not using hardware multiply. I couldnt figure out how to look at the ASM before I left for work this morning, But It seems strange considering that XC8 is Microchips own language. I bet you the optimized version probably makes use of the Hardware Multiply! The results would be better if I could figure out how to get PLL to work in XC 8, as it worked fine in Swordfish! For what its worth, the On time was in the nano second range!

Now to just get my PIC32MX working...I would really Love to see the performance on that!
 
Would take about 100ns on PIC24 including all the data loading and storing. Might be even better on PIC32.

PLL should be easy. Just set PLLEN bit in the OSCTUN reguster.
 
Color me impressed. 250nS On, 227nS Off. I had to use the toggle function, I couldnt figure out how to write to the ports directly. I'm learning as I go, but I got working code on a PIC32MX250f128b, yay (Im using my Microstick II ) ! It should be running at 40Mhz. I feel that the time should be better, BUT its in 32 Bit numbers!

C:
/*
* File:  Math Test.c
* Author: chris
* Just a simple Math Test
* Created on September 26, 2014, 6:23 AM
*/

// Include Header Files
#include <xc.h>  // will include chip specific header file
#include <plib.h> / include peripheral library functions
#include<p32xxxx.h>

// Configuration Bits
#pragma config FNOSC = FRCPLL
// Internal Fast RC oscillator (8 MHz) w/ PLL
#pragma config FPLLIDIV = DIV_2
// Divide FRC before PLL (now 4 MHz)
#pragma config FPLLMUL = MUL_20
// PLL Multiply (now 80 MHz)
#pragma config FPLLODIV = DIV_2
// Divide After PLL (now 40 MHz)
#pragma config FWDTEN = OFF  // Watchdog Timer Disabled
#pragma config ICESEL = ICS_PGx1  // ICE/ICD Comm Channel Select
#pragma config JTAGEN = OFF  // Disable JTAG
#pragma config FSOSCEN = OFF  // Disable Secondary Oscillator
#pragma config FPBDIV = DIV_1  // PBCLK = SYCLK
// Defines
#define SYS_FREQ      (40000000L)

main() {
   SYSTEMConfig(SYS_FREQ, 0);

   mPORTAClearBits(BIT_0);           //Clear bits to ensure light is off.
   mPORTASetPinsDigitalOut(BIT_0);       //Set port as output

   int i;
   int j;
  int k;


   while(1) {     //

  i = 2048;
  j = 2048;

  mPORTAToggleBits(BIT_0);

  k = i*j;

  mPORTAToggleBits(BIT_0);

     }
   }
 
I managed to find that, its 40Mhz. They are using the Nu32 Board

http://hades.mech.northwestern.edu/index.php/NU32:_What_is_in_the_NU32_Kit

I'd love to get my hands on one. It looks like they are using a 32MX795F512L.

ADD: Ive confirmed my PIC is running at 40Mhz on the clock out pin. My scope can only go to 50Mhz. Ive also figured out how to set a output on or off, and it's actually made the time worse. However, Ive done stupid math and it doesnt slow the PIC down much (ie sin (sqrt x) using floats).

Still, why is it taking so long :/ I feel that its using a software algorithm to do math.

ADD2: After some research I found there Is a built in function to do multiplication "__builtin_muluu(a,b)" but I get an error if I try and use it.
 
Last edited:
So, I have finally come to a conclusion! Lets wrap this up with some thoughts. I went over to the microchip forums and described what it was I was trying to do. They suggested I go back, and use the stop watch in MPLab and count cycles. Now it was running at 48Mhz, doing 32 Bit Math, and it took 5 Cycles. Granted the data sheet says 2 Cycle Multiply, But I consider those extra cycles to be "fluff". All together the main loop took around 30 Cycles, which came out to be 500nS. This Agreed with my readings on my O-Scope. So, by using my Scope, Not only was I measuring the time it took to do math, but the time it took to do the whole Loop. I had managed to get it down to 400nS by moving my declarations out of the main Loop. Still, for 32 Bit 400nS Isnt that Bad, considering that its 32 bit math.

However, A Challenger appears! I have in stock, a PIC18F13k22. Awesome little device, 64Mhz Clock! If you think I'm benchmarking it, you would be correct. The time came in to be 4.240uS, or about half of what the 18F2410 was capable of. Now Mind you, this is doing 16x16 to get 32 Bit's. The PIC32 was doing 32x32 Natively!

Here is the thread over at Microchip for anyone curious
https://www.microchip.com/forums/m823644.aspx?tree=true
 
Status
Not open for further replies.

Latest threads

Back
Top