Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ds33FJ256GP710 on Explorer 16 board [solved]
#1
Hi,
i am experimenting with dsLoader on Explorer 16 board.
With 24FJ128GA010 i tried 19200 and 115200 baud rated successfully.
Thanks! I like especially that dsLoader sits in high addresses.

With ds33FJ256GP710 i did changes:
.equ __33FJ256GP710, 1 ;xxx device
; .equ USE_UART1, 1 ;xxx uncomment to use uart1
.equ USE_UART2, 1 ;xxx uncomment to use uart2
dsLoader works fine. BUt my test application with config settings
_FOSCSEL (FNOSC_FRC & // Select Internal FRC at POR
IESO_OFF); // Two-speed Oscillator Startup disabled
_FOSC (FCKSM_CSECMD & // Only clock switching enabled
OSCIOFNC_OFF & // OSC2 is clock O/P
POSCMD_XT); // Primary Oscillator in XT mode
and :
void EnablePLL_XT (void)
{
// Configure PLL prescaler, PLL postscaler, PLL divisor
// Fcy = Fosc/2; Fosc = Fin * (M / (N1 * N2)) = 8MHz * (40 / 4) = 80MHz
PLLPRE = 0; // N1 = 2
PLLFBD = 38; // M = 40
PLLPOST = 0; // N2 = 2
__builtin_write_OSCCONH(0x03); // Initiate Clock Switch to Primary
__builtin_write_OSCCONL(0x01); // Oscillator with PLL (NOSC = 0b011)
while (COSC != 0b011) {}; // Wait for Clock switch to occur
while(LOCK != 1) {}; // Wait for PLL to lock
}

is not working. It worked when loaded directly with Explorer 16 board built-in PICkit2 programmer. Obviously osc config did not suit.

But after i changed dsLoader config bits like this:
config __FOSC, FCKSM_CSECMD & OSCIOFNC_OFF & POSCMD_XT
because i want to use XT_PLL oscillator in my application, now
there is a problem: after loading dsLoader with PICkit2, "Check for BL" found it and first loading of test application is successful (it works also now). But any attempt to reload application fails.
When "Check for BL" -> Searching for bl . .
Found PIC24HJ128GP210A fw ver. 0.13.0
Wrong pic detected(62)/selected(197), aborting
I tried to reduce communication speed to 19200 and increase initial timeout to 10000 with no success.

I think oscillator remains in XT_PLL mode and new runs of dsLoader now are at the wrong speed. I think problem could be solved if dsLoader first checked and disabled XT_PLL.

Dmitri
Reply
#2
Hi,

it seems i fixed the problem. I added this:

;Place the New Oscillator Selection (NOSC=0b111) in W0
MOV #0x17, 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 WREG, OSCCONH
; 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

copy/pasted Code Example for Clock Switching from 07. Oscillator - dsPIC33F FRM.pdf into
; User specific entry code area

Now application with XT_PLL switched on works and Loader works normally.

Dmitri
Reply
#3
Great!

As stated in the manual, you should use the same clock configuration for
both the boot loader and the application.
Reply
#4
For those of you looking to run @ 40 MIPS with an 8 MHz crystal (explorer 16) on a ds33fj256gp710a, I put the following code in the user init area (user_code.inc):

Code:
                     mov  #0x0000,w0        ;CLKDIV=0
                     mov  w0,CLKDIV
                     
                     mov  #0x0026,w0        ;PLLFBD=38
                     mov  w0,PLLFBD

                wait_for_lock:
                    btss OSCCON,#LOCK    ;wait for PLL lock
                    goto wait_for_lock

Also, the fcy needs to be changed to 40000000 in settings.inc.

I hope that helps someone else as it took me forever to find! (I'm not much of an assembly guy...)
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)