Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
18F25K22 Support [solved]
#1
Hi Mikael, Graham here from Digital DIY.

With the feature packed 18F25K22 now fully supported by Microchip, it is becoming the PIC of choice for PICAXE, Amicus and Xino. I have a few of them to test with, although I found there were some issues with the ds30 bootloader.

First thing I noticed - 'Device.INC' has a duplicate pre-compile option:
Code:
    ifdef    __18F25K22
        #include    p18F25K22.inc
        #define        VALID_DEV        1
        #define        MAX_FLASH        0x8000
        #define        DEVICEID        83
        #define        HAS_UART2        1
        #define        ROWSIZEW        32
    endif
After correcting that, I entered in the settings for my hardware (an Amicus board with 16Mhz crystal). Here's the relevant settings from 'settings.inc'
Code:
;------------------------------------------------------------------------------
; Device
;------------------------------------------------------------------------------
        LIST          P=18F25K22;                        ;xxx


;------------------------------------------------------------------------------
; Includes
;------------------------------------------------------------------------------
        #include    "devices.inc"


;------------------------------------------------------------------------------
; User preferences
;------------------------------------------------------------------------------
        radix DEC

        #define        DEV_MODE        1                ;xxx delete or comment this line
        #define        OSCF            64000000        ;xxx oscillator frequency
        #define        BLTIME            2000            ;xxx data receive timeout [ms]
        #define        BLINIT            2000            ;xxx hello receive timeout [ms]
        #define        HELLOTRIES        2                ;xxx number of non hello characters received before branching to the user application


;------------------------------------------------------------------------------
; UART settings
;------------------------------------------------------------------------------            
        #define        BAUDRATE         115200            ;xxx baudrate
        #define        USE_UART1        1                ;xxx uncomment to use uart1
        ;#define    USE_UART2        1                ;xxx uncomment to use uart2
        ;#define    USE_BRG16        1                ;xxx uncomment to use 16-bit brg        
        
        ;#define    USE_TXENABLE    1                ;xxx uncomment to use a tx enable pin        
        #ifdef USE_TXENABLE
            #define    TRISR_TXE        TRISC            ;xxx tris register containing tx enable
            #define    LATR_TXE        LATC            ;xxx port register containing tx enable
            #define    TRISB_TXE        TRISC6            ;xxx tris bit for tx enable
            #define LATB_TXE        RC6                ;xxx port bit for tx enable
        #endif


;------------------------------------------------------------------------------
; CAN settings
;------------------------------------------------------------------------------        
        ;#define USE_CAN                            ;xxx uncomment to use CAN instead of UART
        #define        ID_PIC        1                    ;xxx node number for this device
        #define     ID_GUI         0x7ff                ;xxx node number of the ds30 Loader gui


;------------------------------------------------------------------------------
; Advanced settings
;------------------------------------------------------------------------------        
        #define        PROT_GOTO    1                    ;xxx protect goto at 0x00
        #define        PROT_BL     1                    ;xxx protect bootloader
        
        #define        BLPLP        7                    ;bootloader placement, pages from end
        #define        BLSIZEP        7                    ;bootloader size [pages], used by bootloader protection    
        

;------------------------------------------------------------------------------
; Configuration bits, these macros can be found at the end of the inc-files located in
; C:\Program Files\Microchip\MPASM Suite\
;
; These can also be set in MPLAB IDE instead, they are found in Configure->Configuration bits...
;------------------------------------------------------------------------------
    CONFIG FOSC = HSHP
    CONFIG PLLCFG = ON
    CONFIG FCMEN = OFF
    CONFIG IESO = OFF
    CONFIG BOREN = ON
    CONFIG WDTEN = OFF
    CONFIG WDTPS = 128
    CONFIG PBADEN = OFF
    CONFIG STVREN = ON
    CONFIG LVP = OFF
    CONFIG XINST = OFF
    CONFIG DEBUG = OFF
The ds30 GUI can not detect the device, and a quick check with 18F25K20 settings suggest the hardware works fine (the GUI picks it up fine). What am I overlooking?
I should have added that I am using MPLAB 8.63
Reply
#2
Hello m8!

Is it an external crystal?
I would try without pll and boren and and a lower baud rate.
You missed this one: #define DEV_MODE 1 ;xxx delete or comment this line

Reply
#3
Hi Mikael, cheers for getting back to me.

Yea, the Amicus board makes use of an external 16Mhz crystal.

It's got to be something simple, surely! Attached is a modified version of ds30 specifically for use with K20 and K22. The bootloader configuration depends on the device selected from within MPLAB.

