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

PIC18F4550 Unable to enter debug mode

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



Joined: 08 Sep 2006
Posts: 182

View user's profile Send private message Send e-mail

PIC18F4550 Unable to enter debug mode
PostPosted: Tue May 10, 2011 7:34 am     Reply with quote

Hello,
I have a 4550 connected to USB..
When I program it with the ICD2 it works perfectly.....

When I want to use the debug function it doesn't let me....

In MPLAB I get the message "Unable to enter debug mode"

Included mine fuse settings and code... what have I misplaced???
code:
Code:

#include "C:\MentorProjects\Papagaai_Deur\PIC_Code\RFID Test code_USB\main.h"
#include "C:\MentorProjects\Papagaai_Deur\PIC_Code\RFID Test code_USB\internal_eeprom.c"
#include <stdlib.h>
#include <string.h>
#include <stdlib.h>
#include <input.c>
// Includes all USB code and interrupts, as well as the CDC API
#include <usb_cdc.h>

#define RES   pin_C1

int         string_ready   = 0;
signed int   next_in         = 0;
char      string[45];
char      string_temp[45];
int8      teller          = 0;
int8       papagaai_teller   = 0;
int8      first         = 0;

char   string1[]    = "C820";

#int_RDA
void  RDA_isr(void)
{
  string[next_in]=fgetc(ID20);
  if((string[next_in] == 0x0D) & (next_in > 1))   //Einde string
  {
    string_ready = 1;
    string[next_in+1] = '\0';
  }
  next_in=(next_in+1);
  if(next_in > 40) next_in = 0;
}


void main()
{
  setup_adc_ports(NO_ANALOGS|VSS_VDD);
  setup_adc(ADC_OFF);
  setup_psp(PSP_DISABLED);
  setup_spi(FALSE);
  setup_wdt(WDT_OFF);
  setup_timer_0(RTCC_INTERNAL);
  setup_timer_1(T1_DISABLED);
  setup_timer_2(T2_DISABLED,0,1);
  setup_comparator(NC_NC_NC_NC);
  setup_vref(FALSE);

  output_high(pin_c1);

  enable_interrupts(INT_RDA);
  enable_interrupts(GLOBAL);

  usb_cdc_init();
  usb_init();

  for(teller = 0; teller < 45; teller++)
  {
    string[teller] = ' ';
  }
  next_in = 0;

  while(1)
  {
    while(!usb_cdc_connected())
    {
    }
    usb_task();
    if (usb_enumerated())
    {

      if(string_ready == 1)
         {
           printf(usb_cdc_putc,string);

printf(usb_cdc_putc,string_temp);
           string_ready    = 0;
           next_in       = 0;
      }
    }
  }
}


header:
Code:

#include <18F4550.h>
#device adc=8

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES WDT128                   //Watch Dog Timer uses 1:128 Postscale
#FUSES HSPLL                     //High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD)
#FUSES NOPROTECT                //Code not protected from reading
#FUSES NOBROWNOUT               //No brownout reset
#FUSES BORV20                   //Brownout reset at 2.0V
#FUSES NOPUT                    //No Power Up Timer
#FUSES NOCPD                    //No EE protection
#FUSES STVREN                   //Stack full/underflow will cause reset
#FUSES DEBUG                    //Debug mode for use with ICD
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOWRT                    //Program memory not write protected
#FUSES NOWRTD                   //Data EEPROM not write protected
#FUSES NOIESO                     //Internal External Switch Over mode enabled
#FUSES FCMEN                    //Fail-safe clock monitor enabled
#FUSES NOPBADEN                 //PORTB pins are configured as digital I/O on RESET
#FUSES NOWRTC                   //configuration not registers write protected
#FUSES NOWRTB                   //Boot block not write protected
#FUSES NOEBTR                   //Memory not protected from table reads
#FUSES NOEBTRB                  //Boot block not protected from table reads
#FUSES NOCPB                    //No Boot Block code protection
#FUSES MCLR                     //Master Clear pin enabled
#FUSES LPT1OSC                  //Timer1 configured for low-power operation
#FUSES NOXINST                  //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#FUSES PLL5                     //Divide By 4(20MHz oscillator input)
#FUSES CPUDIV1                  //System Clock by 2
#FUSES USBDIV                   //USB clock source comes from PLL divide by 2
#FUSES VREGEN                   //USB voltage regulator enabled


//#use delay(clock=48000000)
#use delay(clock=20000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8, stream=ID20)


FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Tue May 10, 2011 7:56 am     Reply with quote

I don't see #device ICD = true which is required to reserve memory locations for debugging.
Jody



Joined: 08 Sep 2006
Posts: 182

View user's profile Send private message Send e-mail

PostPosted: Tue May 10, 2011 8:00 am     Reply with quote

I added the #device ICD = true but the result is the same...........
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue May 10, 2011 1:20 pm     Reply with quote

