Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
aack...I canny git the18F26K22 to boot its wee load [solved]
#1
Hey folks:

New to the forum. Wanting to move from an 18F2620 using tiny-bootloader, to an 18F26K22 using ds30Loader. First off, ds30Loader looks awesome -- I have been waiting for something configurable like this for two decades.

Summary:

1) i can't get it to work with an 18F26K22, but I can with an 18F2620
2) yeah, there are different config bits and all, but I think they are correct
3) will post the settings info below if space permits.

Before that:

a) using a pic pcb board that has been in use for fifteen years
b) well-defined max202 iface; 20 MHz xtal; good ground plane...
c) have used 16F876 BL, trutrack BL for 18F252, tiny BL for 18F2620
d) all BLs have worked flawlessly for many years
e) so, not a hardware problem, ok?

I load up current version of MPLAB-X:

i) looks good. I tweak dsLoader settings for building both 2620 and 26K22
ii) builds are fine, but when I plug in the pickit-3 I just got, no frickin' luck
iii) it finds pickit-3, sees serial-num, but no joy after that

So I use my old-friend QuickWriter to burn the 2620 image from MPLAB-X:

I) Yeah baby! Loaded the BL into the 2620, and ds30Loader worked great!
II) Great except that the QuickWriter is obsolete and does not program the K22. But hey, the BL worked, so I am pumped.

So now I need to get Pickit-3 working with the 2620 for comparison:

0000) a bit of googling leads me to believe that MPLAB-X is a piece-of-shit with pickit-3
0001) so i uninstall MPLAB-X and install the old MPLAB 8.whatever that came on disc with my brand-new pickit-3
0010) yeah! it can actually communicate with the pickit-3!
0011) it updates PI-3 firmware, and i re-build projects
0100) i can load 18F2620 BL via pickit-3, and use ds30 to load code!
0101) life is good!

Now I need to get the 26K22 BL running:

0x00) the pickit-3 (via mplab 8.x) loads the BL code into the 18F26K22!
0x01) but ds30Loader cannot see the 26K22 (crap)
0x02) same hardware; same socket; just different chip/BL-firmware

So now, after a week of farting around, I am no further in migrating my project from 18F2620 using tiny-bootloader, to an 18F26K22 using ds30Loader.

I am not sure how to proceed after getting to the point where the BL does not find the target. Does anyone have any ideas?

thanks, gil smith

the important lines from my 18F26K22 settings file:

processor 18F26K22 ;xxx
;
#define OSCF 20000000 ; 20MHz oscillator frequency (including pll)
#define BLINIT 2000 ;xxx hello receive timeout [ms]
#define HELLOTRIES 2 ;xxx number of non hello characters received before branching to the user application
#define BLTIME 2000 ;xxx data receive timeout [ms]

#define USE_UART1 1 ;xxx uncomment to use uart1
;#define USE_UART2 1 ;xxx uncomment to use uart2
#define BAUDRATE 115200 ;xxx baudrate
;#define USE_ABAUD 1 ;xxx uncomment to use auto baud rate detection, READ ERRATA FIRST
;#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 TXE_DELAY 10 ;xxx time in us to wait before transmitting after pulling the tx enable pin high
#define TRISR_TXE TRISD ;xxx tris register containing tx enable
#define LATR_TXE LATD ;xxx port register containing tx enable
#define TRISB_TXE TRISD0 ;xxx tris bit for tx enable
#define LATB_TXE RD0 ;xxx port bit for tx enable
endif

#define KICK_WD 1 ;xxx uncomment to kick the wdt in the rx loop, only enable if the watchdog is enabled
#define PROT_GOTO 1 ;xxx protect goto at 0x00
#define PROT_BL 1 ;xxx protect bootloader
#define WRITE_VER 1 ;do flash write verification
#define EWRITE_VER 1 ;do eeprom write verification

ifdef IS_PIC18F
#define BLPLP 9 ;bootloader placement, pages from end
#define BLSIZEP 9 ;bootloader size [pages], used by bootloader protection
endif

ifdef IS_PIC18FJ
#define BLPLP 2 ;bootloader placement, pages from end
#define BLSIZEP 1 ;bootloader size [pages], used by bootloader protection
endif


config FOSC = HSHP ; HS oscillator (high power > 16 MHz)
config PLLCFG = OFF ; 4xPLL Disabled (direct oscillator)
config PRICLKEN = ON ; Primary clock Enabled
config FCMEN = OFF ; Fail-Safe Clock Disabled
config IESO = OFF ; Oscillator Switchover Disabled
config PWRTEN = ON ; Powerup Timer Enabled
config HFOFST = OFF ; HFINTOSC delayed until oscillator stable
config BOREN = ON ; Brown Out Detector Enabled
config BORV = 250 ; VBOR set to 2.50 V nominal
config WDTEN = ON ; WDT Enabled; SWDTEN bit has no effect
config WDTPS = 512 ; WDT = 1:512 = 2048 ms

config CCP2MX = PORTB3 ; CCP2 i/o is multiplexed with RB3 (not RC1)
config CCP3MX = PORTB5 ; P3A/CCP3 i/o is multiplexed with RB5 (not RC6)
config T3CMX = PORTB5 ; T3CKI is on RB5 (not RC0)
config P2BMX = PORTC0 ; ECCP2 P2B is on RC0 (not RB5)
config PBADEN = OFF ; PORTB<5:0> pins configured as digital i/o (not analog)
config MCLRE = EXTMCLR ; MCLR pin enabled, RE3 input pin disabled

config STVREN = ON ; Stack Overflow Reset Enabled
config XINST = OFF ; Extended Instructions Disabled
config LVP = OFF ; Low-Voltage-Programming Disabled

