chipKIT® Development Platform

Inspired by Arduino™

chipKIT Pi (or DP32) vs Uno digitalWrite Frequency

Created Mon, 08 Jun 2015 03:04:08 +0000 by djgardn2


djgardn2

Mon, 08 Jun 2015 03:04:08 +0000

Hello,

If anyone has ever wondered what the max frequency for the chipKIT Pi (or chipKIT DP32) is compared to the Arduino UNO using digitalWrite(), check out the differences below:

[attachment=0]PIC32_vs_UNO_digitalWrite.jpg[/attachment] This was taken using the Analog Discovery™ using WaveForms™.

PIC32 frequency on average is roughly around 403.23 kHz (PIC32MX250F128B). UNO frequency on average is roughly around 128.87 kHz (ATmega328).

The PIC32 has roughly a 3.13 times faster frequency than the UNO using the digitalWrite() function.

This test used the following code segment below for both:

#define pin_Toggle 13

void setup() {
  pinMode(pin_Toggle, OUTPUT);
}

void loop() {
  while(1)
  {
    digitalWrite(pin_Toggle, HIGH);
    digitalWrite(pin_Toggle, LOW);
    digitalWrite(pin_Toggle, HIGH);
    digitalWrite(pin_Toggle, LOW);
    digitalWrite(pin_Toggle, HIGH);
    digitalWrite(pin_Toggle, LOW);
  }
}

EmbeddedMan

Mon, 08 Jun 2015 13:43:46 +0000

I'd so love to see this comparison with a WiFire (200Mhz chipKIT) as well.

*Brian


majenko

Mon, 08 Jun 2015 14:45:02 +0000

Well, I just linked my Wi-Fire to my MAX32, ran that code on the Wi-Fire, and ran my Timer library's FrequencyCounter on the MAX32, and measured it at 574.64kHz.

Not bad... It'd be interesting to know what the AD gives for the same board...

Edit: The real result is probably something completely different - think I have overloaded the MAX32 - my scope says it's nearer 2MHz...

Edit 2: Just tweaked the frequency counter to cope with higher frequencies - it's now telling me about 1.885MHz.


djgardn2

Mon, 08 Jun 2015 23:31:48 +0000

Very nice, on the Wi-FIRE speed, that's pretty fast for sure. Thanks for posting that.

The Wi-FIRE seems like a very promising board with a great concept having the ability of a built in WiFi module. Very interesting board and it has a serious amount of flash (2MB) and SRAM (512kB) too.

Going with the 1.885MHz reading, that would make it around 14.63 times faster frequency than the Uno and 4.67 times faster frequency than the chipKIT Pi/DP32. Nice.


majenko

Wed, 24 Jun 2015 16:23:44 +0000

I can now confirm my readings. I have just bought myself a proper DSO so I can no find the real frequency of the Wi-Fire.

[attachment=1]dso1.jpg[/attachment]

1.89MHz is not bad... I wonder what it would do with LATGINV=1<<6?

[attachment=0]dso2.jpg[/attachment]

Wow ... 20MHz - not bad, but I would have hoped for more from a 200MHz processor... Maybe I can get it faster with assembly?

Hmmm... with this code:

blast:
	li t0, 1&lt;&lt;6
	la t1, LATGINV
reblast:
	j reblast
	sw t0, 0(t1)

... and you can't really get more efficient than that, can you? ... it's still the same 20MHz. Can a jump and a store-word really be taking 5 clock cycles each? According to Wikipedia the store is 4 cycles, and the jump is 3 cycles. That's 7 cycles. So at 200MHz I'd expect ~28.5MHz.

So why isn't it?

My guess is flash wait states. Can anyone comment on that? And if so, how can I get my assembly into RAM to execute (there's a "ramfunc" section isn't there?)