Page 1 of 1

Programmer for 18FxxQxx parts

Posted: Fri Mar 10, 2023 4:07 pm
by garryp4
I just made a circuit with an 18F14Q41. Before selecting the micro I did verify the Swordfish supported it. What I failed to do was see if my programmer form MELabs supported it, which it does not. Does anyone have any recommendations for one that does? A search did find a PIC KEY Programmer from Forest Electronic Developments for a good price could not find a list of supported micro's.
Thanks

Re: Programmer for 18FxxQxx parts

Posted: Fri Mar 10, 2023 4:47 pm
by garryp4
Or the PICkit4?

Re: Programmer for 18FxxQxx parts

Posted: Fri Mar 10, 2023 4:53 pm
by Jerry Messina
A pickit2 or pickit3 clone along with the pickitminus software would work.
There's also the NSDSP-2-X from Northern Software, which has its own programming utilities.

The Microchip pickit4 or Snap is an option, but those require MPLABX so it's hard to recommend them. The nice thing about those (if you go down that road) is that you can do incircuit debugging too.

MPLABX can be a real pain to work with though, so be prepared.

Re: Programmer for 18FxxQxx parts

Posted: Wed Mar 22, 2023 6:55 pm
by garryp4
Jerry: I purchased the NSDSP-2-X and have gotten as far as a 'hello world" to the terminal. I have been using the MeLabs programmer since I got swordfish a long time ago. The MeLabs software lets me select the state of the configuration fuses and sets them. However the NSDSP-2-X does not do this. So I started poking around and see that the device 'include' files have a section of the configurations. Am I able to set them in my code? For instance, MCLRE(MCLRE) = [EXTMCLR, INTMCLR], is one of the options. How can I change this?

Re: Programmer for 18FxxQxx parts

Posted: Wed Mar 22, 2023 6:55 pm
by garryp4
And I am curious which programmer you prefer?

Re: Programmer for 18FxxQxx parts

Posted: Wed Mar 22, 2023 8:58 pm
by Jerry Messina
For instance, MCLRE(MCLRE) = [EXTMCLR, INTMCLR], is one of the options. How can I change this?
That section in the device include file shows all the possible settings for each of the config registers for that device.

You can add your settings to your main program .bas file. When you compile it'll put the data into your hex file. That's a much better way to do it than relying on the programmer to set them... that way they'll always be there and you don't have to try and remember what you used.

For example, to set the MCLRE add

Code: Select all

device = 18F16Q40

config MCLRE = EXTMCLR
There's a ConfigGenerator utility as part of the IDE plugins (from the IDE select 'Plugin | ConfigGenerator') and it should open.
That'll get you all the settings, along with the correct syntax, which you can copy and paste right into your program file.
See the ConfigGenerator wiki page for more info.

I've used all the ones from Microchip, and although I haven't used the NSDSP-2-X, I've used one of the original ones from NorthernSoftware.
His are much faster than Microchips, and cheaper too. To be honest, I trust his stuff more than the Microchip programmers since these days you have to use MPLABX to get support for the newer devices, and their software is nothing but a constant PITA. Nothing like downloading 3GB of crap just to get (what should be) a simple programmer. I tend to use them though since I do a lot of in-circuit debugging, usually a PICkit3, PICkit4, or ICD3.

If you have trouble with any of the about, just post back. I'm sure we'll get you up and running.

Re: Programmer for 18FxxQxx parts

Posted: Wed Mar 22, 2023 10:27 pm
by garryp4
I did not even know that was a thing. Is there a typo in one of the settings? I included a screen shot that shows the RSTOSC bit in the generator over that line in the data sheet register. The generator says 1mhz... and the data sheet says 64mhz...

Re: Programmer for 18FxxQxx parts

Posted: Wed Mar 22, 2023 11:24 pm
by Jerry Messina
If you open up the listbox (click the down arrow), you should see there are 2 entries for the RSTOSC HFINTOSC selection... 64MHz and 1MHz
Clipboard01.jpg
Clipboard01.jpg (56.85 KiB) Viewed 3742 times
You're showing the FEXTOSC settings, not the RSTOSC settings in the datasheet.
If you're using the intosc then set FEXTOSC OFF

Re: Programmer for 18FxxQxx parts

Posted: Wed Mar 22, 2023 11:56 pm
by garryp4
I don't have the same selections

Re: Programmer for 18FxxQxx parts

Posted: Thu Mar 23, 2023 10:57 am
by Jerry Messina
That's odd. There should be 8 entries in that list box... it looks like the program isn't populating that control correctly (it's a third-party add-on control, and I've seen issues with it before). Of course, it works ok for me.

Just to make sure everything's ok with the asm database file, edit your .bas program and change 'RSTOSC = HFINTOSC_1MHZ' to 'RSTOSC = HFINTOSC_64MHZ' and try to compile it.

See what happens in the ConfigGenerator if you switch to another chip. Any of the xxQxx devices should have those same 8 entries.

Re: Programmer for 18FxxQxx parts

Posted: Thu Mar 23, 2023 11:26 am
by Jerry Messina
I have another idea...

Try and resize the "Setting" column. If you hover the mouse cursor in the top line between "Setting" and just before "Description", you should get a resize control that you can drag to the right and make the "Setting" column larger.

Maybe that'll help it show all 8 entries. If it does, let me know and I'll make that column larger by default.

Re: Programmer for 18FxxQxx parts

Posted: Thu Mar 23, 2023 4:01 pm
by garryp4
Resizing the drop down window did show the 64mhz option. However, this code does not work. I get gibberish to the terminal with the "clock = 64" and the 'include "intocs.bas" commented out:

Code: Select all

Device = 18F14Q41
'Clock = 64

Config
    FEXTOSC = OFF,      // Oscillator not enabled
    RSTOSC = HFINTOSC_64MHZ,// HFINTOSC with HFFRQ = 64 MHz and CDIV = 1:1
    CLKOUTEN = OFF,     // CLKOUT function is disabled
    PR1WAY = ON,        // PRLOCKED bit can be cleared and set only once
    CSWEN = OFF,        // The NOSC and NDIV bits cannot be changed by user software
    FCMEN = ON,         // Fail-Safe Clock Monitor enabled
    FCMENP = OFF,       // Fail-Safe Clock Monitor disabled
    FCMENS = OFF,       // Fail-Safe Clock Monitor Disabled
    MCLRE = EXTMCLR,    // If LVP=0, MCLR pin is MCLR; If LVP=1, RE3 pin function is MCLR
    PWRTS = PWRT_OFF,   // PWRT set at 64ms
    MVECEN = OFF,       // Interrupt contoller does not use vector table to prioritze interrupts
    IVT1WAY = ON,       // IVTLOCKED bit can be cleared and set only once
    LPBOREN = OFF,      // Low-Power BOR disabled
    BOREN = SBORDIS,    // Brown-out Reset enabled , SBOREN bit is ignored
    BORV = VBOR_1P9,    // Brown-out Reset Voltage (VBOR) set to 1.9V
    ZCD = OFF,          // ZCD module is disabled. ZCD can be enabled by setting the ZCDSEN bit of ZCDCON
    PPS1WAY = ON,       // PPSLOCKED bit can be set and cleared repeatedly (subject to the unlock sequence)
    STVREN = ON,        // Stack full/underflow will cause Reset
    LVP = ON,           // Low voltage programming enabled. MCLR/VPP pin function is MCLR. MCLRE configuration bit is ignored
    XINST = OFF,        // Extended Instruction Set and Indexed Addressing Mode disabled
    WDTCPS = WDTCPS_31, // Divider ratio 1:65536; software control of WDTPS
    WDTE = ON,          // WDT enabled regardless of sleep; SWDTEN is ignored
    WDTCWS = WDTCWS_7,  // window always open (100%); software control; keyed access not required
    WDTCCS = SC,        // Software Control
    BBSIZE = BBSIZE_512,// Boot Block size is 512 words
    BBEN = OFF,         // Boot block disabled
    SAFEN = OFF,        // SAF disabled
    DEBUG = OFF,        // Background Debugger disabled
    WRTB = OFF,         // Boot Block not Write protected
    WRTC = OFF,         // Configuration registers not Write protected
    WRTD = OFF,         // Data EEPROM not Write protected
    WRTSAF = OFF,       // SAF not Write Protected
    WRTAPP = OFF,       // Application Block not write protected
    CP = OFF            // PFM and Data EEPROM code protection disabled

#option USART1_TX = PORTB.7            ' 
#option USART1_RX = PORTB.5            '
#option USART2_TX = PORTC.1            ' 
#option USART2_RX = PORTC.2            '

// import modules...
'Include "intosc.bas"
Include "convert.bas"
Include "system.bas"
Include "USART.BAS"
Include "setdigitalio.bas"

  
Private Dim
  red              As PORTC.4,
  green            As PORTC.5,
  e32_m0           As PORTB.6,
  e32_m1           As PORTB.4,
  e32_aux          As PORTC.0,
  prog             As PORTA.4

Private Dim
  Enabled          As ADCON0.Booleans(7),       // ADON, POR = 0 
  Convert          As ADCON0.Booleans(0)        // GO_DONE, POR = 0

'****************************************************************************
Private Sub BLINK_LED()
  High(red)
  DelayMS(100)
  Low(red)
  DelayMS(100)
  High(green)
  DelayMS(100)
  Low(green)
End Sub
'****************************************************************************

SetAllDigital()
SetAnalogPort(ANC3, ANA)               ' Set RC3 to analog mode
SetAnalogPort(ANA2, ANA)               ' Set RA2 to analog mode

Input(e32_aux)
High(e32_m1)
High(e32_m0)
Input(prog)

PPSLOCK.0 = 0
U1RXPPS  = $0D                         ' USART1 RCV = RB5
U2RXPPS  = $11                         ' USART2 RCV = RC1
RB7PPS   = $10                         ' RB7 = USART1 SND
RC2PPS   = $13                         ' RB5 = USART2 SND
PPSLOCK.0 = 1

USART.SetBaudrate(br9600)              ' Baud rate
BLINK_LED

USART.Write("I'M ALIVE!",10,13)
DelayMS(5)

'****************************************************************************
MAIN:
This does work:

Code: Select all

Device = 18F14Q41
Clock = 64

Config
    FEXTOSC = OFF,      // Oscillator not enabled
    RSTOSC = HFINTOSC_64MHZ,// HFINTOSC with HFFRQ = 64 MHz and CDIV = 1:1
    CLKOUTEN = OFF,     // CLKOUT function is disabled
    PR1WAY = ON,        // PRLOCKED bit can be cleared and set only once
    CSWEN = OFF,        // The NOSC and NDIV bits cannot be changed by user software
    FCMEN = ON,         // Fail-Safe Clock Monitor enabled
    FCMENP = OFF,       // Fail-Safe Clock Monitor disabled
    FCMENS = OFF,       // Fail-Safe Clock Monitor Disabled
    MCLRE = EXTMCLR,    // If LVP=0, MCLR pin is MCLR; If LVP=1, RE3 pin function is MCLR
    PWRTS = PWRT_OFF,   // PWRT set at 64ms
    MVECEN = OFF,       // Interrupt contoller does not use vector table to prioritze interrupts
    IVT1WAY = ON,       // IVTLOCKED bit can be cleared and set only once
    LPBOREN = OFF,      // Low-Power BOR disabled
    BOREN = SBORDIS,    // Brown-out Reset enabled , SBOREN bit is ignored
    BORV = VBOR_1P9,    // Brown-out Reset Voltage (VBOR) set to 1.9V
    ZCD = OFF,          // ZCD module is disabled. ZCD can be enabled by setting the ZCDSEN bit of ZCDCON
    PPS1WAY = ON,       // PPSLOCKED bit can be set and cleared repeatedly (subject to the unlock sequence)
    STVREN = ON,        // Stack full/underflow will cause Reset
    LVP = ON,           // Low voltage programming enabled. MCLR/VPP pin function is MCLR. MCLRE configuration bit is ignored
    XINST = OFF,        // Extended Instruction Set and Indexed Addressing Mode disabled
    WDTCPS = WDTCPS_31, // Divider ratio 1:65536; software control of WDTPS
    WDTE = ON,          // WDT enabled regardless of sleep; SWDTEN is ignored
    WDTCWS = WDTCWS_7,  // window always open (100%); software control; keyed access not required
    WDTCCS = SC,        // Software Control
    BBSIZE = BBSIZE_512,// Boot Block size is 512 words
    BBEN = OFF,         // Boot block disabled
    SAFEN = OFF,        // SAF disabled
    DEBUG = OFF,        // Background Debugger disabled
    WRTB = OFF,         // Boot Block not Write protected
    WRTC = OFF,         // Configuration registers not Write protected
    WRTD = OFF,         // Data EEPROM not Write protected
    WRTSAF = OFF,       // SAF not Write Protected
    WRTAPP = OFF,       // Application Block not write protected
    CP = OFF            // PFM and Data EEPROM code protection disabled

