|
|
View previous topic :: View next topic |
Author |
Message |
jrafa
Joined: 13 Dec 2012 Posts: 9
|
debug with dspic33EP |
Posted: Thu Dec 13, 2012 4:17 am |
|
|
Hello,
I am trying to port a code from dspic33FJ256GP506 to dspic33EP256GP506 with ccs 4.138+mplab 8.88+ICD3. I have some problems, the first one is the debug mode, are there some way to use breakpoint, watch, etc. in this micro?
Second, I have to use sAN6, sAN7... and they are not defined in 33EP256GP506.h, are they missing or i can't use them?
By other hand, I've have to comment the #bank_dma directives, are they support for this micro?
Thanks and regards |
|
|
jrafa
Joined: 13 Dec 2012 Posts: 9
|
|
Posted: Tue Dec 18, 2012 4:18 am |
|
|
Hi,
Finally I could put the microcontroller in debug mode: (MPLAB in mode released, code without delays, etc.).
But I continue with some troubles. For example some #pin_select doesn't work. Also, I have some code which I found its dissambled strange; for example this code:
Code: |
42: t2--;
00230 ED3020 dec.w 0x1020
0026A ED3020 dec.w 0x1020
002A4 ED3020 dec.w 0x1020
002DE ED3020 dec.w 0x1020
00318 ED3020 dec.w 0x1020
0034C ED3020 dec.w 0x1020
0037E ED3020 dec.w 0x1020
003B0 ED3020 dec.w 0x1020
003F0 ED3020 dec.w 0x1020
004C8 ED3020 dec.w 0x1020
43: }
00232 040226 goto 0x000226
0026C 040260 goto 0x000260
002A6 04029A goto 0x00029a
002E0 0402D4 goto 0x0002d4
0031A 04030E goto 0x00030e
0034E 040342 goto 0x000342
00380 040374 goto 0x000374
003B2 0403A6 goto 0x0003a6
003F2 0403E6 goto 0x0003e6
004CA 0404BE goto 0x0004be
44: return SPI2BUF;
|
is it ok?
Thanks |
|
|
jrafa
Joined: 13 Dec 2012 Posts: 9
|
Re: debug with dspic33EP |
Posted: Sat Jan 05, 2013 1:03 pm |
|
|
I had some problems with functions, for this reason I had to rewrite some functions, like i2c_write, i2c_read, spi_xfer, set_tris_x, delay, etc. All function i've rewrited are inline, and they works fine. Also I have added the variable "nada" for protect the memory used by ICD3.
Now, my code is:
Code: |
#include "33EP256GP506.h"
#FUSES ICSP3
#FUSES HS
#zero_ram
#use delay(clock=11059200)
unsigned char nada[78]; //debug purposes
int r = 0;
int subfunction(int a){
return a + 10;
}
int subfunction2(int a, int b){
return a + b;
}
void main(void){
r = 4;
TRISB = 0x0000; //output_drive(PIN_B11);
do{
r = subfunction2(r, r);
r = subfunction(r); //don't arrive here
output_toggle(PIN_B11);
}while(true);
r=1;
}
|
The disassembly listing is:
Code: |
1: #include "33EP256GP506.h"
00000 040212 goto 0x000212
2:
3: #FUSES ICSP3
4: #FUSES HS
5: #zero_ram
6: #use delay(clock=11059200)
7:
8: unsigned char nada[78]; //debug purposes
9: int r = 0;
10: int subfunction(int a){
11: return a + 10;
00208 808284 mov.w 0x1050,0x0008
0020A 42026A add.w 0x0008,#10,0x0008
0020C 780004 mov.w 0x0008,0x0000
0020E B7A000 mov.w 0x0000,0x0000
12: }
00210 060000 return
13:
14: int subfunction2(int a, int b){
15: return a + b;
00200 808280 mov.w 0x1050,0x0000
00202 B41052 add.w 0x1052,0x0000
00204 B7A000 mov.w 0x0000,0x0000
16: }
00206 060000 return
17:
18: void main(void){
00212 A8E8C1 bset.b 0x08c1,#7
00214 210000 mov.w #0x1000,0x0000
00216 23FFE1 mov.w #0x3ffe,0x0002
00218 098001 repeat 0x0002
0021A EB1800 clr.w [0x0000++]
0021C EF6020 clr.b 0x0020
0021E EF304E clr.w 0x104e
00220 EF2E0E clr.w 0x0e0e
00222 EF2E1E clr.w 0x0e1e
00224 EF2E2E clr.w 0x0e2e
00226 EF2E4E clr.w 0x0e4e
00228 20F80F mov.w #0xf80,0x001e
0022A 20FFF0 mov.w #0xfff,0x0000
0022C B7A020 mov.w 0x0000,0x0020
0022E 000000 nop
00230 20F80F mov.w #0xf80,0x001e
00232 20FFF0 mov.w #0xfff,0x0000
00234 B7A020 mov.w 0x0000,0x0020
00236 000000 nop
19: r = 4;
00238 200044 mov.w #0x4,0x0008
0023A 888274 mov.w 0x0008,0x104e
20: TRISB = 0x0000; //output_drive
(PIN_B11);
0023C EF2E10 clr.w 0x0e10
21: do{
22: r = subfunction2(r, r);
0023E F8104E push.w 0x104e
00240 F91050 pop.w 0x1050
00242 F8104E push.w 0x104e
00244 F91052 pop.w 0x1052
00246 020200 call 0x000200
0024A B7B04E mov.w 0x0000,0x104e
23: r = subfunction(r); //don't arrive
here
0024C F8104E push.w 0x104e
0024E F91050 pop.w 0x1050
00250 020208 call 0x000208
00254 B7B04E mov.w 0x0000,0x104e
24: output_toggle(PIN_B11);
00256 A96E11 bclr.b 0x0e11,#3
00258 AA6E15 btg.b 0x0e15,#3
25: }while(true);
26: r=1;
0025A 04023E goto 0x00023e
0025E 200014 mov.w #0x1,0x0008
00260 888274 mov.w 0x0008,0x104e
00262 FE4000 pwrsav #0
|
The CPU is continuously rebooting. The code doesn't end a iteration of the loop, it is not properly return of the first function. But, if I do the subfunctions as "inline", it works.
When I am inside the first subrutine, WREG15 = 0x0F84, the address of the return stack. The stack has the value 0x0000, but if I use the simulator of MPLAB, the stack has the return address.
I suposse there are a problem in the return of the functions. Is this a compiler bug? How i can solve this without do all functions inline?
Thanks |
|
|
jrafa
Joined: 13 Dec 2012 Posts: 9
|
Re: debug with dspic33EP |
Posted: Fri Jan 11, 2013 3:14 am |
|
|
Hi,
I've translated the previous code to assembler:
Code: |
#asm
push r
pop 0x1050
call 0x000200
mov W0, r
#endasm
|
and:
Code: |
#asm
push r
pop 0x1050
rcall 0x000200
mov W0, r
#endasm
|
In both cases the return of the function doesn't work. I've tried the same code with a different compiler: C30 (both without optimizations) and they do work in that case.
Could it be a bug in the map memory of the linker? Has anyone had this problem before? |
|
|
n-squared
Joined: 03 Oct 2006 Posts: 99
|
|
Posted: Wed Jan 16, 2013 10:20 am |
|
|
Hi
I just posted a question which may also pertain to your problem.
I too noticed that the processor resets itself.
I entered View->Disassembly and single-stepped until I hit a POP instruction.
The stack pointer DID NOT CHANGE! That caused the return address to be incorrect.
Best regards
Noam _________________ Every solution has a problem. |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Wed Jan 16, 2013 11:53 am |
|
|
To debug from a different ICSP than #1, you have to have the directive:
_________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
jrafa
Joined: 13 Dec 2012 Posts: 9
|
|
Posted: Thu Jan 17, 2013 3:26 pm |
|
|
Hi,
Thanks for the responses. I suppose your post is http://www.ccsinfo.com/forum/viewtopic.php?p=170972&highlight=#170972. The the issue is similar. But I don't think that it is a silicon bug because I have tried the same code with other compiler and it works. For example this code:
Code: | .include "p33ep256gp506.inc"
.global _main
.global _subfunction1
.global _subfunction2
.global __reset
.section .text
__reset:
MOV #__SP_init, W15 ;Initalize the Stack Pointer
MOV #__SPLIM_init, W0 ;Initialize the Stack Pointer Limit Register
MOV W0, SPLIM
NOP ;Add NOP to follow SPLIM initialization
CALL _main ;Call _wreg_init subroutine
_subfunction1:
mov W0, W1
return
_subfunction2:
mov W1, W0
return
_main:
mov #55, W0
mov W0, 0x10a0
push 0x10a2
pop 0x1050
call _subfunction1
mov #66, W0
mov W0, 0x1050
push 0x10a0
pop 0x10a2
rcall _subfunction2
mov W2, W3
.end |
works fine using XC16 compiler. The stack change correctly with "pop", "call" or "rcall". Also, I have using XC16 for porting my code this week, so far no problem.
Can you reproduce this issue with C30 or XC16 compilers?
By the other hand, I need use the PGD3 pins.
Best regards. |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Thu Jan 17, 2013 3:35 pm |
|
|
jrafa wrote: | Hi,
Thanks for the responses. I suppose your post is http://www.ccsinfo.com/forum/viewtopic.php?p=170972&highlight=#170972. The the issue is similar. But I don't think that it is a silicon bug because I have tried the same code with other compiler and it works. For example this code:
Code: | .include "p33ep256gp506.inc"
.global _main
.global _subfunction1
.global _subfunction2
.global __reset
.section .text
__reset:
MOV #__SP_init, W15 ;Initalize the Stack Pointer
MOV #__SPLIM_init, W0 ;Initialize the Stack Pointer Limit Register
MOV W0, SPLIM
NOP ;Add NOP to follow SPLIM initialization
CALL _main ;Call _wreg_init subroutine
_subfunction1:
mov W0, W1
return
_subfunction2:
mov W1, W0
return
_main:
mov #55, W0
mov W0, 0x10a0
push 0x10a2
pop 0x1050
call _subfunction1
mov #66, W0
mov W0, 0x1050
push 0x10a0
pop 0x10a2
rcall _subfunction2
mov W2, W3
.end |
works fine using XC16 compiler. The stack change correctly with "pop", "call" or "rcall". Also, I have using XC16 for porting my code this week, so far no problem.
Can you reproduce this issue with C30 or XC16 compilers?
By the other hand, I need use the PGD3 pins.
|
Are you using PCD at all or are you using XC16/C30? Those are microchip compilers and you can't mix code from PCD to them. (well, technically, anything with enough work and #DEFINEs is possible)
And I told you already to use the "3rd" debug port in CCS, you have to use:
_________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
jrafa
Joined: 13 Dec 2012 Posts: 9
|
|
Posted: Fri Jan 18, 2013 3:05 am |
|
|
Hi,
Thanks for the interest. I started with a code for dsPIC33FJ & CCS 4.084, afterwards, I've wanted to port it to the dsPIC33EP & CCS 4.138. There were some problems with debugging, pin mapping, peripherals, etc. but finally I solved them. But it has not been possible to solve the problem with the software stack. For this reason I have tried with others compilers (with equivalent code, not exactly the same), like C30 and XC16, and it seems that it works.
On the other hand, I have tried using #device ICD=3, #ICD=true, etc, and the results are the same. I think that the problem is the CCS compiler, not the communication with debugger.
Best regards |
|
|
Douglas Kennedy
Joined: 07 Sep 2003 Posts: 755 Location: Florida
|
|
Posted: Fri Jan 18, 2013 8:36 am |
|
|
I also think it is the ccs compiler...I never could get the CCS built in debugger to work with the 24EP512GU810..maybe EP devices aren't yet fully supported. The strange thing is that the run time code without the CCS debugger code loaded appears at first glance to be working. |
|
|
roccat
Joined: 13 Jan 2013 Posts: 8
|
|
|
Douglas Kennedy
Joined: 07 Sep 2003 Posts: 755 Location: Florida
|
|
Posted: Sun Jan 20, 2013 11:03 am |
|
|
Using CCS 4.134 made no difference with the CCS debugger for the 24EP512GU810. I'm not saying 4.134 ( mainly it is the .dat file that is needed) doesn't work as a workaround for other chips but it is not a workaround for the 24EP512GU810. |
|
|
|
|
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
|