ICDWarn0020: Invalid target device id (expected=0x4F, read=0x0)


Closed Thread
Results 1 to 9 of 9
  1. #1
    Join Date
    May 2007
    Posts
    21

    Default ICDWarn0020: Invalid target device id (expected=0x4F, read=0x0)

    Hi all,

    I'm trying to program 18f4550, using MPLAB ICD2. I successfully compiled several timesat beforehand (with the same board design!!!).But this time something strange happened. This is really killing me, because I tried to solve the problem for last 4 hours and nothing changed. An error message keeps appearing when I try to compile with ICD2.
    ICDWarn0020: Invalid target device id (expected=0x4F, read=0x0)
    Does it mean my PIC is dead?
    I'm using same devices, same board design.
    Power is supplied to the board. Therefore I assume there is no failure in the connection.

    Does this message appear when there is only hardware failures?

    Best Regards

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    I can't told you, mine have been used 4-5 times and worked... so it's still like a brand new one... but with few years of dust gathering...

    i would guess of a bad cable, or poor MCLR voltage while programming. Should be 'round 13 volts.

    EDIT: make sure you don't load PGD,PGC pins too much.
    Last edited by mister_e; - 11th June 2007 at 23:39.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    May 2007
    Posts
    21


    Did you find this post helpful? Yes | No

    Default thanks

    I'm really tired right now. It still does not work... I will continue with it tomorrow. Just bored right know.
    And also for the interested ones, I'm trying to write my second picbasic code. I thought it would be easy. It is not. I'm mixed up. I will post the code here, and actually it is nothing. I would really appreciate any help.

    I was using this code in C, where I had an ADC header file. Now I 'm surt of trying to convert it to Picbasic.

    'Aim: to use adc bits as inputs, apply sinusoidal input and
    'upgrade the blink project a little further. The next step is going to
    'be using interrupt.

    DEFINE LOADER_USED 1
    DEFINE RESET_ORG 800H

    OpenADC(ADC_FOSC_32&ADC_RRIGHT_JUST&ADC_12_TAD,ADC _CH0&ADC_INT_OFF,0)
    ' I do not really know how to activate ADC, and use it. The above one
    'is actually a c code.

    Outvalue var PORTD.0

    Outvalue= %0 'Set PORTD.0 output
    TRISA = %11111111 ' Set PORTA to all input, so I can use ADC
    ' bits as input
    ADCON1 = %10000010' Set PORTA analog and right justify result


    SetChanneltoADC(ADC_CHO) ' Want to set channel 0

    ConvertADC() 'Convert the ADC value


    while (Busy adc()) ' while it is busy keep it in a loop



    ' adc_'result=Read ADC() 'I used ADCIN 0, adcresult

    adc_result var word ' Create adc_'result to store result

    Pause 500 ' Wait .5 second

    ADCIN 0, adcresult ' Read channel 0 to adcresult

    loop:if adcresult> 125 ' I thought if it is 8 bits
    '2^8=256
    Outvalue =! Outvalue

    Pause 100 ' Wait .1 second
    Goto loop ' Do it forever
    End

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by kutsi View Post
    OpenADC(ADC_FOSC_32&ADC_RRIGHT_JUST&ADC_12_TAD,ADC _CH0&ADC_INT_OFF,0)
    Yes, that is C, but if you inspect the A/D converter section of whatever PIC you are planning to use, you'll recognize most of those bits and pieces of the C code, therefore, you'll be able to convert your program from C to PBP...

    For instance...
    ADC_FOsc32 - base ADC timing on FOSC/32
    ADC_Right_Just - right justify the result...and so on and so on...

    SetChanneltoADC(ADC_CHO) ' Want to set channel 0
    ConvertADC() 'Convert the ADC value
    while (Busy adc()) ' while it is busy keep it in a loop
    ' adc_'result=Read ADC() 'I used ADCIN 0, adcresult
    Same thing here. You're on the right track, just gotta look a bit harder at the datasheets, PBP manual, etc.

    Converting C to PBP isn't all that hard. You just have to know what (or which PIC) you're dealing with fairly well.
    Once you've learned one PIC, you've practically learned them all...

  5. #5
    Join Date
    May 2007
    Posts
    21


    Did you find this post helpful? Yes | No

    Default New code, interrupt

    'Aim: to use adc bits as inputs, apply sinusoidal input and
    'upgrade the blink project a little further. The next step is going to
    'be using interrupt.


    'OpenADC(ADC_FOSC_32&ADC_RRIGHT_JUST&ADC_12_TAD,AD C_CH0&ADC_INT_OFF,0)
    ' I do not really know how to activate ADC, and use it. The above one
    'is actually a c code.


    Define ADC_BITS 8 ' Set number of bits in result
    Define ADC_CLOCK 3 ' Set clock source (3=rc)
    Define ADC_SAMPLEUS 50 ' Set sampling time in uS

    ADC_intstatus var PortB.0

    On Interrupt Goto ADC_interrupt

    INTCON=%10010000 ' Enable RBO interrupt

    Outvalue var PORTD.0
    adc_result var word ' Create adc_'result to store result

    Outvalue= 0 'Set PORTD.0 output
    TRISA = %11111111 'Set PORTA to all input, so I can use ADC
    ' bits as input
    ADCON1 = %10000010' Set PORTA analog and right justify result

    DISABLE
    ADC_interrupt:

    Pause 500 ' Wait .5 second while (Busy adc()) ' while it is busy keep it in a loop

    ADCIN 0, adc_result ' Read channel 0 to adcresult

    if adc_result> 125 then Outvalue =! Outvalue ' I thought if it is 8 bits, then 2^8=256


    RESUME
    ENABLE

    End



    Thanks for the comments, Skimask. I was busy studying as u suggested. It is the reason for the late reply. This is the new code, with 'interrupt' in it.

    My pic is dead, I've ordered a new one. I cannot try it right now.

    I'm working with PIC18F4550. Want to use A/D pins as inputs, and make PORTD.0 to blink led.

  6. #6
    Join Date
    May 2007
    Posts
    21


    Did you find this post helpful? Yes | No

    Default

    actually I tried to debug it with the simulation.

    CORE-E0002: Stack under flow error occurred from instruction at 0x0000c4

    Can someone help me on the code?

  7. #7
    Join Date
    May 2007
    Posts
    21


    Did you find this post helpful? Yes | No

    Default for starters !!!

    if u want to test your (interrupt)code without connecting an external device, you should not forget to create your own interrupt. At least, it was enough to solve my problem. the easiest way ;
    -initiate PORTB <7:4>=0
    -when u want to create interrupt set PORTB<7:4>=1

    Did I start answering my own questions or what?


    best regards

  8. #8
    Join Date
    Apr 2006
    Location
    New Hampshire USA
    Posts
    298


    Did you find this post helpful? Yes | No

    Smile Yahoo Questons asked - Questions Answered....

    Quote Originally Posted by kutsi View Post
    Did I start answering my own questions or what?
    best regards
    Wow kutsi,
    It doesn’t get any better than asking a question, learning, and answering your own question.
    Great! Just don’t get into a flame war argument with yourself. That’s the worst.
    -Adam-
    Ohm it's not just a good idea... it's the LAW !

  9. #9
    Nonsoezeoke's Avatar
    Nonsoezeoke Guest


    Did you find this post helpful? Yes | No

    Question ICDWarn0020: Invalid target device id (expected=0x4F, read=0x0)

    Hello

    was wondering if Kutsi's issue has been sorted or someone else has any idea on how to sort out the vexing ICDWarn0020: Invalid target device id (expected=0x21, read=0x3E)? Thats what i see on the PicDem4 Demo board. I'm trying to simulate a USART transfer but dont know what PIC18f variant came with the board. It says P18PDEM4_DEMO.

    Been at this all day.

    Any help please?

Similar Threads

  1. ICDWarn0020: Invalid target device id
    By pravec065 in forum General
    Replies: 3
    Last Post: - 4th August 2008, 13:43
  2. Target device does not match
    By krohtech in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 2nd February 2008, 04:20
  3. PIC18F4620 not Target Device
    By kiwipiper in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 17th October 2007, 19:42
  4. Target device <> Selected Device????
    By deepgfishing in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 20th June 2007, 21:18
  5. @ Device Parameters
    By Randy_Suwanee in forum General
    Replies: 2
    Last Post: - 11th August 2004, 14:40

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts