View previous topic :: View next topic |
Author |
Message |
RichardM
Joined: 10 May 2007 Posts: 3
|
Compiler locates fuses for PIC18F87J10 at wrong address |
Posted: Thu May 10, 2007 5:31 am |
|
|
I've specified #include <18F87J10.h> in my source module, and that include file correctly specifies #device PIC18F87J10.
However, my fuses in the .hex file are located at 300000h. This is wrong for this device as this location is volatile memory. The configuration data should be located at 1FFF8h which is non-volatile. The PIC datasheet page 277 explains that in this family of devices the configuration data at 1FFF8h gets copied into 300000h at power-up.
As a result the fuses are not set correctly.
PCH 3.239. _________________ Richard
PCH 3.239 |
|
|
kevcon
Joined: 21 Feb 2007 Posts: 142 Location: Michigan, USA
|
|
Posted: Thu May 10, 2007 7:06 am |
|
|
Hi Richard,
I'm using a device in that same family, the 18F65J10, and my hex file shows that the configuration fuses start at 0xFFF8 like they should be.
Can you post a sample program and hex file with the error and also include the compiler version you are using?
Kevin
EDIT: Sorry just noticed that you did include the compiler version |
|
|
Guest
|
|
Posted: Thu May 10, 2007 8:31 am |
|
|
This 'empty' program has been created with the PIC wizard:
#include "C:\TestFuses\Test.h"
void main()
{
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF|ADC_TAD_MUL_0);
setup_psp(PSP_DISABLED);
setup_spi(FALSE);
setup_spi2(FALSE);
setup_wdt(WDT_OFF);
setup_timer_0(RTCC_INTERNAL);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
setup_timer_4(T4_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
setup_oscillator(False);
}
... and the test.h looks like this:
#include <18F87J10.h>
#device adc=8
#FUSES NOWDT //No Watch Dog Timer
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES E4_SW_IO //External Clock with SW enabled 4x PLL
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOXINST //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#FUSES STVREN //Stack full/underflow will cause reset
#FUSES NOPROTECT //Code not protected from reading
#FUSES FCMEN //Fail-safe clock monitor enabled
#FUSES IESO //Internal External Switch Over mode enabled
#FUSES PRIMARY //Primary clock is system clock when scs=00
#FUSES NOWAIT //Wait selections unavailable for Table Reads or Table Writes
#FUSES BW16 //16-bit external bus mode
#FUSES EMCU20 //Extended microcontroller mode,20 bit address mode
#FUSES ECCPE //Enhanced CCP PWM outpts multiplexed with RE6 thorugh RE3
#FUSES EASHFT //Address shifting enabled
#use delay(clock=20000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=9)
The last few lines of the .hex file look like this:
:020000040030CA
:06000000A004C707F8038D
:00000001FF
;PIC18F87J10
The address of the six fuse bytes are located at 00300000h. This, in the datasheet, specifies the location of the (volatile) config registers, but the non-volatile location in EPROM that stores the config data is 1FFF8h.
If I manually change the location address to 0001FFF8h in the .hex file and then recalculate the checksum bytes, the fuses are reported correctly when I load the .hex file into MPLAB.
Regards,
Richard. |
|
|
kevcon
Joined: 21 Feb 2007 Posts: 142 Location: Michigan, USA
|
|
Posted: Thu May 10, 2007 8:57 am |
|
|
Hi Richard,
I get the same error with 3.249 but it works fine with 4.033
Kevin |
|
|
RichardM
Joined: 10 May 2007 Posts: 3
|
|
Posted: Thu May 10, 2007 9:25 am |
|
|
Thanks for the info Kevin. _________________ Richard
PCH 3.239 |
|
|
Ttelmah Guest
|
|
Posted: Thu May 10, 2007 2:45 pm |
|
|
Yes. This was one of the bugs reported months before V4 came along, and never fixed in V3.
You can 'bodge round' it, to make the J chips work in the V3 compilers, by just adding a #ROM statement, to put the values extracted from the .LST file, in the right place.
Best Wishes |
|
|
RichardM
Joined: 10 May 2007 Posts: 3
|
|
Posted: Fri May 11, 2007 4:19 am |
|
|
Thanks for the tip, I've tried using the #ROM directive and this works.
Regards. _________________ Richard
PCH 3.239 |
|
|
|