Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
HELP WITH PIC18FK20
#1
I have an old copy of DS30 I used it a few years ago with a PIC24H and had no problems, but I am now trying to use it with a PIC18F45K20 but I have not been successful to make it work. I seem to compile correctly with MPLAB 8.92 I can compile, generate a hex file and program the device but when I use the gui loader all I get is time outs.  I did further hardware debugging and found that I am receiving the correct data from the loader on to the PIC RXD pin, however the TXD pin on the PIC is always low and never sends any data out. It appears that the UART is not being setup correctly. I have set the Settings.inc file so the UART1 is selected and the correct TRIS pins are set for TXD, but I cannot get this to work at all.

The PIC is setup as follows:

PIC18F45K20

crystal= 8.388608 MHz

The fuse bits are: 
Oscillator =  HS
NOPROTECT
WDT timer is ON
NOPUT
NOLVP
WDT prescaler = 128
MCLR pin is active
NODEBUG

using UART1 (only one available) at 9600 baud

I have attached my  2 build files that I modified. (settings.inc and ds30loader.asm)

PLEASE...Any help with the above would be greatly appreciated.!!


Attached Files
.txt   settings.txt (Size: 5.86 KB / Downloads: 6)
.txt   ds30loader_asm.txt (Size: 21.83 KB / Downloads: 6)
Reply
#2
I suggest you set ALL configs bits explicitly in settings.inc.
Why is tx_enable uncommented?
Reply
#3
Also use the latest version.
Reply
#4
I am not sure where "tx_enable" is uncommented, on the settings.inc file it is written as follows:
#define USE_TXENABLE 1 ;xxx uncomment to use a tx enable pin

Then on ds30loader.asm we have the following lines which I thought are set correctly:
;----------------------------------------------------------------------
; User init
;----------------------------------------------------------------------
; Enable digital i/o ;
#ifdef ADCON1
; error Do you need to configura uart pins to be digital? If not, remove this line
#endif
;movlw b'01100000' ;xxx disable
;movwf ADCON1 ;xxx analog on tx/rx

; Set internal oscillator to 8MHz
;movlw b'01110000'
;movwf OSCCON

; Make tx enable pin output and set to 0
#ifdef USE_TXENABLE
bcf TRISR_TXE, TRISB_TXE
bcf LATR_TXE, LATB_TXE
#endif
As far as the bit fuses go I have been setting them in MPLAB as I could not find the correct combination for my set-up. I will download the latest free version and try that instead of the older one I have.
Thank you
Reply
#5
I think I misunderstood the meaning of "USE_TXENABLE" for some reason I thought it meant to allow the TXD pin to work, which is silly because the boot loader has to have two way communication anyway. After reading your manual I realize this is just a method to assign a TX enable function through an input pin when we are using the RS485 method of communication. I have now commented out this as follows: ;#define USE_TXENABLE 1
The other thing that I don't seem to understand and perhaps is related to why I can't make this work is why do I keep getting a compilation error on this line of the ds30loader.asm Enable digital i/o ;
#ifdef ADCON1
error Do you need to configura uart pins to be digital? If not, remove this line
#endif

So I had to do the following which is comenting this line out: ; error Do you need to configura uart pins to be digital? If not, remove this line
I don't understand why I get this error unless ADCON1 has been defined as true, where does ADCON1 get set to true?
For some reason my TXD in from my UART is just not working, however everything works fine with my UART when I program other code instead of the s30 loader
Reply
#6
I finally got this working,

The only thing that was wrong with it was the fact I had uncommented "USE_TXENABLE" once I commented that out and got the correct fuse configuration bits set everything appears to work just fine.  I ended up not using the config bit fuses on the code but instead I just set them up independently using MPLAB. Once I generate the hex file and burn one device I can then read the device with it's config bits on to a hex file and then use that hex file as my boot loader load file for future programming.
Reply
#7
Thanks for the update.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)