chipKIT® Development Platform

Inspired by Arduino™

MX7ck board running slow

Created Mon, 02 Jun 2014 16:23:08 +0000 by black_manta


black_manta

Mon, 02 Jun 2014 16:23:08 +0000

good afternoon,

I did a quick benchmark of the chipkit MX7ck compared to a pic18 and found that the pic18 was able to toggle pins much faster (my test code just had a while() with a dozen pin_toggles in it).

the pic18 ran about 5x faster than the mx7, and the mx7 was set up for 80mhz operation while the pic18 was set up for direct 20mhz oscillator.

the PLL was set up as follows: #pragma config FNOSC = PRIPLL #pragma config POSCMOD = EC #pragma config FPLLIDIV = DIV_2 #pragma config FPLLMUL = MUL_20 #pragma config FPLLODIV = DIV_1 #pragma config FPBDIV = DIV_8

does the FPBDIV cause my slow pin toggling speed since it's dividing back down to 10mhz? I was under the impression that it was only slowing the busses (I2C, SPI, etc.)

anyone have ideas on why it's slow?


majenko

Mon, 02 Jun 2014 20:03:33 +0000

And how are you programming the MX7cK? #pragma has no effect in MPIDE, plus the digitalWrite() function you use in MPIDE is very heavy weight and quite slow.

Or are you using MPLAB-X? I would expect, using direct register writes, to be able to toggle pins reliably at 20MHz (the slew rate is too slow to toggle faster and get a clean signal).


black_manta

Mon, 02 Jun 2014 20:29:29 +0000

I'm using MPLAB X with the XC32 compiler. programming it with a pickit3

if the PRAGMAs don't work, then how do I set up the PLLs?

I was hoping the chipkit would be faster than my pic18 setup without having to get down in the weeds to make things faster (assembly, direct register writes, etc.).

if MplabX and the chipkit can't easily beat the pic18 speed with 4x higher sysclk then the chipkit is useless to me (since MPLAB X SUUUCCKKs as a development environment)


Jacob Christ

Mon, 02 Jun 2014 21:06:05 +0000

Are you using digitalWrite()? If so its kind of slow. If speed is what you need toggle the registers directly (but this ties your code to PIC32). Also, the setup() / loop() paradigm slows your code as well, you can just put in a main() and get a little more speed by throwing away the chipKIT core overhead().

Some threads that might help:

The first example outputs a 40MHz square wave (but don't expect anything else to work while doing this).

http://chipkit.net/forum/viewtopic.php?p=101#p101

http://chipkit.net/forum/viewtopic.php?p=6008#p6008

http://www.chipkit.net/forum/viewtopic.php?p=11710#p11710

Jacob


black_manta

Mon, 02 Jun 2014 21:56:00 +0000

so, I don't really have a need to toggle a pin at the fastest speed possible. what I wanted was a easier/"better" setup that I had before (pic18 on a solderless breadboard). however, the ChipKit seems to be running 10x slower per sysclk AND the MPLAB X development environment is horrible. so, if I can't figure out why the chipkit is running so sluggish, I'm just going to throw it in the trash.

also, I intentionally had the while(1) so that I could tell how much delay was from the loop itself and how much was the PortSetBits().

do you know how to set up the PLLs? how can I tell if sysclk is at 80mhz? I'm not sure if I'm setting them up right. if I comment out the PRAGMA statements from my previous post, it does get slower still, but I can't really measure the sysclk.


majenko

Mon, 02 Jun 2014 23:11:12 +0000

Is that board using an external clock? By the pictures I'd say yes, and your code is set to that, but the schematic shows crystals everywhere in it and no clock module, so I'm confused.

If it's a clock module, then you can enable the oscillator output pin and measure the clock speed that way.

Top be honest you're probably best off (re?) installing the chipKIT bootloader and using MPIDE (or UECIDE, it's better :P ) than using MPLAB-X and a PK3. MPLAB-X is great for huge projects when you need to do complex things, but for normal usage MPIDE or UECIDE is tonnes better.


black_manta

Tue, 03 Jun 2014 13:49:04 +0000

yeah, the board is using an external 8mhz clock (unless I read the documentation wrong).

good point, I forgot about setting the clock_out. at least I'll know if my PLL is right.

MPIDE does not work on my PC for some reason, and the built-in serial bootloaded's FT232 chip is also having a hard time communicating with the PC (it ties to enumerate as a com port that my PC wont let me access.)

I would prefer MPIDE and bootloader, but neither are an option.