2xhp
Joined: 14 Jan 2019 Posts: 39
|
write_program_memory on 18F25K80 not working |
Posted: Wed Apr 14, 2021 6:43 pm |
|
|
I can't seem to get write_program_memory to work on a 18F25K80. Compiler version is PCH V5.087.
I'm checking to see if it's written or not by reading back the program memory. The programmer I'm using is a PICkit 2. I see that the EEPROM value I'm writing is written to just to verify the program is running.
Any ideas anyone? I thought maybe it's a fuse value, but I've tried everything that seems like it might be related to write protection. Thanks in advance.
Test program:
Code: | #include <18F25K80.h>
#fuses HSM,PLLEN,NOFCMEN,NOIESO,WDT,WDT_SW,NOMCLR,NOBROWNOUT,NOPUT,SOSC_DIG
#fuses NOPROTECT,NOCPD,NOCPB,NOWRTD,NOWRTB,NOWRTC,NOEBTRB
#use delay(clock=40000000, restart_wdt)
int8 buffer[64] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,
17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,
33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,
49,50,51,52,53,54,55,56,57,58,59,60,60,62,63,64 };
void main() {
write_program_memory(0x2000,buffer,64);
write_eeprom(0x00, 0x77);
} |
List file:
CCS PCH C Compiler, Version 5.087, xxxxx 14-Apr-21 18:37
Filename: C:\temp\test.lst
ROM used: 326 bytes (1%)
Largest free fragment is 32442
RAM used: 68 (2%) at main() level
75 (2%) worst case
Stack used: 0 locations
Stack size: 31
*
0000: GOTO 0066
.................... #include <18F25K80.h>
.................... //////////// Standard Header file for the PIC18F25K80 device ////////////////
.................... ///////////////////////////////////////////////////////////////////////////
.................... //// (C) Copyright 1996, 2014 Custom Computer Services ////
.................... //// This source code may only be used by licensed users of the CCS C ////
.................... //// compiler. This source code may only be distributed to other ////
.................... //// licensed users of the CCS C compiler. No other use, reproduction ////
.................... //// or distribution is permitted without written permission. ////
.................... //// Derivative programs created using this software in object code ////
.................... //// form are not restricted in any way. ////
.................... ///////////////////////////////////////////////////////////////////////////
.................... #device PIC18F25K80
0004: MOVF FF2,W
0006: MOVWF 03
0008: BCF FF2.7
000A: BSF F7F.7
000C: BSF F7F.2
000E: MOVLB F
0010: MOVLW 55
0012: MOVWF F7E
0014: MOVLW AA
0016: MOVWF F7E
0018: BSF F7F.1
001A: NOP
001C: MOVF 03,W
001E: IORWF FF2,F
0020: MOVLB 0
0022: RETURN 0
0024: BCF F7F.6
0026: MOVF FF6,W
0028: ANDLW 3F
002A: MOVWF 00
002C: MOVLW C0
002E: ANDWF FF6,F
0030: TBLRD*-
0032: MOVFF 44,01
0036: TSTFSZ 00
0038: BRA 0048
003A: MOVFF FEE,FF5
003E: MOVF 01,F
0040: BZ 004A
0042: TBLWT+*
0044: DECF 01,F
0046: BRA 004E
0048: DECF 00,F
004A: TBLRD+*
004C: TBLWT*
004E: MOVLW 3F
0050: ANDWF FF6,W
0052: XORLW 3F
0054: BNZ 0036
0056: BSF F7F.4
0058: RCALL 0004
005A: RCALL 0004
005C: TSTFSZ 01
005E: BRA 0036
0060: CLRF FF8
0062: GOTO 011A (RETURN)
....................
.................... #list
....................
....................
.................... #fuses HSM,PLLEN,NOFCMEN,NOIESO,WDT,WDT_SW,NOMCLR,NOBROWNOUT,NOPUT,SOSC_DIG
.................... #fuses NOPROTECT,NOCPD,NOCPB,NOWRTD,NOWRTB,NOWRTC,NOEBTRB
....................
.................... #use delay(clock=40000000, restart_wdt)
....................
.................... int8 buffer[64] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,
.................... 17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,
.................... 33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,
.................... 49,50,51,52,53,54,55,56,57,58,59,60,60,62,63,64 };
....................
.................... void main() {
0066: CLRF FF8
0068: BCF FD0.7
006A: MOVLB F
006C: MOVF x5C,W
006E: ANDLW 80
0070: MOVWF x5C
0072: MOVLW 00
0074: MOVWF x5D
0076: BCF FC1.3
0078: BCF FC1.4
007A: BCF FC1.5
007C: CLRF x5E
007E: CLRF x5F
0080: BRA 00C6
0082: DATA 40,00
0084: DATA 04,01
0086: DATA 02,03
0088: DATA 04,05
008A: DATA 06,07
008C: DATA 08,09
008E: DATA 0A,0B
0090: DATA 0C,0D
0092: DATA 0E,0F
0094: DATA 10,11
0096: DATA 12,13
0098: DATA 14,15
009A: DATA 16,17
009C: DATA 18,19
009E: DATA 1A,1B
00A0: DATA 1C,1D
00A2: DATA 1E,1F
00A4: DATA 20,21
00A6: DATA 22,23
00A8: DATA 24,25
00AA: DATA 26,27
00AC: DATA 28,29
00AE: DATA 2A,2B
00B0: DATA 2C,2D
00B2: DATA 2E,2F
00B4: DATA 30,31
00B6: DATA 32,33
00B8: DATA 34,35
00BA: DATA 36,37
00BC: DATA 38,39
00BE: DATA 3A,3B
00C0: DATA 3C,3C
00C2: DATA 3E,3F
00C4: DATA 40,00
00C6: MOVLW 00
00C8: MOVWF FF8
00CA: MOVLW 00
00CC: MOVWF FF7
00CE: MOVLW 82
00D0: MOVWF FF6
00D2: TBLRD*+
00D4: MOVF FF5,W
00D6: MOVWF 00
00D8: XORLW 00
00DA: BZ 0102
00DC: TBLRD*+
00DE: MOVF FF5,W
00E0: MOVWF 01
00E2: BTFSC FE8.7
00E4: BRA 00F0
00E6: ANDLW 3F
00E8: MOVWF FEA
00EA: TBLRD*+
00EC: MOVFF FF5,FE9
00F0: BTFSC 01.6
00F2: TBLRD*+
00F4: BTFSS 01.6
00F6: TBLRD*+
00F8: MOVFF FF5,FEE
00FC: DCFSNZ 00,F
00FE: BRA 00D2
0100: BRA 00F4
0102: CLRF FF8
....................
.................... write_program_memory(0x2000,buffer,64);
0104: CLRF FF8
0106: MOVLW 20
0108: MOVWF FF7
010A: CLRF FF6
010C: CLRF FEA
010E: MOVLW 04
0110: MOVWF FE9
0112: MOVLW 40
0114: MOVWF 44
0116: MOVLB 0
0118: BRA 0024
.................... write_eeprom(0x00, 0x77);
011A: MOVF FF2,W
011C: MOVWF 00
011E: BCF FF2.7
0120: CLRF F75
0122: CLRF F74
0124: MOVLW 77
0126: MOVWF F73
0128: BCF F7F.6
012A: BCF F7F.7
012C: BSF F7F.2
012E: MOVLB F
0130: MOVLW 55
0132: MOVWF F7E
0134: MOVLW AA
0136: MOVWF F7E
0138: BSF F7F.1
013A: BTFSC F7F.1
013C: BRA 013A
013E: BCF F7F.2
0140: MOVF 00,W
0142: IORWF FF2,F
.................... }
0144: SLEEP
Configuration Fuses:
Word 1: 1315 VREGSLEEP INTRC_HP SOSC_DIG NOXINST HSM PLLEN NOFCMEN NOIESO
Word 2: 7E79 NOPUT NOBROWNOUT BORV18 ZPBORM WDT_SW WDT1048576
Word 3: 0900 CANB MSSPMSK7
Word 4: 0091 STVREN BBSIZ2K NODEBUG
Word 5: C00F NOPROTECT NOCPB NOCPD
Word 6: E000 NOWRTC NOWRTB NOWRTD
Word 7: 4000 NOEBTRB |
|