Microchip Technology DM300023 Scheda Tecnica

Pagina di 18
© 2008 Microchip Technology Inc.
DS80319D-page 11
dsPIC30F1010/202X
32. Module: MCLR Pin
A brown-out event occurs when V
DD
 drops below
the minimum operating voltage for the device but
not all the way down to V
SS
. When the dsPIC DSC
SMPS device is running with the PLL enabled and
a brown-out event occurs, the device may stop
running and the MCLR pin will not reset the device.
If this occurs, the device can only be reset by
cycling power to the V
DD
 pins.
It is recommended that an external Brown-out
Reset (BOR) circuit be used to hold the device in
reset during a brown-out event, to overcome this
problem. The external BOR circuit will use the
MCLR pin to hold the device in reset. The following
work around, in combination with the external BOR
circuit, will ensure that the device is cleanly reset
after a brown-out event occurs. 
Work around
The dsPIC DSC SMPS device must be powered
up with the PLL disabled, the Fail-Safe Clock
Monitor enabled and Clock Switching enabled.
The PLL should be enabled in software via a clock
switch after the device is reset (refer to Section
29. “Oscillator”
 in the “dsPIC30F Family
Reference Manual
” (DS70268) for details on clock
switching). This ensures that the MCLR pin is
functional and that the device can be reset by an
external BOR circuit (see Figure 1).
FIGURE 1:
Use one of the following methods to achieve the
work around.
Method 1: Insert the code shown in Example 1 at
the start of the program.
Method 2: Call the code shown in Example 1 in
the beginning of code execution by including the
ClockSwitch.s
 file in the project and adding the
following code:
• For assembly programming, add the following 
instruction at the beginning of the program:
.global __reset
__reset:
rcall ClockSwitch
• For C programming, add the following 
instruction at the beginning of the program:
int main(void)
{
ClockSwitch;
}
EXAMPLE 1:
CLOCK SWITCHING EXAMPLE
V
SS
MCLR
+5V
+5V
External
BOR
Circuit
R*
U2*
*Any commercially available BOR circuit
can be used in this configuration. Refer to
the BOR circuit manufacturer’s data sheet
for exact circuit configuration.
d
s
P
IC
3
0F
10
1
0
/2
02
X
U1
; This function performs a clock-switch from FRC to FRC+PLL. All other oscillator 
; settings remain unchanged.
; Filename: ClockSwitch.s
_ClockSwitch:
    mov    #OSCCON+1,w4   ; Get address of high OSCCON byte
    mov    #0x0078, w0    ; 1st password for high byte access to OSCCON
    mov    #0x009A, w1    ; 2nd password for low byte access to OSCCON
    mov    #0x0001, w2    ; NOSC value for FRC+PLL
    mov.b  w0, [w4]       ; Write 1st password
    mov.b  w1, [w4]       ; Write 2nd password
    mov.b  w2, [w4]       ; Write NOSC value
    mov    #OSCCON,w4     ; Get address of low OSCCON byte
    mov    #0x0046, w0    ; 1st password for high byte access to OSCCON
    mov    #0x0057, w1    ; 2nd password for low byte access to OSCCON
    mov    #0x0001, w2    ; Set OSWEN bit
    mov.b  w0, [w4]       ; Write 1st password
    mov.b  w1, [w4]       ; Write 2nd password
    mov.b  w2, [w4]       ; Write OSWEN bit
    return