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 CCS Technical Support

Err0040: The target device is not ready for debugging.
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Geows



Joined: 05 May 2016
Posts: 11

View user's profile Send private message

Err0040: The target device is not ready for debugging.
PostPosted: Thu May 05, 2016 4:28 am     Reply with quote

Hi !

So first of all, I'm new in C language and in electronic in general. And I don't have the best english, so sorry in advance if some sentences are not really understandable !

I'm working on a pic24FJ128GB106 with CCS compiler (MPLAB ICD3).

I am developping a project where I use this PIC but I got this error because I kinda destroy my previous pic (I didn't realized first, but I send signals in 24V :s, so I burnt the pic and all the logic gates). So I changed my pic and all the gates. My hardware is good. My pic is detected. But when I tried to use in debug mode, I can't compile my code and i got this error:

Err0040: The target device is not ready for debugging. Please check your configuration bit settings and program the device before proceeding.

But this code was working with my previous pic. i didn't change the ICD. i kept the same FUSES. The MCLR seems to work. But I still get this error. But the weirdest thing is I can program my code. The pic is working in program mode but in debug mode, MPLAB refuse to work.

Also, one of my problem were I couldn't get my oscillator 10MHz working with pll * 4 (to get a clock=40MHz) so I use FRC with pll to get 32MHz. But now, with new pic, it seems that this is the quartz which is working at 10MHz.

Here is a part of my code (where I define the fuses ...) (all comments are in french because I am, so sorry if you can't understand ^^ if you need to know what is it about, I'll give you the translations):
Code:

#include <24FJ256GB106.h> // last pic was a 256GB instead of 128GB but I don't think it changes smthg
#DEVICE ICD = 2
#FUSES FRC_PLL,PLL2,XT,NOIOL1WAY,NOPROTECT,NOWDT,NOWRT,NOOSCIO
//,SOSC, //Liste des Fuses dispo dans le header

#USE delay(clock=10000000) //Quartz de 10MHZ

// Remappage des pins

//========================Selection des pins==================================

#PIN_SELECT U1RX = PIN_D2
#pin_select U1TX = PIN_D1
#pin_select U2RX = PIN_D5
#pin_select U2TX = PIN_D4
#pin_select U3TX = PIN_D11
#pin_select U3RX = PIN_D8

#pin_select IC1   = PIN_B9 // pin pour interruption calcul vitesse ==> à remplacer par G9
#pin_select T1CK = PIN_C14 // pin pour interruption timer3 (quartz 32k) (décompte toutes les secondes)

#use RS232(BAUD=57600, UART1, STREAM = VarAdapt)
#use RS232(BAUD=57600, UART2, STREAM = ComAdapt)
#use RS232(BAUD=57600, UART3, STREAM = TdbAdapt)
#use i2c(master, SDA=PIN_D9, SCL=PIN_D10)

#include <24FJ256GB106_comp.h>
#include <Variables_adaptative.c>
#include <Programme_I2C_GPS.c>
#include <Protocole_UART_adaptative.c>
#include <Fonctions_annexes_adaptative.c>
#include <Interruptions.c>
 
void main(){
   //Initialisation des variables
   led_pic = 0;
   ledPulseVitesse = 0;
   perimetre_roue = 0.484;

   VarTabTDB[0]=1;
   VarTabTDB[1]=2;
   VarTabTDB[2]=3;
   VarTabTDB[3]=4;
   VarTabTDB[4]=5;
   VarTabTDB[5]=6;
   VarTabTDB[6]=7;
   VarTabTDB[7]=8;
         
            //5432109876543210
   SET_TRIS_B(0b0000001010000111);
   SET_TRIS_C(0b0011000000000000);
   SET_TRIS_D(0b0000000000100100); //pour le moment juste par rapport au GPS
   SET_TRIS_E(0b0000000011000000);
   SET_TRIS_F(0b0000000000000000);
   SET_TRIS_G(0b0000000001000000);
   
//Switch de la FPR à l'oscillateur externe
   CLKDIV=0; //used before to be sure that I get 32MHz

   latb=0;
   latc=0;

   //Activation resistance de pull-up ======> A eviter l'année prochaine, préferer pull-up "externe"
   BIT_SET(CNPU1,8); //Pull-up pour le bouton patate
   BIT_SET(CNPU1,3); //Pull-up pour le bouton patate2
   BIT_SET(CNPU1,2); //Pull-up pour le bouton Start-Stop
   BIT_SET(CNPU5,65);   //Pull-up pour le switch Auto-Manu

   // Définition des différents timers
   SETUP_TIMER1(TMR_INTERNAL|TMR_DIV_BY_256); // ==> timer seconde
   PR1 = 62500;
//   T1SYNC = 1;   
//   SOSCEN = 1;

   SETUP_TIMER3(TMR_INTERNAL|TMR_DIV_BY_64);// ==> timer 200ms
   PR3 = 50000;

   // Définition des interrupt capture
   SETUP_CAPTURE(1, CAPTURE_RE | INTERRUPT_EVERY_CAPTURE | CAPTURE_TIMER1 | CAPTURE_HALT_IDLE); //pour l'interruption liée au capteur vitesse.

   //Activation des interruptions
   ENABLE_INTERRUPTS(INT_TIMER1);
//   DISABLE_INTERRUPTS(INT_TIMER3);
   ENABLE_INTERRUPTS(INT_IC1);
//   DISABLE_INTERRUPTS(INT_EXT1);
   DISABLE_INTERRUPTS(INT_RDA);
   DISABLE_INTERRUPTS(INT_RDA2);
   ENABLE_INTERRUPTS(INTR_GLOBAL);

Thanks in advance if you have any idea or advice about this. If you have any need because I was not clear about some explanations or you need any details, don't hesitate asking me !
Ttelmah



Joined: 11 Mar 2010
Posts: 19520

View user's profile Send private message

PostPosted: Thu May 05, 2016 9:12 am     Reply with quote

DEBUG fuse.

Selecting ICD=x, only specifies which pins the ICD is to use. Doesn't actually put it into DEBUG mode.
Geows



Joined: 05 May 2016
Posts: 11

View user's profile Send private message

PostPosted: Thu May 05, 2016 9:24 am     Reply with quote

Thanks for the answer.
So I tried but it doesn't change anything :/
Ttelmah



Joined: 11 Mar 2010
Posts: 19520

View user's profile Send private message

PostPosted: Fri May 06, 2016 2:03 am     Reply with quote

Are you _sure_ you are actually connecting to the second port?.
The normal reason for this is that the actual connections and the port selected don't match.
Geows



Joined: 05 May 2016
Posts: 11

View user's profile Send private message

PostPosted: Fri May 06, 2016 7:33 am     Reply with quote

Yes I'm sure ! Actually, if I hadn't the good port I think I wouldn't be able to program my pic. But since it is working (and I check my board) it is not the problem.
Ttelmah



Joined: 11 Mar 2010
Posts: 19520

View user's profile Send private message

PostPosted: Fri May 06, 2016 2:04 pm     Reply with quote

Not quite.

Programming and ICD are different internally in the chip. Think about it, you can program the chip _before_ it has been given an ICD=x line.
The MCLR line actually triggers the programming mode, and this then uses whichever lines the data is arriving on.

ICD=X, requires the correct pins are used for the ICD.

Your error is exactly what you would get, if you were not on the correct ICD pin pair. Might not even be your fault. I have seen chips in the past, where the pair the data sheet lists as ICD1, are actually ICD2, and vice versa. Not a CCS fault, since it behaved the same through MPLAB....
Geows



Joined: 05 May 2016
Posts: 11

View user's profile Send private message

PostPosted: Mon May 09, 2016 3:01 am     Reply with quote

Ok I understand.

So I change the ICD pins to 1 and 3 and it didn't change anything :/.
Before posting this topic, I checked some older topic and I saw it could happen if my clock didn't have the good value.
As I said before, with my previous pic I used the frc with a pll to get 32MHz (because I couldn't get 40MHz with my 10MHz quartz and a pll).
But now when I'm using programming my led will change of state(at each second with a delay) only for 10MHz.
So could it be the reason why the ICD doesn't work ?

And another thing weird to me is that in the configuration bits window, the value are not the one I indicated with my fuses. So, I think that the pic doesn't get any of my fuses ?
What do you think about this ?
Ttelmah



Joined: 11 Mar 2010
Posts: 19520

View user's profile Send private message

PostPosted: Mon May 09, 2016 3:42 am     Reply with quote

When you are programming for ICD, quite a few fuses are 'overridden'. So (for instance), the ICD does not support the WDT, so any WDT fuse will be disabled. This applies to several fuses.

Clock rate though suggests something further is wrong.

Can you change your crystal to 8MHz?.

On your chip, you have the 96MHz PLL block, which requires an input at 4MHz. This (of course) cannot be derived by integer division from 10MHz....
The maximum CPU frequency supported is 32MHz.

Your fuses and clock settings do not match. You have two different oscillators selected at once.

Either use:
Code:

//With an 8MHz crystal

#FUSES HSPLL, PLL2, NOIOL1WAY, NOPROTECT, NOWDT, NOWRT
#USE delay(crystal=8MHz, clock=32Mhz, USB_FULL)


Or:
Code:


#FUSES FRC_PLL PLL2, NOIOL1WAY, NOPROTECT, NOWDT, NOWRT, NOOSCIO
#USE delay(internal=8MHz, clock=32Mhz)


Be aware that on your chip, USB is not supported using the internal oscillator:
"While the FRCPLL Oscillator mode is available in
these devices, it should never be used for USB
applications. FRCPLL mode is still available when
the application is not using the USB module. However,
the user must always ensure that the FRC
source is configured to provide a frequency of
4 MHz or 8 MHz (RCDIV<2:0> = 001 or 000) and
that the USB PLL prescaler is configured
appropriately."

Seems rather pointless to be using a USB chip without USB...

Microchip are very specific, that you have to manually ensure the FRC module is set to the right rate, and the correct divider used.
Geows



Joined: 05 May 2016
Posts: 11

View user's profile Send private message

PostPosted: Mon May 09, 2016 10:02 am     Reply with quote

Yes, that's what I was thinking too ! I have a 10MHz quartz because I thought I could do it anyway (but I was wrong) (in some pic, you can do this way to get a 40MHz but not on this one).

So since it is a prototype I didn't change it and I don't have a 8MHz quartz with me right now. That's also why I was using the FRCPLL with my previous pic and it was working well.

But as it is said in the datasheet, the FRC is the default selection, so I thought it wouldn't have been a problem...

Because in my configuration bits window I have :
Primary oscillator disabled
Oscillator select : Fast RC OScillator Postscaler (FRCDIV)
PLLDIV : Oscillator input divided by 12 (48MHz input)

which seem very wrong.

I rechecked the datasheet and it seems it is the default configuration (even if I put pll2 in my fuses)

And I forgot to say but I am not using any USB tool, so I can use the FRCPLL according to the datasheet.

And to finish, I tried with your fuses and it still doesn't work :/
Ttelmah



Joined: 11 Mar 2010
Posts: 19520

View user's profile Send private message

PostPosted: Mon May 09, 2016 10:18 am     Reply with quote

You need to work out why you can't program the fuses.

Have you got automatic erase selected?. Probably needed.

Obviously the fuses won't work if they are not being written.... Sad

Generally most of the USB PIC's, need a master oscillator that is a multiple of 4MHz.
Ttelmah



Joined: 11 Mar 2010
Posts: 19520

View user's profile Send private message

PostPosted: Mon May 09, 2016 10:44 am     Reply with quote

You will probably be running at 8MHz.

FRCDIV, is the input to the clock multiplexer, directly from the FRC source (with divider), not the PLL output. The divider for this is defaulting to 111, so 8MHz.

I'd be looking in detail at section 2.5.

I'd honestly suspect you have connection problems (possibly capacitance, or pull-ups on the ICD pins). You need to get the chip fully programming, before ICD has any hope of working.
Ttelmah



Joined: 11 Mar 2010
Posts: 19520

View user's profile Send private message

PostPosted: Mon May 09, 2016 1:54 pm     Reply with quote

Post your circuit, and what the previous PIC actually was.
What is your actual supply voltage?.

Everything is saying you are not actually successfully programming the chip completely.
Entering ICD, requires that the ICD director, is programmed into part of the chip. This is failing. Together with your fuses not changing, something is radically wrong with the programming.

Was the programmer connected when you destroyed the other chip?....
Geows



Joined: 05 May 2016
Posts: 11

View user's profile Send private message

PostPosted: Wed May 11, 2016 12:58 am     Reply with quote

My previous pic was a pic24FJ256GB106. It's the same model, with more memory.

I'm not sure the icd programmer was connected when i destroyed it. But I have different ICD programmer and it doesn't work with any of them so I don't think the problem is the ICD3.

If you want to have access to the schematic of my board, there it is :
https://mega.nz/#!BcgghLLY!5plNcLGUO78lTYFIyYey9mfdOCIzmczyLsX3rxYK4fY

(It is just the schematic not the pcb. If you want it, tell me and i'll add it but with this schematic you can have all the informations I think)

And the supply voltage is 3.3V. I actually have 24V coming into a tsr1-2433 which change it into 3.3V.
Ttelmah



Joined: 11 Mar 2010
Posts: 19520

View user's profile Send private message

PostPosted: Wed May 11, 2016 1:11 am     Reply with quote

Unfortunately the link gives a server exception error when you try to access it.
Geows



Joined: 05 May 2016
Posts: 11

View user's profile Send private message

PostPosted: Wed May 11, 2016 1:23 am     Reply with quote

Try with this : https://www.dropbox.com/s/9xrusm5a5fl2lu1/Carte_adaptative_V6%20-%20Project.pdf?dl=0
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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