chipKIT® Development Platform

Inspired by Arduino™

mpide VS mplab speedtest

Created Thu, 21 Feb 2013 19:17:46 +0000 by rygelxvi


rygelxvi

Thu, 21 Feb 2013 19:17:46 +0000

Hi all,

Made a quick test today to see the difference between the two environments listed in subject.

HW: CHIPKIT max32

Debugger/Programmer: PICKIT3

Compiler: MPLAB® XC Compiler

Test Code:

#include <stdio.h>
#include <plib.h>

// External Oscillator uses base 8MHz oscillator
#pragma config FPLLIDIV = DIV_2         // PLL Input Divider (4x Divider) Using 8MHz/2 = 4MHz
#pragma config FPLLMUL = MUL_20         // PLL Multiplier (20x Multiplier) 4MHz * 20 = 80Mhz
#pragma config UPLLIDIV = DIV_1         // USB PLL Input Divider (5x Divider) (USB module must have an input of 4MHz to multiply by 24 (96) and divide by 2 to get 48MHz for FS)
#pragma config UPLLEN = ON              // USB PLL Enable (Disabled and Bypassed)
#pragma config FPLLODIV = DIV_1         // System PLL Output Clock Divider (PLL Divide by 1) => 80Mhz/1 => 80MHz
#pragma config FNOSC = PRIPLL           // Oscillator Selection Bits (Primary Osc w/PLL (XT+,HS+,EC+PLL))
#pragma config FSOSCEN = OFF            // Secondary Oscillator Enable (Disabled)
#pragma config IESO = OFF               // Internal/External Switch Over (Disabled)
#pragma config POSCMOD = HS             // Primary Oscillator Configuration (HS osc mode)
#pragma config OSCIOFNC = OFF           // CLKO Output Signal Active on the OSCO Pin (Disabled)
#pragma config FPBDIV = DIV_1           // Peripheral Clock Divisor (Pb_Clk is Sys_Clk/1)
#pragma config FCKSM = CSDCMD           // Clock Switching and Monitor Selection (Clock Switch Disable, FSCM Disabled)
#pragma config WDTPS = PS1              // Watchdog Timer Postscaler (1:1)
#pragma config FWDTEN = OFF              // Watchdog Timer Enable (WDT Enabled)

int main()
{
  TRISA = 0;      // all PORTA as output
  while(1)
  {
    PORTA = BIT_7;
    PORTA = 0;
  }
}

Compile Info (for MPLAB case):

Release build of project `C:\testing\test.mcp' started.
Language tool versions: xc32-as.exe v1.20, xc32-gcc.exe v1.20, xc32-ld.exe v1.20, xc32-ar.exe v1.20
Thu Feb 21 20:25:25 2013
----------------------------------------------------------------------
Clean: Deleting intermediary and output files.
Clean: Deleted file "C:\testing\test.o".
Clean: Deleted file "C:\testing\test.elf".
Clean: Deleted file "C:\testing\test.hex".
Clean: Done.
Executing: "C:\Program Files (x86)\Microchip\xc32\v1.20\bin\xc32-gcc.exe" -mprocessor=32MX795F512L -x c -c "test.c" -o"test.o" -MMD -MF"test.d"  -g -O3 -funroll-loops -fomit-frame-pointer
Executing: "C:\Program Files (x86)\Microchip\xc32\v1.20\bin\xc32-gcc.exe" -mprocessor=32MX795F512L "test.o" -o"test.elf" -O3 -Wl,-L"C:\Program Files (x86)\Microchip\xc32\v1.20\pic32mx\lib",--defsym=__MPLAB_BUILD=1,-Map="test.map"
Executing: "C:\Program Files (x86)\Microchip\xc32\v1.20\bin\xc32-bin2hex.exe" "C:\testing\test.elf"
Loaded C:\testing\test.elf.
----------------------------------------------------------------------
Release build of project `C:\testing\test.mcp' succeeded.
Language tool versions: xc32-as.exe v1.20, xc32-gcc.exe v1.20, xc32-ld.exe v1.20, xc32-ar.exe v1.20
Thu Feb 21 20:25:26 2013
----------------------------------------------------------------------
BUILD SUCCEEDED

When I use MPLAB (or MPLABX), XC compiler and PICKIT3: [attachment=1]mplab_pickit3.jpg[/attachment]

When I use MPIDE, XC compiler and avrdude (modified) I get this output: [attachment=0]mpide_avrdude.jpg[/attachment] (yes, it is possible to program max32 board using avrdude)

So everything is the same in the both cases except for the link script and boot loader (according to me), where in the MPIDE case I use the script found here: c:\Program Files\mpide-0023-windows-20120903\mpide-0023-windows-20120903\hardware\pic32\cores\pic32\chipKIT-MAX32-application-32MX795F512L.ld

However, as you can see, the time it takes to toggle one pin is very different.

Any thoughts on this anyone?


Jacob Christ

Fri, 22 Feb 2013 07:40:07 +0000

We did a similar test just the other day and your getting much better results than we did. I suspect its the while loop in your code where we just used the loop().

Jacob


majenko

Fri, 22 Feb 2013 10:23:31 +0000

loop() adds the overhead of a repeated call to the loop() function, plus the _scheduleTask() function, so yes you can expect a while() inside loop() (or main()) to be somewhat faster.


rygelxvi

Fri, 22 Feb 2013 17:57:00 +0000

In the MPLAB environment, after looking into the asm code it looks like the -O3 option (optimize level 3) is not suited to handle the while loop in my test code. -O3 XC compiler argument will make the code inside the loop to execute twice and then it runs a NOP instruction and then starts at the beginning of loop again.

In the MPIDE environment I think the timing is somewhat ok but curve look ugly and do not know if I can use that signal to anything useful.

Also, for 80Mhz I think toggling a pin at maximum 13Mhz with full optimization is not very exciting.

One question that comes to mind is why these curves looks so different, when the only things that is changed between the two graphs are link-script and "boot loader".


rygelxvi

Thu, 04 Apr 2013 16:27:06 +0000

Just to update... I seem to get same behavior with this config:

#pragma config FPLLMUL = MUL_20, FPLLIDIV = DIV_2, FPLLODIV = DIV_1, FWDTEN = OFF
#pragma config POSCMOD = HS, FNOSC = PRIPLL, FPBDIV = DIV_1

#define SYS_FREQ               (80000000L)

int main()
{
    SYSTEMConfig(SYS_FREQ, SYS_CFG_WAIT_STATES | SYS_CFG_PCACHE);
   while(true)
    {
        PORTA = 0xFF;
        PORTA = 0x00;
    }
}

"C:\Program Files (x86)\Microchip\xc32\v1.20\bin\xc32-gcc.exe" -g -x c -c -mprocessor=32MX795F512L -O3 -funroll-loops -fomit-frame-pointer -MMD -MF build/default/production/vga.o.d -o build/default/production/vga.o vga.c "C:\Program Files (x86)\Microchip\xc32\v1.20\bin\xc32-gcc.exe" -mprocessor=32MX795F512L -O3 -o dist/default/production/sony_disp.X.production.elf build/default/production/vga.o -Wl,--defsym=__MPLAB_BUILD=1