Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
io speed
24-08-2012, 06:42 PM,
Question  io speed

I'm new on Pinguino (USB OTG,PIC32MX440f256h,8mhz crystal), please forgive me:
I tried to increase the IO-speed to 80Mhz with the Pinguino-functions System.setCpuFrequency & System.setPeripheralFrequency.
getPeripheralFrequency shows me 80mhz. (by default peripheralfrequency should be 40mhz).
I simply toggled RD2 (Pinguino: D0) with LATCHDINV=0x100 (much faster as digitalWrite or PORTD^=0x100Wink.
But after all the measured frequency is only 4.75 Mhz. Huh
Any suggestions?


24-08-2012, 09:35 PM, (This post was last modified: 24-08-2012, 09:35 PM by pingotg.)
RE: io speed
Please provide at least the few lines of code doing the toggling.

If you used a loop of any kind then there's the answer.

25-08-2012, 12:33 PM,
RE: io speed
thanx for reply,

i tried it in the loop()-->4.75Mhz.
When I do

for (i=80000000;i>0;i--)
PORTDINV=0b0000000000000100; (this must reach not less than 10Mhz) 7.5 Mhz but ugly waveform 1V to 3.3V
also tried for(i=1000000000;i>0;i--) //100times// LATDINV=0b0000000000000100; same as above, but 10 Mhz

Here the code:

#include <p32xxxx.h>
#include <proc/p32mx440f256h.h>

int i;
void setup() {

void loop() {
for (i=80000000;i>0;i--)
25-08-2012, 03:45 PM, (This post was last modified: 25-08-2012, 04:26 PM by pingotg.)
RE: io speed
If the comment about 100 times means you put 100 of them ("loop unrolling") and it still wasn't fast then the next thing I'd do would be to look at the generated code.

(I tend always to use -save-temps which is good enough for me.)

If that still does not explain it, next might be to run the loop from on-chip RAM as I'm not sure how fast the flash is (see datasheet LOL).

Beyond that, maybe the speed you set is not the speed you intended (wrong argument, locked from changes - the bootloader will already set some value or other - or something).

edit: another couple of thoughts: how many bytes make up each instruction (they all need fetching, decoding executing etc) and how many clocks is the instruction supposed to take (may well not be 1)

25-08-2012, 06:57 PM,
RE: io speed
solved: The Olimex Pinguino OTG & Pinguino IDE X.3 Rev399 runs peripheral at 40Mhz, setPeripheralFrequency() doesn't work.
Frequencies above 10Mhz must be Schmitt-triggered.
edit: 1 ClockCycle = 1 InstructionCycle, the atomic instructions need just a single.
Flash is fast enough I think, but a few pic32mxxxx have also a prefetch-cache. btw how to execute code directly from RAM?

thx from Germany,


Forum Jump:

Users browsing this thread: 1 Guest(s)