English
Language : 

PIC32MX440F256H-80I Datasheet, PDF (534/646 Pages) Microchip Technology – 64/100-Pin General Purpose and USB 32-Bit Flash Microcontrollers
PIC32MX3XX/4XX
23.6.1 DYNAMIC PERIPHERAL BUS
SCALING METHOD
The PBCLK can be scaled dynamically, by software, to
save additional power when the device is in a low activ-
ity mode. The following issues need to be taken into
account when scaling the PBCLK:
• All the peripherals clocked from PBCLK will scale
at the same ratio, at the same time. This needs to
be accounted in peripherals which need to main-
tain a constant baud rate, or pulse period even in
low-power modes.
• Any communication through a peripheral on the
peripheral bus that is in progress when the
PBCLK changes may cause a data or protocol
error due to a frequency change during
transmission or reception.
The following steps are recommended if the user
intends to scale the PBCLK divisor dynamically:
• Disable all communication peripherals whose
baud rate will be affected. Care should be taken to
ensure that no communication is currently in prog-
ress before disabling the peripherals as it may
result in protocol errors.
• Update the Baud Rate Generator (BRG) settings
for peripherals as required for operation at the
new PBCLK frequency.
• Change the peripheral bus ratio to the desired
value.
• Enable all communication peripherals whose
baud rate were affected.
Note:
Modifying the peripheral baud rate is done
by writing to the associated peripheral
SFRs. To minimize latency, the peripher-
als should be modified in the mode where
the PBCLK is running at its highest
frequency.
EXAMPLE 23-2: CHANGING THE PB CLOCK DIVISOR
// Code example to change the PBCLK divisor
// This example is for a device running at 20 MHz
// Make sure that there is no UART send/receive in progress
... user code ...
U1BRG = 0x81;
// set baud rate for UART1 for 9600
... user code ...
SYSKEY = 0x0;
SYSKEY = 0xAA996655;
SYSKEY = 0x556699AA;
OSCCONCLR = 0x3 << 19;
SYSKEY = 0x0;
// write invalid key to force lock
// Write Key1 to SYSKEY
// Write Key2 to SYSKEY
// set PB divisor to minimum (1:1)
// write invalid key to force lock
... user code ...
// Change Peripheral Clock value
U1BRG = 0x0F;
// set baud rate for UART1 for 9600 based on
// new PB clock frequency
SYSKEY = 0x0;
// write invalid key to force lock
SYSKEY = 0xAA996655;
// Write Key1 to SYSKEY
SYSKEY = 0x556699AA;
// Write Key2 to SYSKEY
OSCCONSET = 0x3 << 19; // set PB divisor to maximum (1:8)
SYSKEY = 0x0;
// write invalid key to force lock
// Reset Peripheral Clock
OSCCONCLR = 0x3 << 19; // set PB divisor to minimum (1:1)
U1BRG = 0x81;
// restore baud rate for UART1 to 9600 based
// on new PB clock frequency
DS61143E-page 532
Preliminary
© 2008 Microchip Technology Inc.