Announcement

Collapse
No announcement yet.

Support for new 18F chips

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • tumbleweed
    replied
    The Q10 is very similar to the K40 except the Q10 is specified to 64MHz over the full voltage range of 1.8V to 5.5V.

    The 26/27/46/47Q10 also have CLC logic cells that aren't in the K40, but I think they're still marked "future product".

    Leave a comment:


  • Charles Leo
    replied
    It's possible in an upcoming version, but not right away. The datasheet has been released and Microchip let me order samples. The data looks like most other PIC18.

    What makes this one more desirable than the 28-pin devices already supported? At first glance, I don't see the feature that would warrant the "Q" in the part number.

    Leave a comment:


  • Athome
    replied
    I have version 3.0.10.4
    Is there a possibility of support for 18F24Q10 chips?

    Leave a comment:


  • Charles Leo
    replied
    PBP 3.1 with K40 support has been released. Sign in to the online store to purchase your upgrade key.

    http://store.melabs.com/cat/PBPUP.html

    Leave a comment:


  • MichelJasmin
    replied
    Originally posted by tumbleweed View Post
    Here's a stab at an updated version of mpgmike's DT-INT for the K40. I added the IPEN fix, changed register accesses to use banksel, and cleaned up the whole K40 device selection code.

    It compiles, but I don't have a K40 to test it on...
    Tested following interrupts:
    • TMR1_INT: OK!
    • RX2_INT: OK!


    Will test some more. Thank you tumbleweed!

    Leave a comment:


  • tumbleweed
    replied
    Originally posted by Ioannis View Post
    I am struggling to make Pickit 3 work with the IPE environment and program the K40 thing...
    If you use the pickit3 with other software you must make sure that the IPE correctly reprograms the PK3.

    Remove any target connections and hit 'Connect'
    If you get a 'Connection failed' message keep hitting 'Connect' until it downloads all three sections.
    For me it takes 4 tries...

    downloading bootloader...
    downloading RS...
    downloading AP...

    Finally you should end up with:
    Target device was not found (could not detect target voltage VDD). You must connect to a target device to use PICkit 3.

    Things should work normally after this.

    Leave a comment:


  • Ioannis
    replied
    I am struggling to make Pickit 3 work with the IPE environment and program the K40 thing...

    I 'll try your fix as soon as I am able to use the Pickit.

    Unfortunately I have also another programmer but is obsolete now (Pikprog+ by Elnec) and does not support new chips. Classic, buy our new shiny programmer...!

    Ioannis

    Leave a comment:


  • tumbleweed
    replied
    Here's a stab at an updated version of mpgmike's DT-INT for the K40. I added the IPEN fix, changed register accesses to use banksel, and cleaned up the whole K40 device selection code.

    It compiles, but I don't have a K40 to test it on...
    Attached Files

    Leave a comment:


  • tumbleweed
    replied
    TMR1_INT works but RX2_INT doesn't. The processor jump somewhere else
    I haven't tried the updated DT-INTs, but the issue could be related to the fact that on the K40 all of the PIR, PIE, and IPR registers aren't located in the access bank anymore... they're in bank 14 so they'd need banksel instructions to access them.

    I don't recall seeing this on other chips.

    Leave a comment:


  • Charles Leo
    replied
    Originally posted by sergio_tx View Post
    Hi Charles,
    Can you please confirm if this version has implemented the WRITE and READ commands for 18F27K40? I´m trying to Write and Read from EEprom without success.
    Thanks,
    Sérgio
    Yes, as far as I know READ and WRITE are working. I tested briefly on the 18F47K40, but that was before I added the NVMCON1.7 workaround. I will test again when I get time.

    Leave a comment:


  • sergio_tx
    replied
    Originally posted by Charles Leo View Post
    I've posted a new beta with the NVMCON1 workaround:
    http://pbp3.com/downloads/PBP3_310_BETA_Setup.exe

    This installation only allows compilation for the new chips that need testing, so you shouldn't replace your existing PBP installation. Rather, install to a separate folder.

    We're still chasing a pesky versioning bug in the new exe file, so this one will still identify as 3.0.9. You'll know it's the beta because the list of available devices will be short.

    This also has fixes for READ/WRITE commands in the 16F183xx series.

    Hi Charles,
    Can you please confirm if this version has implemented the WRITE and READ commands for 18F27K40? I´m trying to Write and Read from EEprom without success.
    Thanks,
    Sérgio

    Leave a comment:


  • MichelJasmin
    replied
    Originally posted by sergio_tx View Post
    I found an error regarding IPEN on DT-INTs posted by mpgmike..
    "OverCREATE
    bsf RCON,IPEN, 0 ; Enable Interrupt Priorities
    bsf INTCON,GIEL, 0 ; Enable Low Priority Interrupts
    endm"
    on PIC18F27k40 IPEN is on INTCON register, not RCON
    Don´t know if it has any kind of influence on your issue...
    Tanks for the tip, I've implemented it on mpgmike's version of DT's interrups. I've worked on it a couple of hours yesterday and it doesn't correct the problem. Will continue today.

    Leave a comment:


  • sergio_tx
    replied
    Originally posted by MichelJasmin View Post
    I'm trying to use some interrupts. TMR1_INT works but RX2_INT doesn't. The processor jump somewhere else. I made sure the USART worked by polling RC2REG. I'm using mpgmike's version of DT's interrupt.

    Any hints?

    Code:
    '****************************************************************
    '*  Name    : UNTITLED.BAS                                      *
    '*  Author  : [select VIEW...EDITOR OPTIONS]                    *
    '*  Notice  : Copyright (c) 2017 [select VIEW...EDITOR OPTIONS] *
    '*          : All Rights Reserved                               *
    '*  Date    : 2017-03-10                                        *
    '*  Version : 1.0                                               *
    '*  Notes   :                                                   *
    '*          :                                                   *
    '****************************************************************
    'PIC18F27K40
    
    #config
      CONFIG RSTOSC = HFINTOSC_64MHZ
      CONFIG WDTE = OFF
    ;  CONFIG PWRT = ON
    ;  CONFIG BOREN = OFF
    ;  CONFIG PBADEN = OFF
      CONFIG MCLRE = EXTMCLR
    ;  CONFIG LVP = OFF
    ;  CONFIG DEBUG = OFF
    ;  CONFIG XINST = OFF
    #endconfig
    
    DEFINE OSC 64
    DEFINE NO_CLRWDT 1  ' Don't waste cycles clearing WDT
    
    Clear   ' Clear RAM before entry
    
    TIMEOUT_1sec    CON 30
    TIMEOUT_500msec con 15
    
    CharBuff2       VAR BYTE
    TmrTick         VAR WORD    '~30 tick/secc
    Timeout         VAR WORD
    
    TempB           VAR BYTE
    TempW           VAR WORD
    PtrB            VAR BYTE
    
    '----[ ALIAS }-------------------------
    
    TMR1IF      var PIR4.0          'TMR1 Overflow Interrupt Flag bit
    TMR1ON      VAR T1CON.0         'TMP1 ON bit
    TMR1IE      var PIE4.0          'TMR1 Overflow Interrupt Enable bit
    TMR1IP      var IPR4.0          'TMR1 Overflow Interrupt Priority bit
    
    RC1IE       var PIE3.5          'EUSART1 Receive Interrupt Enable bit
    RC2IE       var PIE3.7          'EUSART2 Receive Interrupt Enable bit
    
    RC1IP       var IPR3.5          'EUSART1 Receive Interrupt Priority bit
    RC2IP       var IPR3.7          'EUSART2 Receive Interrupt Priority bit
    
    RC1IF       var PIR3.5          'EUSART1 Receive Interrupt Flag bit
    RC2IF       var PIR3.7          'EUSART2 Receive Interrupt Flag bit
    
    
    GIEH        VAR INTCON.7        ' high priority interrupts
    GIEL        VAR INTCON.6        ' low priority interrupts
    IPEN        var INTCON.5        'Interrupt Priority Enable bit
    INTEDG2     var INTCON.2        'External Interrupt 2 Edge Select bit
    INTEDG1     var INTCON.1        'External Interrupt 1 Edge Select bit
    INTEDG0     var INTCON.0        'External Interrupt 0 Edge Select bit
    
    OERR1       var RCSTA1.1    'Overrun Error bit 
    FERR1       var RCSTA1.2    'Framing Error bit
    CREN1       var RCSTA1.4    'Continuous Receive Enable bit
    SPEN1       var RCSTA1.7    'Serial Port Enable bit
    
    OERR2       var RCSTA2.1    'Overrun Error bit 
    FERR2       var RCSTA2.2    'Framing Error bit
    CREN2       var RCSTA2.4    'Continuous Receive Enable bit
    SPEN2       var RCSTA2.7    'Serial Port Enable bit
    
    '----[ Interrups handling ]-------------------------
    
    'INCLUDE  "..\_Include\DT_INTS-18\DT_INTS-18K40.pbp"   ' Base Interrupt System
    INCLUDE  "..\_Include\DT_INTS-18\DT_INTS-18_3_4.pbp"   ' Base Interrupt System
    INCLUDE  "..\_Include\DT_INTS-18\ReEnterPBP-18.bas"   ' Include if using PBP interrupts
    
    
    
    ASM
    INT_LIST  macro    ; IntSource, Label,          Type, ResetFlag?
            INT_Handler  RX2_INT,   _RX2_Handler, PBP,  yes
            INT_Handler  TMR1_INT,   _TmrIntr,   PBP,  yes
            ;INT_Handler  RX1_INT,   _Rx1_Handler, PBP,  yes
        endm
        INT_CREATE               ; Creates the interrupt processor
    ENDASM
    
    goto OverIntHandlers
    
    TmrIntr:
        '~30 tick/sec
        
    '    TMR1ON = 0 ' Stop the Clock
    '    TMR1H = $3C
    '    TMR1L = $B1
    '    TMR1ON = 1 ' Restart the Clock
    
        TmrTick = TmrTick + 1
    
        TMR1IF = 0 ' Reset TMR1's Interupt Flag
    
    @ INT_RETURN
    
    '----[ RX2_Handler ]-------------------------------------------------------
    RX2_Handler:
        
        PORTB.3 = 1    
        
        IF (FERR2 = 1) or (OERR2 = 1) THEN
            ' A framing/overrun error occurred.
            ' Read RCREG to clear the error but don't use the data.
            CREN2 = 0
            CharBuff2 = RC2REG
            CREN2 = 1
    
        ELSE
           ' No framing error occurred. Get caracter.
            CharBuff2 = RC2REG
            
    '        if (CharBuff2 = "$") then
    '            '$ = Start of Transmission
    '            '4 = EOT = End of Transmission
    '            BuffPtrWS = 0
    '        endif
            
    '        BufferWS(BuffPtrWS) = CharBuff2
    
    '        'Cicular buffer
    '        BuffPtrWS = BuffPtrWS + 1
            
    '        if BuffPtrWS >= BFLN_WS_BUF then
    '            BuffPtrWS = 0
    '        endif
            
        ENDIF
    
    @ INT_RETURN
    
    OverIntHandlers:
    
    TmrTick = 0
    Timeout = TIMEOUT_1sec
    
    '----[ A/D ]-------------------------------------------------------
    ANSELA = 0
    ANSELB = 0
    ANSELC = 0
    CCP1CON = 0
    CCP2CON = 0
    ADCON0 = 0
    ADCON1 = 0  'A/D VREF+ connected to internal signal, FVR BUF2
    ADCON2.7 = 1    'A/D Conversion Result Format : Right justified
    
    
    '----[ I/O ]-------------------------------------------------------
    
    TRISB.7 = 1 'RX2
    TRISB.6 = 1 'TX2
    TRISB.3 = 0
    
    '----[ UART 2 = Debug ]-------------------------------------------------------
    Init_UART2:
        RCSTA2 = $90   ' Enable serial port & continuous receive
        TXSTA2 = $24   ' Enable transmit, BRGH = 1
        SPBRG2 = 130   ' 9600 Baud @ 64MHz, -0.02%
        SPBRGH2 = 6
        BAUDCON2.3 = 1 ' Enable 16 bit baudrate generator
    
    
        'Empty EUSART2 input buffers
        CREN2 = 0
        CharBuff2 = RC2REG
        PAUSE 50
        CREN2 = 1
        SPEN2 = 1
        RC2REG = 0
        
        RC2IP = 1       'EUSART2 Receive Interrupt Priority bit : high priority
        RC2IE = 1       'Enable RX2 Interrupts  
    @ INT_ENABLE  RX2_INT  ; Enable RX2 Interrupts  
    
    '----[ Timer1 init ]-------------------------------------------------------
    Timer1_init:
        TMR1CLK = %00000001 'Fosc/4 (p.230)
        T1GCON = 0          'Gate control - Timer1 is always counting (p.229)
        T1CON = %00110100   'Timer0 off, 8bits read, 1:8, freq=30.517 Hz, overflow @ 32.7684 mSec
    
        TMR1H = 0
        TMR1L = 0
        TMR1ON = 1
    
        TMR1IP = 0      ' TMR1IP TMR1 Overflow Interrupt Priority bit : Low priority
        TMR1IE  = 1     ' Enable TMR1 overflow interrupt
        TMR1IF  = 0     ' Clear  TMR1 interrupt flag
       
    @ INT_ENABLE  TMR1_INT    ; enable timer 1 interrupts
    
       
    '----[ Interrupt control ]-------------------------------------------------------
    GIEL = 1     ' Enable peripheral interrupts
    GIEH = 1     ' Enable global interrupts
    
    NVMCON1.7 = 1   'ref.: http://support.melabs.com/threads/1178-Support-for-new-18F-chips?p=3538&viewfull=1#post3538
    
    PORTB.3 = 1
    pause 2000
    PORTB.3 = 0
    
    hserout2 [13,10,13,10, "PIC18F27K40 test serial", 13,10]
    
    main:
    
    	if TmrTick >= Timeout then
            Timeout = TmrTick + TIMEOUT_1sec
            hserout2 ["TmrTick=", dec TmrTick, 13, 10]
            PORTB.3 = 0
    	endif
    
        if CharBuff2 <> 0 then
            hserout2 ["CharBuff2=", CharBuff2, 13, 10]
            CharBuff2 = 0
            Timeout = TmrTick + TIMEOUT_500msec
        endif
        
    
    goto main
    I found an error regarding IPEN on DT-INTs posted by mpgmike..
    "OverCREATE
    bsf RCON,IPEN, 0 ; Enable Interrupt Priorities
    bsf INTCON,GIEL, 0 ; Enable Low Priority Interrupts
    endm"
    on PIC18F27k40 IPEN is on INTCON register, not RCON
    Don´t know if it has any kind of influence on your issue...

    Leave a comment:


  • MichelJasmin
    replied
    I'm trying to use some interrupts. TMR1_INT works but RX2_INT doesn't. The processor jump somewhere else. I made sure the USART worked by polling RC2REG. I'm using mpgmike's version of DT's interrupt.

    Any hints?

    Code:
    '****************************************************************
    '*  Name    : UNTITLED.BAS                                      *
    '*  Author  : [select VIEW...EDITOR OPTIONS]                    *
    '*  Notice  : Copyright (c) 2017 [select VIEW...EDITOR OPTIONS] *
    '*          : All Rights Reserved                               *
    '*  Date    : 2017-03-10                                        *
    '*  Version : 1.0                                               *
    '*  Notes   :                                                   *
    '*          :                                                   *
    '****************************************************************
    'PIC18F27K40
    
    #config
      CONFIG RSTOSC = HFINTOSC_64MHZ
      CONFIG WDTE = OFF
    ;  CONFIG PWRT = ON
    ;  CONFIG BOREN = OFF
    ;  CONFIG PBADEN = OFF
      CONFIG MCLRE = EXTMCLR
    ;  CONFIG LVP = OFF
    ;  CONFIG DEBUG = OFF
    ;  CONFIG XINST = OFF
    #endconfig
    
    DEFINE OSC 64
    DEFINE NO_CLRWDT 1  ' Don't waste cycles clearing WDT
    
    Clear   ' Clear RAM before entry
    
    TIMEOUT_1sec    CON 30
    TIMEOUT_500msec con 15
    
    CharBuff2       VAR BYTE
    TmrTick         VAR WORD    '~30 tick/secc
    Timeout         VAR WORD
    
    TempB           VAR BYTE
    TempW           VAR WORD
    PtrB            VAR BYTE
    
    '----[ ALIAS }-------------------------
    
    TMR1IF      var PIR4.0          'TMR1 Overflow Interrupt Flag bit
    TMR1ON      VAR T1CON.0         'TMP1 ON bit
    TMR1IE      var PIE4.0          'TMR1 Overflow Interrupt Enable bit
    TMR1IP      var IPR4.0          'TMR1 Overflow Interrupt Priority bit
    
    RC1IE       var PIE3.5          'EUSART1 Receive Interrupt Enable bit
    RC2IE       var PIE3.7          'EUSART2 Receive Interrupt Enable bit
    
    RC1IP       var IPR3.5          'EUSART1 Receive Interrupt Priority bit
    RC2IP       var IPR3.7          'EUSART2 Receive Interrupt Priority bit
    
    RC1IF       var PIR3.5          'EUSART1 Receive Interrupt Flag bit
    RC2IF       var PIR3.7          'EUSART2 Receive Interrupt Flag bit
    
    
    GIEH        VAR INTCON.7        ' high priority interrupts
    GIEL        VAR INTCON.6        ' low priority interrupts
    IPEN        var INTCON.5        'Interrupt Priority Enable bit
    INTEDG2     var INTCON.2        'External Interrupt 2 Edge Select bit
    INTEDG1     var INTCON.1        'External Interrupt 1 Edge Select bit
    INTEDG0     var INTCON.0        'External Interrupt 0 Edge Select bit
    
    OERR1       var RCSTA1.1    'Overrun Error bit 
    FERR1       var RCSTA1.2    'Framing Error bit
    CREN1       var RCSTA1.4    'Continuous Receive Enable bit
    SPEN1       var RCSTA1.7    'Serial Port Enable bit
    
    OERR2       var RCSTA2.1    'Overrun Error bit 
    FERR2       var RCSTA2.2    'Framing Error bit
    CREN2       var RCSTA2.4    'Continuous Receive Enable bit
    SPEN2       var RCSTA2.7    'Serial Port Enable bit
    
    '----[ Interrups handling ]-------------------------
    
    'INCLUDE  "..\_Include\DT_INTS-18\DT_INTS-18K40.pbp"   ' Base Interrupt System
    INCLUDE  "..\_Include\DT_INTS-18\DT_INTS-18_3_4.pbp"   ' Base Interrupt System
    INCLUDE  "..\_Include\DT_INTS-18\ReEnterPBP-18.bas"   ' Include if using PBP interrupts
    
    
    
    ASM
    INT_LIST  macro    ; IntSource, Label,          Type, ResetFlag?
            INT_Handler  RX2_INT,   _RX2_Handler, PBP,  yes
            INT_Handler  TMR1_INT,   _TmrIntr,   PBP,  yes
            ;INT_Handler  RX1_INT,   _Rx1_Handler, PBP,  yes
        endm
        INT_CREATE               ; Creates the interrupt processor
    ENDASM
    
    goto OverIntHandlers
    
    TmrIntr:
        '~30 tick/sec
        
    '    TMR1ON = 0 ' Stop the Clock
    '    TMR1H = $3C
    '    TMR1L = $B1
    '    TMR1ON = 1 ' Restart the Clock
    
        TmrTick = TmrTick + 1
    
        TMR1IF = 0 ' Reset TMR1's Interupt Flag
    
    @ INT_RETURN
    
    '----[ RX2_Handler ]-------------------------------------------------------
    RX2_Handler:
        
        PORTB.3 = 1    
        
        IF (FERR2 = 1) or (OERR2 = 1) THEN
            ' A framing/overrun error occurred.
            ' Read RCREG to clear the error but don't use the data.
            CREN2 = 0
            CharBuff2 = RC2REG
            CREN2 = 1
    
        ELSE
           ' No framing error occurred. Get caracter.
            CharBuff2 = RC2REG
            
    '        if (CharBuff2 = "$") then
    '            '$ = Start of Transmission
    '            '4 = EOT = End of Transmission
    '            BuffPtrWS = 0
    '        endif
            
    '        BufferWS(BuffPtrWS) = CharBuff2
    
    '        'Cicular buffer
    '        BuffPtrWS = BuffPtrWS + 1
            
    '        if BuffPtrWS >= BFLN_WS_BUF then
    '            BuffPtrWS = 0
    '        endif
            
        ENDIF
    
    @ INT_RETURN
    
    OverIntHandlers:
    
    TmrTick = 0
    Timeout = TIMEOUT_1sec
    
    '----[ A/D ]-------------------------------------------------------
    ANSELA = 0
    ANSELB = 0
    ANSELC = 0
    CCP1CON = 0
    CCP2CON = 0
    ADCON0 = 0
    ADCON1 = 0  'A/D VREF+ connected to internal signal, FVR BUF2
    ADCON2.7 = 1    'A/D Conversion Result Format : Right justified
    
    
    '----[ I/O ]-------------------------------------------------------
    
    TRISB.7 = 1 'RX2
    TRISB.6 = 1 'TX2
    TRISB.3 = 0
    
    '----[ UART 2 = Debug ]-------------------------------------------------------
    Init_UART2:
        RCSTA2 = $90   ' Enable serial port & continuous receive
        TXSTA2 = $24   ' Enable transmit, BRGH = 1
        SPBRG2 = 130   ' 9600 Baud @ 64MHz, -0.02%
        SPBRGH2 = 6
        BAUDCON2.3 = 1 ' Enable 16 bit baudrate generator
    
    
        'Empty EUSART2 input buffers
        CREN2 = 0
        CharBuff2 = RC2REG
        PAUSE 50
        CREN2 = 1
        SPEN2 = 1
        RC2REG = 0
        
        RC2IP = 1       'EUSART2 Receive Interrupt Priority bit : high priority
        RC2IE = 1       'Enable RX2 Interrupts  
    @ INT_ENABLE  RX2_INT  ; Enable RX2 Interrupts  
    
    '----[ Timer1 init ]-------------------------------------------------------
    Timer1_init:
        TMR1CLK = %00000001 'Fosc/4 (p.230)
        T1GCON = 0          'Gate control - Timer1 is always counting (p.229)
        T1CON = %00110100   'Timer0 off, 8bits read, 1:8, freq=30.517 Hz, overflow @ 32.7684 mSec
    
        TMR1H = 0
        TMR1L = 0
        TMR1ON = 1
    
        TMR1IP = 0      ' TMR1IP TMR1 Overflow Interrupt Priority bit : Low priority
        TMR1IE  = 1     ' Enable TMR1 overflow interrupt
        TMR1IF  = 0     ' Clear  TMR1 interrupt flag
       
    @ INT_ENABLE  TMR1_INT    ; enable timer 1 interrupts
    
       
    '----[ Interrupt control ]-------------------------------------------------------
    GIEL = 1     ' Enable peripheral interrupts
    GIEH = 1     ' Enable global interrupts
    
    NVMCON1.7 = 1   'ref.: http://support.melabs.com/threads/1178-Support-for-new-18F-chips?p=3538&viewfull=1#post3538
    
    PORTB.3 = 1
    pause 2000
    PORTB.3 = 0
    
    hserout2 [13,10,13,10, "PIC18F27K40 test serial", 13,10]
    
    main:
    
    	if TmrTick >= Timeout then
            Timeout = TmrTick + TIMEOUT_1sec
            hserout2 ["TmrTick=", dec TmrTick, 13, 10]
            PORTB.3 = 0
    	endif
    
        if CharBuff2 <> 0 then
            hserout2 ["CharBuff2=", CharBuff2, 13, 10]
            CharBuff2 = 0
            Timeout = TmrTick + TIMEOUT_500msec
        endif
        
    
    goto main

    Leave a comment:


  • sergio_tx
    replied
    meProg

    Hi all,
    I´ve been doing some testing with PIC18F27K40 and i found an issue that may need verification.
    When using internal OSC with config 64MHZ/1:1 and disabling ExtOsc (CONFIG FEXTOSC = OFF), seems that meProg does not assume the disabling of external OSC. I tried to use RA7 (CLKIN) as normal input connected to a key, and was not suceeding. Only after i programmed with PicKit3 it started working as normal Input.
    MeProg also don't show the option "Disabled" on "External Oscillator" configuration options, that´s why i suspect it is not disabling ExtOsc...
    Can you please verify this?
    Thanks,
    Sérgio

    (I´m using latest version of PBP with MPLABX and U2 programmer.)
    Last edited by sergio_tx; 03-08-2017, 04:00 PM.

    Leave a comment:

Working...
X