config CP0 = OFF ;Code Protect 00800-03FFF
config CP1 = OFF ;Code Protect 04000-07FFF
config CP2 = OFF ;Code Protect 08000-0BFFF
config CP3 = OFF ;Code Protect 0C000-0FFFF
config CPB = OFF ;Code Protect Boot
config CPD = OFF ;Data EE Read Protect
config WRT0 = OFF ;Table Write Protect 00800-03FFF
config WRT1 = OFF ;Table Write Protect 04000-07FFF
config WRT2 = OFF ;Table Write Protect 08000-0BFFF
config WRT3 = OFF ;Table Write Protect 0C000-0FFFF
config WRTC = OFF ;Config. Write Protect
config WRTB = OFF ;Table Write Protect Boot
config WRTD = OFF ;Data EE Write Protect
config EBTR0 = OFF ;Table Read Protect 00800-03FFF
config EBTR1 = OFF ;Table Read Protect 04000-07FFF
config EBTR2 = OFF ;Table Read Protect 08000-0BFFF
config EBTR3 = OFF ;Table Read Protect 0C000-0FFFF
config EBTRB = OFF ;Table Read Protect Boot
Reply
#2
Hi,
Thanks for posting. Please see ghus reply in this thread: http://mrmackey.no-ip.org/elektronik/ds3...hp?tid=200
Reply
#3
Hi Mikael:

Thanks for the reply. I looked at that thread and fixed the problem!

Some comments on the thread:

- I can't use USART2, as the circuit board is fixed with USART1, so I never bothered to test the second port.

- It seems difficult to believe that a small error in the bit times would cause it to not work at all. Intermittently perhaps. Trying lower baud rates would help that issue, but I never bothered.

- The errata tidbit about setting BRGH = 1 and BRG16 = 1 only applies to rev 2 chips. Since my 26K22 chips are rev 4 (as reported by pickit-3 when it connects), I never bothered with this.

- Posts by hobbytronics and ghu show extra assembly code for the user_code section. As I have not programmed pic assembly since the early 90s (I use CCS C), I had to dig into assembly a bit (pardon the pun).


IT NOW RUNS DUE TO TWO THINGS I DID:

1) GOT RID OF MPLAB-X -- this never could talk to the Pickit-3. I find it reprehensible that Microchip allowed this software out without testing it. I am apparently not the only one who ran into problems with it. Maybe there is a firmware update for pickit-3 to fix it, but now that I have my bootloader built, I won't need mplab except to program a chip, or maybe build ds30loader for another chip in the future. I loaded the MPLAB version 8.70 that came on disk with the pickit-3 and it works great.

2) ADDED A FEW ASSEMBLY LINES TO USER_CODE:

UserInit macro

; tweak: Make uart-1 pins digital:
movlb 0x0F ; MANDATORY: BSR set to SFR bank
movlw b'00000000'
movwf ANSELC ; MANDATORY: analog off on port C
movlw b'00000000'
movwf ADCON0 ; not necessary, but adc off
movlw b'10111111'
movwf TRISC ; not necessary, but tx pin RC6 as output

A big thanks to hobbytronics and ghu for finding this!

gil smith

Reply
#4
I desperately needed to get the ds30 running on my 18F25K22 using the internal oscillator at 16MHz, 4x PLL and USART2. It's taken a lot of time to get it working but with the collective wisdom of the forum I have succeeded, so many thanks.

It boiled down to putting code in user_code.inc to make sure all the ANSELs are correctly set to digital mode, TRIS's correct, comparators switched off, ADCON set to digital (only needed for USART1) and the correct oscillator configuration. Finally setting the CONFIG registers correctly for my setup.

Of course getting these devices to work properly even when not using a bootloader means getting all that right too.

Finally I tried to find out what breaks it. Setting OSCTUNE to b'11000000' to feed the PLL from the internal oscillator was a vital one.

If anyone's interested I'll post my set of files.

Now to get ds30 going on my 18F44K22, should be a doddle...

John
Reply
#5
(2012-06-28, 17:03:05)SoundFriend Wrote: If anyone's interested I'll post my set of files.

Now to get ds30 going on my 18F44K22, should be a doddle...

John

Hi John,

If you wouldn't mind that would be most appreciated.

My setup is identical and I'm still fiddling about without sucess just yet...

Craig
Reply
#6
(2012-06-28, 17:03:05)SoundFriend Wrote: I desperately needed to get the ds30 running on my 18F25K22 using the internal oscillator at 16MHz, 4x PLL and USART2.
...
It boiled down to putting code in user_code.inc to make sure all the ANSELs are correctly set to digital mode, TRIS's correct, comparators switched off, ADCON set to digital (only needed for USART1) and the correct oscillator configuration. Finally setting the CONFIG registers correctly for my setup.
...
Finally I tried to find out what breaks it. Setting OSCTUNE to b'11000000' to feed the PLL from the internal oscillator was a vital one.
...

I was not using the internal osc on the 26K22 so I didn't run into quite this same issue, but I had a similar obscure problem with a 27J13 -- the errata showed a similar problem with internal osc configuration -- even when not using the int osc. See:
http://mrmackey.no-ip.org/elektronik/ds3...hp?tid=525

Crazy stuff.
Reply
#7
(2013-03-03, 03:23:20)strud Wrote:
(2012-06-28, 17:03:05)SoundFriend Wrote: If anyone's interested I'll post my set of files.

Now to get ds30 going on my 18F44K22, should be a doddle...

John

Hi John,

If you wouldn't mind that would be most appreciated.

My setup is identical and I'm still fiddling about without sucess just yet...

Craig

Done, I hope it's useful.

John


Attached Files
.zip   Code.zip (Size: 6.4 KB / Downloads: 26)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)