Firewing standard fuses for 24HJ128GP502

General questions about Firewing...

Firewing standard fuses for 24HJ128GP502

Postby Coccoliso » Sat Apr 18, 2015 2:23 pm

Hello,
I want to implement a DIY board that mounts a 24HJ128GP502 programmed via PicKit.
Firewing, via bootloader, charges its fuses .. can you give me an example of this standard configuration for a 80 mhz clock setting?
I looked into the PIC24 bootloader source without positive results.
Thanks.
User avatar
Coccoliso
 
Posts: 177
Joined: Sat Sep 27, 2014 10:02 am

Re: Firewing standard fuses for 24HJ128GP502

Postby Jerry Messina » Sat Apr 18, 2015 7:46 pm

If you're looking for code to set config/change osc settings, perhaps this helps

Code: Select all
device = 24HJ128GP502      ' default FW device
clock = 80

#if (_device = 24HJ128GP502)
config FOSCSEL = {FNOSC_FRCPLL, IESO_OFF}
config FOSC = {FCKSM_CSECMD, OSCIOFNC_OFF, POSCMD_NONE, IOL1WAY_OFF}    // OSC2 output on (pin 10)
config FWDT = {WDTPOST_PS256, WDTPRE_PR128, WINDIS_OFF, FWDTEN_OFF}
config FPOR = {FPWRT_PWR128, ALTI2C_OFF}
#endif

macro SetSysClock()
    const sysClock = _clock

    // Fosc = Fin * (M/N1*N2))
    // CLKDIVbits.FRCDIV = 0    (CLKDIV[10:8]) FRC/1= 7.3728MHz
    // CLKDIVbits.PLLPOST = N2  (CLKDIV[7:6])  N2: 00=2, 01=4, 11=8
    // CLKDIVbits.PLLPRE = N1-2 (CLKDIV[4:0])  N1 = 2-33
    // PLLFBDbits.PLLDIV = M-2
    if (sysClock = 80) then     // 40 MIPS
        const FRCDIV = 0
        const PLLPOST = 0
        const PLLPRE = 1
        const PLLDIV = 63       // 39.94
        WREG4 = (CLKDIV and &HF800) or (FRCDIV<<8) or (PLLPOST<<6) or PLLPRE
        CLKDIV = WREG4
        PLLFBD = PLLDIV               
    elseif (sysClock = 64) then // 32 MIPS                   
        const FRCDIV = 0
        const PLLPOST = 0
        const PLLPRE = 1
        const PLLDIV = 50       // 31.95
        WREG4 = (CLKDIV and &HF800) or (FRCDIV<<8) or (PLLPOST<<6) or PLLPRE
        CLKDIV = WREG4
        PLLFBD = PLLDIV               
    elseif (sysClock = 32) then // 16 MIPS                   
        const FRCDIV = 0
        const PLLPOST = 1
        const PLLPRE = 1
        const PLLDIV = 50       // 15.97
        WREG4 = (CLKDIV and &HF800) or (FRCDIV<<8) or (PLLPOST<<6) or PLLPRE
        CLKDIV = WREG4
        PLLFBD = PLLDIV               
    elseif (sysClock = 16) then // 8 MIPS
        const FRCDIV = 0
        const PLLPOST = 3
        const PLLPRE = 1
        const PLLDIV = 50       // 7.99 
        WREG4 = (CLKDIV and &HF800) or (FRCDIV<<8) or (PLLPOST<<6) or PLLPRE
        CLKDIV = WREG4
        PLLFBD = PLLDIV               
    elseif (sysClock = 8) then  // 4 MIPS
        const FRCDIV = 1        // note: this is outside the VCO range... should use FNOSC_FRC mode
        const PLLPOST = 3
        const PLLPRE = 1
        const PLLDIV = 50 
        WREG4 = (CLKDIV and &HF800) or (FRCDIV<<8) or (PLLPOST<<6) or PLLPRE
        CLKDIV = WREG4
        PLLFBD = PLLDIV               
    else
        checkparam(etError, "unsupported system clock freq")
    end if

    // trim osc for accurate baud (optional)
    'OSCTUN = &H03A

    // wait until the PLL is locked
    while (OSCCON.bits(5) = 0)    // check LOCK bit
    end while
end macro

sub main()
    SetSysClock()
end sub


If that's not what you're after, ask again
Last edited by Jerry Messina on Sat Aug 15, 2015 10:22 am, edited 1 time in total.
Jerry Messina
 
Posts: 280
Joined: Thu Feb 14, 2013 10:16 am

Re: Firewing standard fuses for 24HJ128GP502

Postby Coccoliso » Sun Apr 19, 2015 7:33 am

Yes Jerry,
to start some testing is exactly what I meant ;) .
I will use the same topic if I have other requests.
Thank you.
User avatar
Coccoliso
 
Posts: 177
Joined: Sat Sep 27, 2014 10:02 am


Return to Questions

Who is online

Users browsing this forum: No registered users and 1 guest

cron

x