Quote:
In MPLAB I get the message "Unable to enter debug mode"

This is really a Microchip ICD2 forum question, but if you're going to ask
it here, at least post the ICDxxxx error message number that you're
seeing in the MPLAB output window. Then we (or you) could just go to
the MPLAB help file for ICD2, and read what they say about it.
Jody



Joined: 08 Sep 2006
Posts: 182

View user's profile Send private message Send e-mail

Solved
PostPosted: Wed May 11, 2011 2:49 am     Reply with quote

I has recently updated the compiler...
And I have the idea that the fuse settings has changed with the compiler..
I have run the PIC Wizard again and get totaly different fuses and fuse settings...
With the new settings everything works perfect...
new fuse settings:
Code:

#include <18F4550.h>
#device adc=16

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES WDT128                   //Watch Dog Timer uses 1:128 Postscale
#FUSES PLL5                     //Divide By 5(20MHz oscillator input)
#FUSES CPUDIV1                  //No System Clock Postscaler
#FUSES HS                       //High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD)
#FUSES NOBROWNOUT               //No brownout reset
#FUSES NOPBADEN                 //PORTB pins are configured as digital I/O on RESET
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES ICSP1                    //ICD uses PGC1/PGD1 pins
#FUSES NOXINST                  //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#FUSES DEBUG                    //Debug mode for use with ICD

#use delay(clock=20000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=ID20)

barryg



Joined: 04 Dec 2006
Posts: 41

View user's profile Send private message

Unable to enter debug mode--V4 Compiler?
PostPosted: Wed Jul 13, 2011 1:16 pm     Reply with quote

I experienced the same problem recently. I currently have no time to chase it down, so all that I know is this:

- I upgraded from V3 to V4 compiler in anticipation of another project.
- For the current project, this is something that I have been developing on and off since 2007.
- It's not that I've never seen this error, but it's been solved in the past by using a shorter cable, or by switching from the ICD2 to the MPLAB REAL ICE
- Those didn't help this time.
- The chip in this case is the PIC18F4455. Current MPLAB is 8.60.
- In program mode it works fine.
- I do have the #device ICD=TRUE line--always have had it.

So I reinstalled the V3 compiler and I got debug capability back immediately.
This makes me wonder if there is a connection anybody knows about. Else I will have to ask the support staff.

Thanks
Barry
turok_gt



Joined: 21 Apr 2010
Posts: 2

View user's profile Send private message

Re: Solved
PostPosted: Tue Aug 02, 2011 9:27 pm     Reply with quote

I had the same problem with the pic18f4550. To enter in mode debug, it needs the fuse #FUSES ICSP1.



Jody wrote:
I has recently updated the compiler...
And I have the idea that the fuse settings has changed with the compiler..
I have run the PIC Wizard again and get totaly different fuses and fuse settings...
With the new settings everything works perfect...
new fuse settings:
Code:

#include <18F4550.h>
#device adc=16

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES WDT128                   //Watch Dog Timer uses 1:128 Postscale
#FUSES PLL5                     //Divide By 5(20MHz oscillator input)
#FUSES CPUDIV1                  //No System Clock Postscaler
#FUSES HS                       //High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD)
#FUSES NOBROWNOUT               //No brownout reset
#FUSES NOPBADEN                 //PORTB pins are configured as digital I/O on RESET
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES ICSP1                    //ICD uses PGC1/PGD1 pins
#FUSES NOXINST                  //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#FUSES DEBUG                    //Debug mode for use with ICD

#use delay(clock=20000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=ID20)

bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Tue Aug 02, 2011 9:51 pm     Reply with quote

I've actually found of late that I can leave out the ICD=TRUE and toggle the project "DEBUG"/"RELEASE" modes instead and go back and forth (of course, you have to set the IDE to Debugger->ICD FIRST, THEN COMPILE, THEN PROGRAM).

Otherwise the debug executive isn't selected properly...

But I've had no issues of late debugging most PIC18's which I work in most of the time.

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
barryg



Joined: 04 Dec 2006
Posts: 41

View user's profile Send private message

Re: Solved
PostPosted: Wed Aug 10, 2011 5:03 pm     Reply with quote

turok_gt wrote:
I had the same problem with the pic18f4550. To enter in mode debug, it needs the fuse #FUSES ICSP1.

Well that was huge. You nailed it! I'm not even sure if CCS would have been able to figure this one out, given the evidence.

Everyone take note, that this seems to be particular to the PIC18F4455/ PIC18F4550. That chip has an alternate set of ICD pins, and the compiler tries to use them by default. Setting the ICSP1 fuse turns that back off. You can see this in MPLAB's "configuration bits"--once you know to look for it.

Side note, for V3->V4 transition; if you are still using *(&x+1) to get the high byte of a 16 bit number, you need to change that to *((unsigned char *)&x+1) ... I knew this, but old code never dies...

Once again, a big thanks for finding that one.
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