Search in Pinguino World !!

Friday, November 11, 2011

Increase speed on Pinguino32 !!

Default peripheral speed on Pinguino is programmed to 10 Mhz. For some application, we need to increase this speed ( 10 MIPS is less than a Pinguino 8 bits ). To achieve this, we must use the system library which is located in the /p32/include/pinguino/basics folder ).
The peripheral speed is derived from the system clock speed wich is 80 MHZ on Pinguino 32. You can select a peripheral speed with the SetPeripheralClock(divider) function. Divider should be chosen in the predefined value.
PBDIV8 use a 10 Mhz peripheral speed ( default value in Pinguino ).
PBDIV4 -> 20 Mhz
PBDIV2 -> 40 Mhz
PBDIV1 -> 80 Mhz

As an example, we propose this small program:

// increasing peripheral speed on Pinguino32
// Jean-Pierre Mandon 2011

void setup()
{
SetPeripheralClock(PBDIV1);
Serial.begin(9600);
}

void loop()
{
Serial.printf("System clock=%d\n\r",GetSystemClock());
Serial.printf("Peripheral clock=%d\n\r",GetPeripheralClock());
delay(500);
}

SetPeripheralClock must be the first instruction in the setup() because peripheral speed is used to configure Serial, delay and SPI.

Now your Pinguino32 is a real 32 bits/80 MIPS computer !!