Programme with pickit 3

Discuss the Firewing development environment

Programme with pickit 3

Postby AndrewB » Tue Mar 08, 2016 6:28 pm

I have just tried to program a clean pic24 using the Hex file generated but the display does not work.
Its responding to buttons.

Is there anything I have to do to the main program prior?

I am using a pickit3
AndrewB
 
Posts: 94
Joined: Thu Jan 02, 2014 3:38 pm

Re: Programme with pickit 3

Postby David John Barker » Tue Mar 08, 2016 7:51 pm

If your program works when bootloaded, but fails to work when you build the *.hex file yourself and then program, then it's your fuse settings. Easier way is to match the fuse settings in the loader

http://www.firewing.info/pmwiki.php?n=Firewing.Firewing24#Firmware
User avatar
David John Barker
 
Posts: 491
Joined: Thu Nov 08, 2012 12:21 pm

Re: Programme with pickit 3

Postby Jerry Messina » Tue Mar 08, 2016 8:55 pm

Here are the settings from the loader...
Code: Select all
// 24HJ128GP502 default fuse settings from the pic24 firewingLoader.s file
config  FBS = {BWRP_WRPROTECT_OFF}
config  FSS = {SWRP_WRPROTECT_OFF}
config  FGS = {GWRP_OFF}
config  FOSCSEL = {FNOSC_FRCPLL, IESO_OFF}
config  FOSC = {POSCMD_NONE, OSCIOFNC_ON, IOL1WAY_OFF, FCKSM_CSECMD}
config  FWDT = {WDTPOST_PS256, WINDIS_OFF, FWDTEN_OFF}
config  FPOR = {FPWRT_PWR128, ALTI2C_OFF}
config  FICD = {ICS_PGD1, JTAGEN_OFF}
Jerry Messina
 
Posts: 280
Joined: Thu Feb 14, 2013 10:16 am

Re: Programme with pickit 3

Postby AndrewB » Wed Mar 09, 2016 6:06 pm

Where do I place this? At the beginning of the firewing code or somewhere in MLAB?
AndrewB
 
Posts: 94
Joined: Thu Jan 02, 2014 3:38 pm

Re: Programme with pickit 3

Postby Jerry Messina » Wed Mar 09, 2016 7:42 pm

Put them in your main firewing module.

The last config statements seen override any previous ones, so if you put it after all the "imports" they'll be the ones that are in effect...
Code: Select all
imports mplabicd

' these config statements override any previous ones
// 24HJ128GP502 default fuse settings from the pic24 FW bootloader
config  FBS = {BWRP_WRPROTECT_OFF}
config  FSS = {SWRP_WRPROTECT_OFF}
config  FGS = {GWRP_OFF}
config  FOSCSEL = {FNOSC_FRCPLL, IESO_OFF}
config  FOSC = {POSCMD_NONE, OSCIOFNC_ON, IOL1WAY_OFF, FCKSM_CSECMD}
config  FWDT = {WDTPOST_PS256, WINDIS_OFF, FWDTEN_OFF}
config  FPOR = {FPWRT_PWR128, ALTI2C_OFF}
config  FICD = {ICS_PGD1, JTAGEN_OFF}

Sub Main()

End Sub
Jerry Messina
 
Posts: 280
Joined: Thu Feb 14, 2013 10:16 am

Re: Programme with pickit 3

Postby AndrewB » Wed Mar 09, 2016 7:44 pm

Thanks
AndrewB
 
Posts: 94
Joined: Thu Jan 02, 2014 3:38 pm

Re: Programme with pickit 3

Postby Coccoliso » Wed Mar 09, 2016 7:59 pm

Hi Jerry
should not also set the oscillator with the macro ? (which in any case it is the one that you gave me ;) )
Must be called as the first line in main sub.

Code: Select all
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 = 2-N1 (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
User avatar
Coccoliso
 
Posts: 177
Joined: Sat Sep 27, 2014 10:02 am

Re: Programme with pickit 3

Postby AndrewB » Wed Mar 09, 2016 8:03 pm

Thanks Coccoliso

So this goes before and the other switches after?

Would be nice to have a confirmed info on this.

if I want read protect what do i do?
AndrewB
 
Posts: 94
Joined: Thu Jan 02, 2014 3:38 pm

Re: Programme with pickit 3

Postby Jerry Messina » Wed Mar 09, 2016 9:57 pm

By default, Firewing will set up the clock for you, so you may not need that macro.

Here are two threads that talk about using the pickit and no bootloader...

viewtopic.php?f=12&t=216
viewtopic.php?f=12&t=238


To change the protection you'd change the General Segment config setting
Code: Select all
config  FGS = {GWRP_OFF}     // no protection

There are a number of different types/levels... you'd probably be ok with GSS_STD. See http://ww1.microchip.com/downloads/en/D ... 70239B.pdf
Jerry Messina
 
Posts: 280
Joined: Thu Feb 14, 2013 10:16 am

Re: Programme with pickit 3

Postby AndrewB » Wed Mar 09, 2016 10:17 pm

Thanks Jerry.

I will read up and test above.

thanks all for the help.
AndrewB
 
Posts: 94
Joined: Thu Jan 02, 2014 3:38 pm


Return to Development Environment

Who is online

Users browsing this forum: No registered users and 1 guest

cron

x