View Full Version : ICDWarn0020: Invalid target device id (expected=0x4F, read=0x0)
kutsi
- 11th June 2007, 23:27
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
mister_e
- 11th June 2007, 23:36
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.
kutsi
- 12th June 2007, 01:34
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
skimask
- 12th June 2007, 04:23
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...
kutsi
- 12th June 2007, 22:06
'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,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.
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.
kutsi
- 13th June 2007, 00:04
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?
kutsi
- 13th June 2007, 07:44
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
Pic_User
- 13th June 2007, 14:01
Did I start answering my own questions or what? :(
best regardsWow 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.:D
-Adam-
Nonsoezeoke
- 24th April 2008, 22:19
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?
Powered by vBulletin® Version 4.1.7 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.