The bootloader works fine with the K20, and not so well with K22 selected (timeouts).

Any thoughts? Feel free to make changes to the software - I can test it here if you do not have any K22's.

.zip   firmware PIC18F.zip (Size: 59.29 KB / Downloads: 32)
It's also worth pointing out that I made the changes you suggested earlier, and that PORTC<7:6> are configured as digital if the K22 is selected.
Reply
#4
It look osk, use an oscilloscope and
verify oscillator frequency
verify PIC tx baud rate
verify rx baud rate on PIC rx pin

You could also try to set the tris bits for u1 tx and rx correctly
Reply
#5
Hi Mikael,

Quote:You could also try to set the tris bits for u1 tx and rx correctly

Will do, I've made a change in the user init section:

Code:
        ; Enable digital i/o    
        ifdef    ADCON1
            ifndef DEV_MODE
;                error Do you need to configura uart pins to be digital? If not, remove this line
                ifdef    __18F25K22
                    clrf     ANSELC
                    movlw    0x80
                    movwf    TRISC
                endif
            endif
        endif

Attached is the updated ds30 program (still not working, though)
.zip   firmware PIC18F.zip (Size: 57.96 KB / Downloads: 16)

The K22 support has got me stumped. I only dabble with low level code - I much prefer to use a HLL such as Swordfish.. With that in mind, my fault finding capability is rather limited working with assembly!

I made the following simple program for testing the K20 and K22 USART hardware. The only the config fuses change depending on which device is selected:

Code:
Device = 18F25K22
//Device = 18F25K20

Clock = 16
#if _device = 18F25K20
    Config FOSC = HS
#else
    Config PLLCFG = OFF, FOSC = HSHP    
#endif

Include "USART.bas"

USART.SetBaudrate(br38400)
While True
    USART.Write("Hello World",13,10)
    DelayMS(1000)
Wend

The program works perfectly fine with either K20 or K22 defined, and results with "Hello World" on the terminal program every second. Which is interesting, as the USART module is configured exactly the same between the Swordfish programs. Going a little further, and the SF USART initialisation looks much the same as what you have in the ds30 program.

Attached are the assembly outputs for each variation of the above program (just in case you'd like to inspect the configuration between them?).
.zip   K20+K22 ASM.zip (Size: 11.22 KB / Downloads: 23)

Have you had any success with K22's in the past? There also appears to be a small bug in the GUI for the 18F25K22 - the device is listed twice in v1.3.14.0).
Reply
#6
No I haven't used a K22.
Ok, interesting.

Is still think you should use an oscilloscope to point the problem out:
verify oscillator frequency
verify PIC tx baud rate
verify rx baud rate on PIC rx pin

You could also add constant transmit in the firmware to verify PIC tx using the terminal in ds30 Loader.
Reply
#7
I think a lot of people look forward to a solution because although compilers may cater for new PIC's they do not provide boot loaders until a much later date (if ever) and for educational applications I consider a boot loader essential.

It is an interesting situation because I do not have the skill needed to create a boot loader for the 18F25K22 chip, nor can I find anyone who sells one. So Mikael, you have the ability to save both my sanity ... and the planet Hi!.

John.


@ Mitchy.

I am not smart enough to know if this is relevant of not.

"The default is 64MHz (16 mips), as it is using the internal x4 PLL with a 16MHz crystal." (from the Amicus forum by Les).

Also ...."However, I have noticed that the latest Mpasm assembler supplied with the compiler seems to have an anomaly with its fuse configuration when using an 18F25K22 device. And instead of choosing the High speed oscillator, it's choosing the LP oscillator ........ Les".









Reply
#8
I still think you should use an oscilloscope to point the problem out:
verify oscillator frequency
verify PIC tx baud rate
verify rx baud rate on PIC rx pin

or send me a board and i will fix it.
Reply
#9
Righto, thanks to the help of Ettore from the Amicus site, we've got a working version of ds30 for PIC18F25K22 (attached).

The changes needed:
  • devices.inc - remove duplicate 18F25K22 entry
  • ds30loader.asm - configure digital IO via ANSELC banked address
  • from there, follow the normal setup guide for ds30
I've tested the firmware, works well.

@moonshadow
Fuse configurations are manually defined in settings.inc - the attached firmware will work on your Amicus18 board with an 18F25K22 installed Smile

[Edit] Reverted the firmware version back to 2.0.3 so that it functions with the GUI/Console correctly.


Attached Files
.zip   ds30Loader.zip (Size: 716.04 KB / Downloads: 77)
Reply
#10


@moonshadow
Fuse configurations are manually defined in settings.inc - the attached firmware will work on your Amicus18 board with an 18F25K22 installed Smile

[Edit] Reverted the firmware version back to 2.0.3 so that it functions with the GUI/Console correctly.
[/quote]

@Mitchy.

Sorry for the delay, I have been having a 'blank' period. I tried this and it does work, but I ran into issues. I am not sure if I generated them with my own incompetence, but decided to post them here just in case. Incidentally I am not using the Amicus board, but the one for the Children's project. I am using the Amicus compiler.

1. The first is that the above procedures* were written for the 18F25K20 chip, but also appear to apply to the 18F25K22 chip.

2. Most of the issues found with the DS30 concerned the operation of the drop down DOS window.

3. If the target board is not powered during a download, the bootloader search is bypassed and the DOS screen closes giving no time to read any warnings.

4. If the download cable is not plugged in during a download, the bootloader search is bypassed and the DOS screen closes giving no time to read any warnings.

5. During a normal download, it was found that very often the bootloader search was bypassed, or prematurely ended. This was of major concern because the DOS screen disappears so fast, it is impossible to read the warnings at the bottom of the window. The end result is that one thinks that there has been a download, when there hasn't. Again, the DOS screen closes down too fast to read any warnings.

6. If, in the settings box, the download cable is not plugged in, it obviously will not show. If it is then plugged in, one has to exit and then re-enter the box in order to detect the cable.

7. It may very well be that the above conditions were caused by my own incompetence.

jk

* http://homepage.ntlworld.com/moonshadow/...loader.htm

Reply
#11
    Hey there

hope can still write in this one...

anyway, I've been using the 18F45K22, 18F44K22 with success, and now I'm trying to use the 18F24k22, but nothing (should be the same, or almost, right?)

I've tried to clear the ASELC, but nothing and when I tried to make the C7 pin an input, this message came out (picture attached).

I've program the PIC already, just to see if it works, and yes, it is working, so may be the bootloader the one that doesn't work.... I guess

Here is the text that i modify, so u can check them out, maybe u can see something that i don't

config FOSC = INTIO67 ;Internal oscillator block
config PLLCFG = OFF ;Oscillator used directly ( Disabled )
config PRICLKEN = ON ;Primary clock is always enabled
config FCMEN = OFF ;Fail-Safe Clock Monitor disabled
config IESO = OFF ;Oscillator Switchover mode disabled
config PWRTEN = OFF ;Power up timer enabled
config BOREN = OFF ;Brown-out Reset disabled in software
config WDTEN = OFF ;Watch dog timer is always disabled.
config PBADEN = OFF ;PORTB<5:0> pins are configured as digital I/O on Reset
config HFOFST = OFF ;HFINTOSC output and ready status are delayed by the oscillator stable status
config MCLRE = EXTMCLR ;MCLR pin enabled, RE3 input pin disabled
config STVREN = OFF ;Stack full/underflow will not cause Reset
config LVP = OFF ;Single-Supply ICSP disabled
config XINST = OFF ;Instruction set extension and Indexed Addressing mode enabled
config DEBUG = OFF ;Disabled

config CCP3MX = PORTB5 ;P3A/CCP3 input/output is multiplexed with RB5

....and.....

; Make uart pins digital
ifdef ADCON1
ifndef DEV_MODE
; error Do you need to configura uart pins to be digital? If not, remove this line
ifdef __18F24K22
clrf ANSELC
movlw 0x80
movwf TRISC
endif
endif
endif

I'd put it down into test with a oscilloscope, and the GUI send the data, but the PIC never answers back, so any Idea?


thanks in advance
Reply
#12
Hi,
Please zip the boot loader MPLAB IDE project and post it here. What does your oscillator setup look like?
Reply
#13
Hi,

here is the zip file, now it is working, sadly to say, just download a old version of your software, change the PIC18F24K22, and it was working, no more the error as before (contact Mike....)

at the end the new .hex file add two more words, but I actually don't know what was wrong, because I double checked and the config registers were the same, the baud set up was the same, pretty much else was the same....

anyway here is the zip file, just in case

thanks again for the great soft...
https://www.youtube.com/watch?v=B7z7BhY5WBA


Attached Files
.zip   firmware PIC18F.zip (Size: 102.86 KB / Downloads: 41)
Reply
#14
Can you please post the non working files as well. Thanks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)