#option USART1_TX = PORTB.7            ' 
#option USART1_RX = PORTB.5            '
#option USART2_TX = PORTC.1            ' 
#option USART2_RX = PORTC.2            '

// import modules...
Include "intosc.bas"
Include "convert.bas"
Include "system.bas"
Include "USART.BAS"
Include "setdigitalio.bas"

  
Private Dim
  red              As PORTC.4,
  green            As PORTC.5,
  e32_m0           As PORTB.6,
  e32_m1           As PORTB.4,
  e32_aux          As PORTC.0,
  prog             As PORTA.4

Private Dim
  Enabled          As ADCON0.Booleans(7),       // ADON, POR = 0 
  Convert          As ADCON0.Booleans(0)        // GO_DONE, POR = 0

'****************************************************************************
Private Sub BLINK_LED()
  High(red)
  DelayMS(100)
  Low(red)
  DelayMS(100)
  High(green)
  DelayMS(100)
  Low(green)
End Sub
'****************************************************************************

SetAllDigital()
SetAnalogPort(ANC3, ANA)               ' Set RC3 to analog mode
SetAnalogPort(ANA2, ANA)               ' Set RA2 to analog mode

Input(e32_aux)
High(e32_m1)
High(e32_m0)
Input(prog)

PPSLOCK.0 = 0
U1RXPPS  = $0D                         ' USART1 RCV = RB5
U2RXPPS  = $11                         ' USART2 RCV = RC1
RB7PPS   = $10                         ' RB7 = USART1 SND
RC2PPS   = $13                         ' RB5 = USART2 SND
PPSLOCK.0 = 1

USART.SetBaudrate(br9600)              ' Baud rate
BLINK_LED

USART.Write("I'M ALIVE!",10,13)
DelayMS(5)

'****************************************************************************
MAIN:
It also still works if I comment out the two osc config lines and let the intocs.bas make the settings:

Code: Select all

Config
    'FEXTOSC = OFF,      // Oscillator not enabled
    'RSTOSC = HFINTOSC_64MHZ,// HFINTOSC with HFFRQ = 64 MHz and CDIV = 1:1
I can get it to work and assume that it is working at 64mhz because the "I'm alive" prints fine to the terminal.

Re: Programmer for 18FxxQxx parts

Posted: Thu Mar 23, 2023 5:27 pm
by Jerry Messina
You have to have a "clock =" statement so that the compiler knows what freq you're running at, otherwise it assumes 20MHz.

Intosc.bas will use the "clock=' and do all the setup and config to match. As long as you don't have the config statements after the "include intosc.bas", it can override any config statements for you... if you have multiple config statements for the same function, the last one wins.

If you don't use "intosc.bas" then you have to set everything yourself.