|
|
View previous topic :: View next topic |
Author |
Message |
roccat
Joined: 13 Jan 2013 Posts: 8
|
not working write_program_memory |
Posted: Sun Mar 30, 2014 1:03 pm |
|
|
hi. not working write_program_memory on dspic33EP64GP504.
Code: |
CCS PCD C Compiler, Version 5.021
Filename: E:\MbCg\test\test.lst
ROM used: 896 bytes (2%)
Largest free fragment is 40064
RAM used: 66 (1%) at main() level
64 (1%) worst case
Stack used: 20 locations
Stack size: 48
*
0000: GOTO 320
.................... //#include <test.h>
.................... //#include <CRC.C>
.................... //#define icd3
.................... //==============================================================================
.................... #include <33EP64GP504.h>
.................... //////////// Standard Header file for the DSPIC33EP64GP504 device ////////////////
.................... ///////////////////////////////////////////////////////////////////////////
.................... //// (C) Copyright 1996, 2013 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 DSPIC33EP64GP504
*
0200: PUSH 42
0202: MOV W0,[W15++]
0204: BCLR.B 8C1.7
0206: MOV 42,W4
0208: IOR #E0,W4
020A: MOV W4,42
020C: BSET.B 8C1.7
020E: MOV W1,2FA
0210: MOV #55,W4
0212: MOV W4,2FA
0214: MOV #AA,W4
0216: MOV W4,2FA
0218: BSET.B 2FB.7
021A: NOP
021C: NOP
021E: BTSC.B 2FB.7
0220: BRA 21E
0222: MOV [--W15],W0
0224: BCLR.B 8C1.7
0226: POP 42
0228: BSET.B 8C1.7
022A: RETURN
022C: MOV W5,[W15++]
022E: MOV #C,W5
0230: REPEAT #3
0232: MOV [W5++],[W15++]
0234: BCLR W3.0
0236: BCLR W3.1
0238: CP0 W3
023A: BRA Z,2C8
023C: BCLR W0.0
023E: BCLR W2.0
0240: MOV #FA,W4
0242: MOV W4,54
0244: MOV W1,2B4
0246: MOV W0,W1
0248: MOV #FFFF,W4
024A: MOV #3,W0
024C: AND W0,W1,W0
024E: BRA Z,268
0250: MOV W1,[W15++]
0252: LSR W1,#2,W1
0254: SL W1,#2,W1
0256: MOV W1,[W15++]
0258: AND #3,W1
025A: TBLWTL W4,[W1]
025C: TBLWTH W4,[W1++]
025E: MOV [--W15],W1
0260: INC2 W1,W1
0262: SUB W0,#2,W0
0264: BRA NZ,256
0266: MOV [--W15],W1
0268: MOV #7FF,W0
026A: AND W0,W1,W0
026C: BRA NZ,27C
026E: MOV W1,2B4
0270: TBLWTL W0,[W1]
0272: MOV W1,[W15++]
0274: MOV #2B4,W1
0276: CALL 200
027A: MOV [--W15],W1
027C: MOV W1,[W15++]
027E: AND #3,W1
0280: TBLWTL [W2++],[W1]
0282: TBLWTH [W2++],[W1++]
0284: MOV [--W15],W1
0286: INC2 W1,W1
0288: MOV #3,W0
028A: AND W1,W0,W0
028C: BRA NZ,29E
028E: MOV #4,W0
0290: SUB W1,W0,W0
0292: MOV W0,2B4
0294: MOV W1,[W15++]
0296: MOV #2B4,W1
0298: CALL 200
029C: MOV [--W15],W1
029E: SUB W3,#4,W3
02A0: BRA NZ,268
02A2: MOV #3,W0
02A4: AND W1,W0,W0
02A6: BRA Z,2C8
02A8: MOV #FFFF,W4
02AA: MOV W1,[W15++]
02AC: AND #3,W1
02AE: TBLWTL W4,[W1]
02B0: TBLWTH W4,[W1++]
02B2: MOV [--W15],W1
02B4: INC2 W1,W1
02B6: MOV #3,W0
02B8: AND W1,W0,W0
02BA: BRA NZ,2AA
02BC: MOV #4,W0
02BE: SUB W1,W0,W0
02C0: MOV W0,2B4
02C2: MOV #2B4,W1
02C4: CALL 200
02C8: MOV #12,W5
02CA: REPEAT #3
02CC: MOV [--W15],[W5--]
02CE: MOV [--W15],W5
02D0: RETURN
02D2: MOV W1,54
02D4: CP0 W3
02D6: BRA Z,2FE
02D8: BTSC.B 0.0
02DA: BRA 2E8
02DC: TBLRDL.B[W0++],[W2++]
02DE: DEC W3,W3
02E0: BRA Z,2FE
02E2: TBLRDL.B[W0],[W2++]
02E4: DEC W3,W3
02E6: BRA Z,2FE
02E8: DEC W0,W0
02EA: TBLRDH.B[W0++],[W2++]
02EC: DEC W3,W3
02EE: BRA Z,2FE
02F0: CLR.B [W2++]
02F2: DEC W3,W3
02F4: INC W0,W0
02F6: CP0 W0
02F8: BTSC.B 42.1
02FA: INC 0054
02FC: BRA 2D4
02FE: RETURN
....................
.................... #list
....................
.................... #FUSES NOWDT //No Watch Dog Timer
.................... #FUSES XT //Crystal osc <= 4mhz for PCM/PCH , 3mhz to 10 mhz for PCD
.................... #FUSES NOCKSNOFSM //Clock Switching is disabled, fail Safe clock monitor is disabled
.................... #FUSES PR_PLL //Primary Oscillator with PLL
.................... #FUSES NOIESO //Internal External Switch Over mode disabled
.................... #opt 9
.................... //------------------------------------------------------------------------------
.................... #ifdef icd3
.................... #FUSES DEBUG //Debug mode for use with ICD
.................... #device ICD=TRUE
.................... #else
.................... #FUSES NODEBUG
.................... #endif
.................... //------------------------------------------------------------------------------
.................... #device ICSP=1
.................... #use delay(clock=140MHz,crystal=8MHz) //#use delay(clock=140000000)
0300: CP0 W0
0302: BTSC.B 42.1
0304: BRA 31E
0306: REPEAT #116B
0308: NOP
030A: REPEAT #3FFE
030C: NOP
030E: REPEAT #3FFE
0310: NOP
0312: REPEAT #3FFE
0314: NOP
0316: REPEAT #3FFE
0318: NOP
031A: DEC W0,W0
031C: BRA NZ,306
031E: RETURN
.................... //==============================================================================
.................... #ZERO_RAM
....................
.................... #bit PLLlock= 0x0742.5
.................... #word CLKDIV = 0x0744
.................... #word PLLFBD = 0x0746
....................
.................... #define CK_FLASH_END (getenv("PROGRAM_MEMORY")-1)
.................... #define CK_FLASH_PAGE_SIZE (getenv("FLASH_ERASE_SIZE")/2)
.................... #define CK_NUM_PAGES (CK_FLASH_END/CK_FLASH_PAGE_SIZE)
....................
.................... #define CK_USER_PAGE (CK_FLASH_PAGE_SIZE*(CK_NUM_PAGES-1))
....................
.................... #org CK_USER_PAGE,CK_FLASH_END {}
.................... #word TRISC = 0x0E20
.................... #word LATC = 0x0E24
.................... #bit led1 = LATC.5
.................... unsigned int8 read_data[8];
.................... unsigned int8 write_data[] = {12,34,56,0,25,42,1,0};
....................
.................... void main()
0320: MOV #2FD0,W15
0322: MOV #2FFF,W0
0324: MOV W0,20
0326: NOP
0328: BSET.B 8C1.7
032A: MOV #105A,W0
032C: MOV #FD1,W1
032E: REPEAT W1
0330: CLR [W0++]
0332: CLR 744
0334: MOV #44,W4
0336: MOV W4,746
0338: CLR E0E
033A: CLR E1E
033C: CLR E2E
033E: MOV #220C,W4
0340: MOV W4,1062
0342: MOV #38,W4
0344: MOV W4,1064
0346: MOV #2A19,W4
0348: MOV W4,1066
034A: MOV #1,W4
034C: MOV W4,1068
.................... {
.................... TRISC = 0b0011000100;
034E: MOV #C4,W4
0350: MOV W4,E20
.................... PLLFBD=68; CLKDIV=0x0000; // multiplier M=70,prescaler N1=2,PLL postscaler N2=2
0352: MOV #44,W4
0354: MOV W4,746
0356: CLR 744
.................... while (PLLlock!= 1);
0358: BTSS.B 742.5
035A: BRA 358
.................... //delay_ms(100);
.................... write_program_memory(0xaf00,write_data,8);
035C: MOV #AF00,W0
035E: MOV #0,W1
0360: MOV #1062,W2
0362: MOV #8,W3
0364: CALL 22C
....................
.................... read_program_memory(CK_USER_PAGE,read_data,8);
0368: MOV #A000,W0
036A: MOV #0,W1
036C: MOV #105A,W2
036E: MOV #8,W3
0370: CALL 2D2
....................
....................
.................... while(TRUE)
.................... {
.................... led1=!led1; delay_ms(100); //TODO: User Code
0374: BTG.B E24.5
0376: MOV #64,W0
0378: CALL 300
037C: BRA 374
.................... }
....................
.................... }
037E: BRA 37E
Configuration Fuses:
Word 3L: FF5F ICSP1 NOJTAG DEBUG
H: FF00
Word 4L: FFFF NOALTI2C1 NOALTI2C2 WDTWIN_25%
H: FF00
Word 5L: FF7F WPOSTS16 WPRES128 PLLWAIT WINDIS NOWDT
H: FF00
Word 6L: FFBD XT NOOSCIO IOL1WAY NOCKSNOFSM
H: FF00
Word 7L: FF7B PR_PLL NOIESO
H: FF00
Word 8L: FFFF NOWRT NOPROTECT
H: FF00
Word 9L: FFFF
H: FF00
Word 10L: FFFF
H: FF00
Some fuses have been forced to be compatible with the ICD debugger.
|
|
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Sun Mar 30, 2014 4:48 pm |
|
|
Your program contains a lot of code that is not required to show your problem.
Also, you will get much better responses when you post the output that you get and the data that you expected. Now you leave it to us to read your mind to figure out what is wrong.
Just something I noticed: Code: | .................... write_program_memory(0xaf00,write_data,8);
035C: MOV #AF00,W0
035E: MOV #0,W1
0360: MOV #1062,W2
0362: MOV #8,W3
0364: CALL 22C
....................
.................... read_program_memory(CK_USER_PAGE,read_data,8);
0368: MOV #A000,W0 | You are writing to address 0xAF00 but reading from 0xA000. No wonder you get different results. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19550
|
|
Posted: Mon Mar 31, 2014 12:39 am |
|
|
As one other tiny comment. Be aware of just how large the page size is on this chip. A write to 0xAF00, will not trigger an erase (not on a page boundary). Also, you need to ensure the page is 'reserved' (no code being put there), so have a #ORG with start and end addresses, and a 'dummy' function containing nothing, to ensure that the compiler will not put code into the addresses. |
|
|
roccat
Joined: 13 Jan 2013 Posts: 8
|
|
Posted: Tue Apr 01, 2014 4:16 pm |
|
|
There was a problem in the compiler 5.021.
In 5.023 write_program_memory works. |
|
|
roccat
Joined: 13 Jan 2013 Posts: 8
|
|
Posted: Wed Apr 02, 2014 9:52 am |
|
|
Found another problem.
After erase_program_memory, write_program_memory not work.
So also does not work if write_program_memory writing from start of the page. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|