Two-speed start-up

Post Reply
Bernard Leak
Posts: 18
Joined: Fri Aug 15, 2008 3:42 pm
Location: Armitage, Staffordshire, England

Two-speed start-up

Post by Bernard Leak » Tue Sep 16, 2008 2:35 pm

M. Kerhuel,
we use the PIC mechanism for two-speed start-up, and we would very
much like this to be supported in the block-set. The necessary strange invocations
for the dsPIC33F series follow (taken from the Microchip manual section 70186b.pdf).
I believe it's similar for other PIC variants, but have not checked.

The extra configuration settings (in _FOSC()) are
FCKSM_CSECME Both enabled
FCKSM_CSECMD Only clock switching enabled
FCKSM_CSDCMD Both disabled (default, as the block-set does at present)

Bernard Leak.


Just *after* setting PLLFBD and CLKDIV as at present, the oscillator mode can be
switched over as follows:

;Place the New Oscillator Selection (NOSC=0b101) in W0
MOV #0x15,w0
;OSCCONH (high byte) Unlock Sequence
MOV #OSCCONH, w1
MOV #0x78, w2
MOV #0x9A, w3
MOV.B w2, [w1] ; Write 0x78
MOV.B w3, [w1] ; Write 0x9A
;Set New Oscillator Selection
MOV.B w0, [w1]
; Place 0x01 in W0 for setting clock switch enabled bit
MOV #0x01, w0
;OSCCONL (low byte) Unlock Sequence
MOV #OSCCONL, w1
MOV #0x46, w2
MOV #0x57, w3
MOV.B w2, [w1] ; Write 0x46
MOV.B w3, [w1] ; Write 0x9A
; Enable Clock Switch
MOV.B w0, [w1] ; Request Clock Switching by Setting OSWEN bit
wait:
btsc OSCCONL, #OSWEN
bra wait

LubinKerhuel
Site Admin - Expert
Posts: 616
Joined: Wed Mar 07, 2007 11:23 pm
Location: Bayonne- France
Contact:

Re: Two-speed start-up

Post by LubinKerhuel » Tue Sep 16, 2008 5:29 pm

Dear Bernard,

I am not sure to understand what your need is.
Do you want to manually "change" the clock source within the program (i.e. add a block to do it in the simulink model ?)


Or do you want to use the "Two Speed Start-up" as it is described from the 70186b.pdf doc you mentioned page 7-31 ?
In this last case, my understanding of this page is the following:
The include file of dsPIC33 has the following parameters :

; Two-speed Oscillator Startup :
; IESO_OFF Disabled
; IESO_ON Enabled

The blockset always set the two speed startup to off (IESO_OFF).

If I add an option so as to configure it to (IESO_ON), the two speed startup will be enabled. Thus, the dsPIC will start with the internal FRC clock and when the "user source clock" will be working, it will switch automatically to this source clock.

Is it right? (I did not tested yet the two speed startup ? )
Is this solution what you are asking for?

Lubin

Bernard Leak
Posts: 18
Joined: Fri Aug 15, 2008 3:42 pm
Location: Armitage, Staffordshire, England

Re: Two-speed start-up

Post by Bernard Leak » Wed Sep 17, 2008 6:35 pm

Apologies! The "two-speed start-up" is a complete red herring: I misunderstood what it meant.
This simplifies things. If you give an option in the "Master" block which allows the oscillator
to be changed, that would help. I only want to set the oscillator once, as early as possible,
and I can do that with a block of my own, though it would be kind if you supplied one
yourself.
The reason why I need it is one which I don't fully understand (it depends on the
hardware outside the chip). For some reason, although our external oscillator is fine
(we start up with it), we can't start using the oscillator AND the PLL until later.
At the beginning of main() is not too early! Moreover, we do need to wait until the new
oscillator state is stable before using it. I therefore start with the XT HS oscillator, then
drop briefly to the RFC oscillator, and return to the XT HS oscillator, this time with the PLL.
The easiest way to do this is, as I suggested, to replace the existing PLL and CLKDIV
setting.

Bernard.

LubinKerhuel
Site Admin - Expert
Posts: 616
Joined: Wed Mar 07, 2007 11:23 pm
Location: Bayonne- France
Contact:

Re: Two-speed start-up

Post by LubinKerhuel » Sun Sep 21, 2008 7:01 pm

Hi Bernard,

I did not looked at this problem yet. I'll do it shortly...

Post Reply

Who is online

Users browsing this forum: No registered users and 19 guests