FWIW if you want to use your Pickit2, heres a modified PK2DeviceFile which can programme 18F26K22 and a couple of simple apps for manipulating the dat file.
FWIW if you want to use your Pickit2, heres a modified PK2DeviceFile which can programme 18F26K22 and a couple of simple apps for manipulating the dat file.
Last edited by towlerg; - 5th April 2018 at 23:04.
George
Many thanks tumbleweed, it works now !
I can't understand why Microchip make such complex thinks sometimes
"Keep it simple" should be the rule !
George, would your mods for the PicKit2 provide also the debug capability or only programming ?
Best regards
MikeBZH
@Mike. No, just stand alone PK2cmd.exe and Pickit2v2.exe.
For what it's worth the config I use (in Proton but easily transposed)
Code:' internal clock 16MHz with 4xPLL = 64MHz $if _device = _18F26K22 Config_Start FOSC = INTIO67 ; Internal oscillator block PLLCFG = On ; Oscillator multiplied by 4 PRICLKEN = On ; Primary clock enabled FCMEN = OFF ; Fail-Safe Clock Monitor disabled IESO = OFF ; Oscillator Switchover mode disabled PWRTEN = On ; Power up timer enabled BOREN = On ; Brown-out Reset enabled and controlled by software (SBOREN is enabled) BORV = 285 ; VBOR set to 2.85 V nominal WDTEN = OFF ; Watch dog timer is always disabled. SWDTEN has no effect. WDTPS = 32768 ; 1:32768 CCP2MX = PORTC1 ; CCP2 input/output is multiplexed with RC1 PBADEN = OFF ; PORTB<5:0> pins are configured as digital I/O on Reset CCP3MX = PORTB5 ; P3A/CCP3 input/output is multiplexed with RB5 HFOFST = On ; HFINTOSC output and ready status are not delayed by the oscillator stable status T3CMX = PORTC0 ; T3CKI is on RC0 P2BMX = PORTB5 ; P2B is on RB5 MCLRE = INTMCLR ; RE3 input pin enabled; MCLR disabled STVREN = On ; Stack full/underflow will cause Reset LVP = OFF ; Single-Supply ICSP disabled XINST = OFF ; Instruction set extension and Indexed Addressing mode disabled (Legacy mode) Debug = OFF ; Disabled Cp0 = OFF ; Block 0 (000800-003FFFh) not code-protected CP1 = OFF ; Block 1 (004000-007FFFh) not code-protected CP2 = OFF ; Block 2 (008000-00BFFFh) not code-protected CP3 = OFF ; Block 3 (00C000-00FFFFh) not code-protected CPB = OFF ; Boot block (000000-0007FFh) not code-protected CPD = OFF ; Data EEPROM not code-protected WRT0 = OFF ; Block 0 (000800-003FFFh) not write-protected WRT1 = OFF ; Block 1 (004000-007FFFh) not write-protected WRT2 = OFF ; Block 2 (008000-00BFFFh) not write-protected WRT3 = OFF ; Block 3 (00C000-00FFFFh) not write-protected WRTC = OFF ; Configuration registers (300000-3000FFh) not write-protected WRTB = OFF ; Boot Block (000000-0007FFh) not write-protected WRTD = OFF ; Data EEPROM not write-protected EBTR0 = OFF ; Block 0 (000800-003FFFh) not protected from table reads executed in other blocks EBTR1 = OFF ; Block 1 (004000-007FFFh) not protected from table reads executed in other blocks EBTR2 = OFF ; Block 2 (008000-00BFFFh) not protected from table reads executed in other blocks EBTR3 = OFF ; Block 3 (00C000-00FFFFh) not protected from table reads executed in other blocks EBTRB = OFF ; Boot Block (000000-0007FFh) not protected from table reads executed in other blocks Config_End $endif
George
MikeBZH, Here is the config I use for almost all of my 26K22 projects: 64Mhz internal OSC.
#CONFIG
;----- CONFIG1H Options --------------------------------------------------
__config _CONFIG1H, _FOSC_INTIO7_1H & _PLLCFG_ON_1H & _PRICLKEN_ON_1H & _FCMEN_ON_1H & _IESO_OFF_1H
;----- CONFIG2L Options --------------------------------------------------
__config _CONFIG2L, _PWRTEN_ON_2L & _BOREN_ON_2L & _BORV_190_2L
;----- CONFIG2H Options --------------------------------------------------
__config _CONFIG2H, _WDTEN_OFF_2H & _WDTPS_32768_2H
;----- CONFIG3H Options --------------------------------------------------
__config _CONFIG3H, _CCP2MX_PORTB3_3H & _PBADEN_OFF_3H & _HFOFST_OFF_3H & _T3CMX_PORTB5_3H & _MCLRE_EXTMCLR_3H
;----- CONFIG4L Options --------------------------------------------------
__config _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _XINST_OFF_4L & _DEBUG_OFF_4L
#ENDCONFIG
Dave Purola,
N8NTA
EN82fn
If you are really using a crystal then you need FOSC = LP (or the correct setting for a low power crystal with your device.)
Your file is set for a medium power high speed resonator
LP, XT, and HS settings are all for use with crystals.
See section 2.5.3 in the datasheet.
Tumbleweed - You're right - I should have looked it up instead of going by memory.
Thank you Dave,
I need some frequency accuracy. This is why I don't use the internal oscillator but an external xtal and in that case the CONFIG is a little bit different.
But this issue is fixed now.
I am now faced with reading the port A digital inputs. Quite simple question but for an unknown reason it behaves differently than with the 18F2685.
73
MikeBZH (F8DFN)
Both devices have analog functions on portA but the function is selected differently.I am now faced with reading the port A digital inputs
On the 2685 you use the ADCON1 register, while with the 26K22 it's set with the ANSELA register.
Mike, here is the setup for one of my projects:
ANSELA = %00101111 'PORTS A5,A3,A2,A1,A0 ALALOG, A7,A6,A4 DIGITAL
ANSELB = %00100000 'PORTS B7,B6,B4,B3,B2,B1,B0 DIGITAL BUFFERED, B5 ANALOG
ANSELC = %00000000 'PORTS C7,C6,C5,C4,C3,C2,C1,C0 DIGITAL BUFFERED
Hope this helps...
Dave Purola,
N8NTA
EN82fn
Bookmarks