PIC 18F452 programmieren mit dem PicKit 3

Gast #2055570
Lesenswert?

Nachdem ich letzte Woche den Neuen PicKit 3 Brenner bekam, testete ich 
gestern den Brenner. Nach einigen Anlaufschwierigkeiten funktionierte 
die LED-Pwm-Schaltung (Daten von 
http://www.sprut.de/electronic/pic/grund/pwm.htm und 
http://www.reichelt.de/?;ACTION=28;LA=3;ARTICLE=58077;GROUPID=2968;GROUP=A3668;SID=40TUlVRX8AAAIAADIrlFMbb6f065a9a68166353526d0a3fdd795a). 
Nachdem ich den PIC gebrannt hatte schloss ich das Programmiergerät ab. 
Heute wollte ich weiter arbeiten, doch ich kann den PIC einfach nicht 
mehr debugen. Ich konnte das aktuele Programm zwar herunterlöschen, doch 
beim debugen kommt immer folgender Fehler im Outputfenster:
1
The target device is not ready for debugging.
2
Please check your configuration bit settings and program
3
the device before proceeding.

Foto mit Aufbau im Anhang.
Und hier noch der Programmcode:
1
#include <p18f452.h>
2
#include <delays.h>
3

4
#pragma CONFIG FOSC   = HS      // Taktbereich
5
#pragma CONFIG PWRT   = OFF      // Power On Timer
6
#pragma CONFIG BOR    = ON      // BrownOut Detect
7
#pragma CONFIG BODEN  = ON      // BrownOut Detect
8
#pragma CONFIG BODENV = 4.5V    // BrownOut Voltage
9
#pragma CONFIG WDT    = OFF      // Watchdog Timer
10
#pragma CONFIG LVP    = OFF      // Low Voltage programming
11
#pragma CONFIG STVR   = OFF      // Stack Overfow Reset
12
#pragma CONFIG MCLRE  = OFF      // Master Clear Reset
13
#pragma CONFIG PBAGEN = OFF  
14
#pragma CONFIG VREGEN = OFF      
15

16
void main()
17
{
18
  unsigned char Z1; 
19

20
  TRISD = 0x00;
21
  TRISC = 0x00;
22
  
23
  Z1 = 0x00;
24

25
  T2CONbits.T2CKPS1 = 0;
26
  T2CONbits.T2CKPS0 = 0;
27
  T2CONbits.TMR2ON = 1;
28

29
  PR2 = 0xFF;
30
  CCPR1L = 0x00;
31

32
  CCP1CON = 0x00;
33
  CCP1CONbits.CCP1M3 = 1;
34
  CCP1CONbits.CCP1M2 = 1; 
35

36
  while (1)
37
  {
38
    CCPR1L = Z1;
39
    Delay1KTCYx(25);
40
    if (Z1 < 0xFF)
41
    {
42
      Z1++;
43
    }
44
    else
45
    {
46
      Z1 = 0x00;
47
    }
48
  }
49
}

Ich weiß beim besten Willen nicht was ich falsch gemacht habe! 
Schlieslich hat es gestern funktioniert.

Ich hoffe hier weiß jemand Rat...
Vielen Dank für produktive Beiträge im voraus...
Angehängte Dateien:
Gast #2055596
Lesenswert?

Die PGD- und PGC-Leitungen sind bei den PICs sehr empfindlich, lege die 
mal nicht über die Zwischenstation des Breadboards, sondern direkt an 
das PICKIT. Evtl. sind PGD und PGC auch vertauscht, das kann man auf dem 
Photo nicht richtig sehen.

Und Quarz + Lastkondensatoren hast Du nicht optimal angebracht, diese 
sowie den 10 kOhm Widerstand brauchst Du zum Programmieren auch nicht, 
nur für den Betrieb.
Gast #2055636
Lesenswert?

Habe den 10kΩ Wiederstand herausgezogen und die Drähte von PGD und PGC 
direkt angeschlossen.

Außer dem habe ich es nochmal probiert es kommen folgende 
Meldungen\Texte:
1
PICkit 3 detected
2
Connecting to PICkit 3...
3
Firmware Suite Version...... 01.26.17
4
Firmware type......................PIC18F
5
PICkit 3 Connected.
6
Target Detected
7

8
CAUTION: Check that the device selected in MPLAB IDE (PIC18F452)
9
is the same one that is physically attached to the debug
10
tool. Selecting a 5V device when a 3.3V device is connected
11
can result in damage to the device when the debugger checks
12
the device ID.
13
Device ID Revision = 00000007
14

15
----------------------------------------------------------------------
16
Debug build of project `C:\xxx\PICs\ErstesProjekt\Proj1.mcp' started.
17
Language tool versions: mpasmwin.exe v5.40, mplink.exe v4.38, mcc18.exe v3.37.01, mplib.exe v4.38
18
Preprocessor symbol `__DEBUG' is defined.
19
Target debug platform is `__MPLAB_DEBUGGER_PK3=1'.
20
Debug platform options are: `__ICD2RAM=1'.
21
Wed Feb 09 17:37:06 2011
22
----------------------------------------------------------------------
23
Clean: Deleting intermediary and output files.
24
Clean: Deleted file "C:\xxx\PICs\ErstesProjekt\Main.o".
25
Clean: Deleted file "C:\xxx\PICs\ErstesProjekt\Proj1.cof".
26
Clean: Deleted file "C:\xxx\PICs\ErstesProjekt\Proj1.hex".
27
Clean: Deleted file "C:\xxx\PICs\ErstesProjekt\Proj1.mcs".
28
Clean: Done.
29
Executing: "C:\Program Files\Microchip\MPL 18\bin\mcc18.exe" -p=18F452 "Main.c" -fo="Main.o" -D__DEBUG -D__MPLAB_DEBUGGER_PK3=1 -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa-
30
C:\xxx\PICs\ErstesProjekt\Main.c:4:Warning [2002] unknown pragma 'CONFIG'
31
C:\xxx\PICs\ErstesProjekt\Main.c:5:Warning [2002] unknown pragma 'CONFIG'
32
C:\xxx\PICs\ErstesProjekt\Main.c:6:Warning [2002] unknown pragma 'CONFIG'
33
C:\xxx\PICs\ErstesProjekt\Main.c:7:Warning [2002] unknown pragma 'CONFIG'
34
C:\xxx\PICs\ErstesProjekt\Main.c:8:Warning [2002] unknown pragma 'CONFIG'
35
C:\xxx\PICs\ErstesProjekt\Main.c:9:Warning [2002] unknown pragma 'CONFIG'
36
C:\xxx\PICs\ErstesProjekt\Main.c:10:Warning [2002] unknown pragma 'CONFIG'
37
C:\xxx\PICs\ErstesProjekt\Main.c:11:Warning [2002] unknown pragma 'CONFIG'
38
C:\xxx\PICs\ErstesProjekt\Main.c:12:Warning [2002] unknown pragma 'CONFIG'
39
C:\xxx\PICs\ErstesProjekt\Main.c:13:Warning [2002] unknown pragma 'CONFIG'
40
C:\xxx\PICs\ErstesProjekt\Main.c:14:Warning [2002] unknown pragma 'CONFIG'
41
Executing: "C:\Program Files\Microchip\MPL 18\bin\mplink.exe" /p18F452 /l"C:\Program Files\Microchip\MPL 18\lib" "Main.o" /u_CRUNTIME /u_DEBUG /u_DEBUGCODESTART=0x7dc0 /u_DEBUGCODELEN=0x240 /u_DEBUGDATASTART=0x5f4 /u_DEBUGDATALEN=0xc /z__MPLAB_BUILD=1 /z__MPLAB_DEBUG=1 /z__MPLAB_DEBUGGER_PK3=1 /z__ICD2RAM=1 /o"Proj1.cof" /M"Proj1.map" /W
42
MPLINK 4.38, Linker
43
Copyright (c) 1998-2010 Microchip Technology Inc.
44
Errors    : 0
45

46
MP2HEX 4.38, COFF to HEX File Converter
47
Copyright (c) 1998-2010 Microchip Technology Inc.
48
Errors    : 0
49

50
Loaded C:\xxx\PICs\ErstesProjekt\Proj1.cof.
51
----------------------------------------------------------------------
52
Debug build of project `C:\xxx\PICs\ErstesProjekt\Proj1.mcp' succeeded.
53
Language tool versions: mpasmwin.exe v5.40, mplink.exe v4.38, mcc18.exe v3.37.01, mplib.exe v4.38
54
Preprocessor symbol `__DEBUG' is defined.
55
Target debug platform is `__MPLAB_DEBUGGER_PK3=1'.
56
Debug platform options are: `__ICD2RAM=1'.
57
Wed Feb 09 17:37:09 2011
58
----------------------------------------------------------------------
59
BUILD SUCCEEDED
60

61
---------------------------
62
Configuration Bits Conflict
63
---------------------------
64
PICkit 3 cannot debug while the following configuration settings are enabled:
65

66
- Low Voltage Program
67
- Watchdog Timer
68

69
Would you like PICkit 3 to turn off these settings and continue programming?
70
---------------------------
71
OK   Abbrechen   
72
---------------------------
73

74
Resetting...
75
PK3Err0040: The target device is not ready for debugging.
76
Please check your configuration bit settings and program
77
the device before proceeding.
78

79
Programming...
80
Programming/Verify complete
81

82
Running...
83
PK3Err0040: The target device is not ready for debugging.
84
Please check your configuration bit settings and program
85
the device before proceeding.

Wieso sagt der Compiler immer "unknown pragma"? Ich habe alles so 
gemacht wie hier beschrieben:
http://pic-projekte.de/pic_c.html

Und übrigens, ich benutze MBLab und habe den Debuger richig eingestelt!
Gast #2055683
Lesenswert?

...This addendum lists the configuration settings available for each of 
the PIC18 devices
for use with MPLAB® C18's #pragma config directive and MPASM™ 
assembler's
CONFIG directive....

hab ich aus einer PDF, probier mal config klein zu schreiben.
Gast #2055690
Lesenswert?

"#pragma DATA _CONFIG, _LVP_OFF" funktioniert leider auch nicht!


Mir ist jetzt aber gerade aufgefallen das ich "CONFIG" anstelle von 
"config" schrieb.
Jetzt kommen aber folgende Fehler beim Complieren:

configuration setting 'FOSC' not recognized
configuration setting 'BODEN' not recognized
configuration setting 'BODENV' not recognized
configuration setting 'MCLRE' not recognized
configuration setting 'PBAGEN' not recognized
configuration setting 'VREGEN' not recognized

Vielleicht weiß hierzu jemand Rat...
Gast #2056028
Lesenswert?

Hat keiner eine Idee?
Ein Microcontrollerexperte der mit 144-TQFP bastelt, so wie es sie hier 
durchaus gibt, müsste doch die PIC-Konfiguration ein Klaks sein?

Was meinte usuru eigentlich mit "Und Quarz + Lastkondensatoren hast Du 
nicht optimal angebracht"? Wie bringe ich den Quarz optimal an? Welcher 
Lastkondensator? Wenn er damit die blauen Keramikkondensatoren meinte, 
sind das meines Wissen "Einschwingkondensatoren".
Gast #2056208
Lesenswert?

Danke, danke jetzt geht die Konfiguration!

Doch bin ich wieder beim Ausgangspunkt. Denn die Meldung im 
Outputfenster attackiert mich weiterhin!
Meldungs Text:
1
PICkit 3 detected
2
Connecting to PICkit 3...
3
Firmware Suite Version...... 01.26.17
4
Firmware type......................PIC18F
5
PICkit 3 Connected.
6
Target Detected
7
 
8
CAUTION: Check that the device selected in MPLAB IDE (PIC18F452)
9
is the same one that is physically attached to the debug
10
tool. Selecting a 5V device when a 3.3V device is connected
11
can result in damage to the device when the debugger checks
12
the device ID.
13
 
14
Device ID Revision = 00000007
15

16
Programming...
17
Programming/Verify complete
18

19
Running...
20

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

Wenn ich nur wüßte warum das Device nicht bereit ist!
#2056313
Lesenswert?

Top 10 Reasons Why You Can't Debug (MC PICKIT3 Hilfe)

The oscillator is not working. Check your Configuration bits setting for 
the oscillator.
The target board is not powered. Check the power cable connection.
The debugger has become physically disconnected from the PC and/or the 
target board. Check the communications cables' connections.
The device is code-protected. Check your Configuration bit's setting for 
code protection.
You are trying to rebuild the project while in Release mode. Select 
Debug in the Build Configuration drop-down list on the project toolbar, 
then rebuild the project.
The debugger is selected as a programmer, and not as a debugger, in 
MPLAB IDE.
The debugger to PC communications has been interrupted. Reconnect to the 
debugger in MPLAB IDE.
The target application has become corrupted or contains errors.Try 
rebuilding and reprogramming the target application. Then initiate a 
Power-on Reset of the target.
Other configuration settings are interfering with debugging. Any 
configuration setting that would prevent the target from executing code 
will also prevent the debugger from putting the code into debug mode.
The debugger cannot always perform the action requested. For example, 
the debugger cannot set a breakpoint if the target application is 
currently running.

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren