CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Debugging PIC24F

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Andrew76
Guest







Debugging PIC24F
PostPosted: Sun Mar 22, 2009 3:36 am     Reply with quote

Hello,
I'm trying to use PIC24FJ64GA002.
This PIC is mounted on microchip development board DM300027

I use for the development the MPLAB 8.20
For the compiler, CCS 4.081

My program only moves the 4 leds on the board.

The problem is that I can program the system but can't enter in debug mode!

following fuses configuration

#include "24FJ64GA002.h"


#device ICD=TRUE

#FUSES NOJTAG //JTAG disabled
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOWRT //Program memory not write protected
#FUSES DEBUG //Debug mode for use with ICD
#FUSES ICS1 //ICD communication channel 1
#FUSES IOL1WAY //Allows only one reconfiguration of peripheral pins
#FUSES WINDIS //Watch Dog Timer in non-Window mode
#FUSES WPRES128 //Watch Dog Timer PreScalar 1:128
#FUSES WPOSTS16 //Watch Dog Timer PostScalar 1:32768
#FUSES NOIESO //Internal External Switch Over mode disabled
#FUSES NOCKSFSM //Clock Switching is disabled, fail Safe clock monitor is disabled
#FUSES NOOSCIO //OSC2 is general purpose output
#FUSES HS //High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD)
#FUSES I2C1SELD
#use delay(clock=7632000,RESTART_WDT)



Any idea?
Thanks
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Sun Mar 22, 2009 5:50 am     Reply with quote

I don't think, that it prevents ICD2 debugging, but the oscillator mode is set to default FRC_PS (internal with postscaler), cause no #FUSES PR is present, resulting in 4 MHz clock with default CLKDIV setting. Also default NOWDT is in effect.

Generally, it's a good idea to check all fuses in MPLAB, also to verify if your understanding of CCS C #fuses settings is corresponding to the compiler's.
Andrew76
Guest







PostPosted: Mon Mar 23, 2009 1:56 am     Reply with quote

Thank for the help.
I try in the way you suggest but still doesn't enter in debug mode.

Do I have to try something in MPLAP?

Where is the fault?

The system still program the PIC but doesn't enter in debug mode.
Andrew76
Guest







PostPosted: Tue Mar 24, 2009 7:39 am     Reply with quote

I finally found what happends with the demo board and with MPLAB.

About the demo board, the ICD seems working on ICD1 pin.
I set fuses
#FUSES ICS1 //ICD communication channel 1

for the communication on channel 1.

Everything for me was clear and easy but...
Running comiler, MPLAP, automaticalli set the communication on channel 3. Always.
Even if I set the communication mannualy on channel 1, on every comiling of the project, the system switch on channel 3.

I tried to set

#FUSES ICS3 //ICD communication channel 3

and magically, the sistem can finally enter in debug mode.

I hope could be helpul for someone else.

Bye
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Tue Mar 24, 2009 1:28 pm     Reply with quote

Interesting issue. I actually checked the ICD channel in the demoboard schematics against your project settings, cause I had a doubt, it may be wrong. But it seemed to be according to your fuses setting and also the suggestion in the demoboard manual. Don't really understand how the channels are confused. Which setting is displayed in MPLAB after compilation?
Andrew76
Guest







PostPosted: Tue Mar 24, 2009 2:54 pm     Reply with quote

FvM wrote:
Interesting issue. I actually checked the ICD channel in the demoboard schematics against your project settings, cause I had a doubt, it may be wrong. But it seemed to be according to your fuses setting and also the suggestion in the demoboard manual. Don't really understand how the channels are confused. Which setting is displayed in MPLAB after compilation?



I've checked again to be sure about my post, and as you, everything on the demoboard seems working on channel 1.
But, on doubt, I've seen thet something strange happends.

In the program, if I write on fuses
#FUSES ICS1
as it should be, MPLAB, automatically change his congiguration fuses to work on channel 3!!!!

if then I force channel 1 in MPLAB configuration, wen compiling, MPLAB, once again, change on channel 3.
This disabled the communication for the debug and the system doesn't enter in debug mode.

I've then set the fuse in program to work on channel 3
#FUSES ICS3

and now, MPLAB, when I compile, change his fusese to work on channel 1!!!
But now the system finally enter in debug mode!!!!!
What I need!
So, I don't know who is the mistake but working with #FUSES ICS3 let me able to debug!!!
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Tue Mar 24, 2009 3:41 pm     Reply with quote

It's actually very simple, just another PCD bug. You can see in list file, that ICS1 is displayed, but PGC3/PGD3 is coded in configuration bits. The bug is continued at least until V4.084. In V4.087, it has been supplemented by a new bug. Now fuses with a new name of ICSP2 up to ICSP4 are available, no ICS1 or ICSP1. Assuming the numbers have been only shifted inadvertently, the order of mapping in configuration bit is still wrong. The #fuses coding can be viewn and also corrected in Device Table Editor tool.

P.S.: I wonder, if it's really too difficult to read a daatsheet.
Quote:
CW1: FLASH CONFIGURATION WORD 1
...
bit 9-8 ICS1:ICS0: Emulator Pin Placement Select bits
11 = Emulator EMUC1/EMUD1 pins are shared with PGC1/PGD1
10 = Emulator EMUC2/EMUD2 pins are shared with PGC2/PGD2
01 = Emulator EMUC3/EMUD3 pins are shared with PGC3/PGD3
00 = Reserved; do not use

CCS C sets 01 for ICS1 (and for ICSP2 now), which selects PGD3
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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