Pic 18F26K40


Closed Thread
Results 1 to 18 of 18

Thread: Pic 18F26K40

  1. #1
    Join Date
    Jun 2016
    Posts
    60

    Default Pic 18F26K40

    I have in mind a new project where I need two uarts com ports, so I did search microchip site and found the pic 18F26k40 to suite my need. As a second step I did check if my pbp3 (ver 3.09.4) was supporting this device and I discover that it doesn't! The closest one is 18F26K80 (wich is obsolete) while my melabs U2 programmer (ver 4.4) does list only 18F26K20.

    How can I add this new device to my compiler and programmer?

    Any help will be greatly appreciate.

    Alberto

  2. #2
    Join Date
    Apr 2014
    Location
    OK
    Posts
    557


    Did you find this post helpful? Yes | No

    Default Re: Pic 18F26K40

    The easy fix is to spend the $50 and upgrade to PBP3.1. You must use Windows 7 or newer, can't use XP with 3.1.

  3. #3
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,795


    Did you find this post helpful? Yes | No

    Default Re: Pic 18F26K40

    Well, my 3.1.1.4 has support (maybe limited) for the K40 series.

    Why not update your older version? If there is any cost I think is not too much.

    Ioannis

  4. #4
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: Pic 18F26K40

    I would like to ask, Why the 26K40? I would personally use an 18F26K22. It has been supported since PBP 3.0 I believe and it's still in production.
    Dave Purola,
    N8NTA
    EN82fn

  5. #5
    Join Date
    Jun 2016
    Posts
    60


    Did you find this post helpful? Yes | No

    Default Re: Pic 18F26K40

    Thank all for the quick reply! I will check @ melabs site how to update my pbp3. You didn't mention the U2 programmer. Does it upgrade automatically with the pbp3 upgrade?

    @ Dave:

    I did Selected the pic 18K family @ microchip site and the list obtained doesn't show the device you suggested (pic 18f26k22)

    Alberto

  6. #6
    Join Date
    Aug 2011
    Posts
    408


    Did you find this post helpful? Yes | No

    Default Re: Pic 18F26K40

    The closest one is 18F26K80 (wich is obsolete)
    No it's not. It's still in production.

    The 18F2xK22 is your best bet. Many of the search tools on the mchip site are broken, or they default to showing you "new and popular products". The 18F2xK22 is one of the most popular in the whole K family but it doesn't show up until you "show all".

  7. #7


    Did you find this post helpful? Yes | No

    Default Re: Pic 18F26K40

    Of all the oddities on microchips site one of the more annoying is that seach which only seems to work if you put PIC (like PIC18F26K22), maybe it's just my browser/VPN combo.
    George

  8. #8
    Join Date
    Apr 2014
    Location
    OK
    Posts
    557


    Did you find this post helpful? Yes | No

    Default Re: Pic 18F26K40

    Quote Originally Posted by Alberto View Post
    You didn't mention the U2 programmer. Does it upgrade automatically with the pbp3 upgrade?
    Alberto
    Yes. You must download it separately, though

  9. #9
    Join Date
    Jun 2016
    Posts
    60


    Did you find this post helpful? Yes | No

    Default Re: Pic 18F26K40

    Thank you for pointing out that 18f26k22 is still in production! This will save me the money and trouble to update my pbp3 ( you never know how it will end up the update!). Additionally, the suggeted device has got more memory and is cheaper!

    Yes the searching tools at microchip site are very poor indeed. Searching for the single product I found the 18f26k22 as currently in production!

    I have placed the order for 10 units and hopefully will arrive to my place in two weeks. Then I will return here for some more help, since I never used two uarts on the same device, and I don't know how to set DT interrupt for the second uart.

    So if somebody has a code snippet that shows how to set DT interrupt for the second uart and is willing to post it, I will appreciate it very much!

    Soo far so good, thank you to all.

    Alberto

    Alberto
    Last edited by Alberto; - 9th April 2018 at 16:54.

  10. #10
    Join Date
    Aug 2011
    Posts
    408


    Did you find this post helpful? Yes | No

    Default Re: Pic 18F26K40

    One thing to watch out for... on the 2xK22 the second uart TX/RX share pins with the ICSP on RB6 and RB7.

    On the 4xK22 they're on PORTD, so no conflict there. Just something to be aware of.

  11. #11
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: Pic 18F26K40

    I have tried using the 18F27K40 because of the extra memory and they work just fine BUT, There is no longer any boot loader support from Mecanique and I have NOT found any from sources like TinyLoader. Therefor I have stuck with the 18F26K22 and the 18F46K22 as well as the 18F67K22 processors.
    Dave Purola,
    N8NTA
    EN82fn

  12. #12
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,795


    Did you find this post helpful? Yes | No

    Default Re: Pic 18F26K40

    Why don't you use the ICSP for programming? That is if you have a programmer capable for that chip?

    It is much faster than a bootloader.

    Ioannis

  13. #13
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,517


    Did you find this post helpful? Yes | No

    Default Re: Pic 18F26K40

    Hmm... My experience is the complete opposite. Using a bootloader is generally much faster than using ISCP (with a PK3 at least) - especially when loading small programs into chips with a lot of flash.

    /Henrik.

  14. #14
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,795


    Did you find this post helpful? Yes | No

    Default Re: Pic 18F26K40

    Interesting Henrik. No matter the chip selected?

    Ioannis

  15. #15
    Join Date
    Apr 2014
    Location
    OK
    Posts
    557


    Did you find this post helpful? Yes | No

    Default Re: Pic 18F26K40

    Quote Originally Posted by Alberto View Post
    So if somebody has a code snippet that shows how to set DT interrupt for the second uart and is willing to post it, I will appreciate it very much!
    Alberto
    Code:
    DEFINE      OSC             32
    DEFINE      HSER1_RCSTA     90h             ;OBD
    DEFINE      HSER1_TXSTA     24h
    DEFINE      HSER1_BAUD      57600
    DEFINE      HSER1_CLROERR   1
    DEFINE      HSER2_RCSTA     90h             ;Master
    DEFINE      HSER2_TXSTA     24h
    DEFINE      HSER2_BAUD      57600
    DEFINE      HSER2_CLROERR   1
    
    INCLUDE "DT_INTS-18.pbp"
    INCLUDE "ReEnterPBP-18.bas"
    
    ;Interrupt Processor:
    ASM
    INT_LIST  macro    ; IntSource,  Label,         Type, ResetFlag? 
            INT_Handler   INT1_INT,  _OK,           PBP,  yes   ;USART2 (Main) CS
            INT_Handler   RX1_INT,   _Grab_ELM,     PBP,  yes   ;USART1 (ELM) Transmission Received
            INT_Handler   RX2_INT,   _Grab_Main,    PBP,  yes   ;USART2 (MAIN) Transmission Received
        endm
        INT_CREATE                      ;Creates the interrupt processor
    ENDASM
    
    ; -=- *** USART SFRs *** -----------------------------------------------------------------------------------------------
    TXSTA1      =    %00100100          ;24h, Yields 57,600 Baud, ELM327
    RCSTA1      =    %10010000          ;90h
    BAUDCON1    =    %01000000
    SPBRG1      =    34                 ;57,600 Baud @ 48MHz, 0.16%    
    PIE3.5      =    1                  ;RC1IE
    PIE3.4      =    0                  ;TX1IE
    TXSTA2      =    %00100100          ;24h, Master Controller
    RCSTA2      =    %10010000          ;90h
    SPBRG2      =    34                 ;57,600 Baud @ 48MHz, 0.16%   
    BAUDCON2    =    %01000000 
    PIE3.7      =    1                  ;RC2IE
    PIE3.6      =    0                  ;TX2IE
    ; -=- *** Interrupt Related SFRs *** -----------------------------------------------------------------------------------
    INTCON      =   %01000000           ;.7 = GIE, .1 = INT1 Falling Edge
    PIE0.1      =   1                   ;INT1IE
    
    Start:
        INTCON.7 = 1                                ;Enable Global Interrupts
    @   INT_ENABLE RX1_INT
    @   INT_ENABLE RX2_INT
    
    MainLoop:
    DO
       PAUSE 10
       LOOP
    
    ; -=-=-=- RX1 Interrupt Handler -=-=-=-
    Grab_ELM:
        Ebyt0 = REREG1
        ElmCt = ElmCt + 1
    @   INT_RETURN
    
    ; -=-=-=- RX2 Interrupt Handler -=-=-=-
    Grab_Main:
        IF Mbit = 0 THEN
            Byt0 = RCREG2
            GOTO Grab_Main2
        ELSEIF Mbit = 1 THEN
            Byt1 = RCREG2
        ENDIF
    @   INT_RETURN
    I have a project I originally designed around the PIC18F26K22 that does some work, communicates with an ELM327 OBD-II Interpreter, and reports back to a Master PIC18F25K50 connected to USB. It uses both UART Functions along with SPI for a digital pot. I recently changed over to the PIC18F27K40. Here is the code you requested.

  16. #16
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,517


    Did you find this post helpful? Yes | No

    Default Re: Pic 18F26K40

    Interesting Henrik. No matter the chip selected?

    Ioannis
    I'd say yes. But then again, my programs are usually not near the size of the memory size of the part in question and IIRC the bootloader does not reprogram the FULL memory while an ICSP device programmer usually does, even if the content is all $FF. I may be mistaken there though so don't quote me.

    I suspect that the ICSP programmer used might have a fairly big impact on the programming speed as well and I believe that's part of where the "not to be used for production" label for the PK3 comes from - but again, that's me speculating.

    If I find the time I'll do some tests and report back.

    /Henrik.

  17. #17
    Join Date
    Jun 2016
    Posts
    60


    Did you find this post helpful? Yes | No

    Default Re: Pic 18F26K40

    Thank you mgpmike for posting the code. That's just what I needed to understand how to use the 2nd uart (this is my first time)

    I noted that you define the uarts prior to include the DT interrupt. Does it make any difference if you include the DT int. prior to defining the uarts?

    Alberto
    Last edited by Alberto; - 10th April 2018 at 18:10.

  18. #18
    Join Date
    Apr 2014
    Location
    OK
    Posts
    557


    Did you find this post helpful? Yes | No

    Default Re: Pic 18F26K40

    Just so both are defined before you try to use them, the order doesn't seem to matter. I believe DT said to place the INT section close to the top...maybe it does matter?!?

Similar Threads

  1. High Speed Serial Comm PC - PIC and PIC - PIC
    By manumenzella in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 16th January 2007, 22:55

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts