Forum: Mikrocontroller und Digitale Elektronik PIC18+Olimex - Debuggen?


von Microman (Gast)


Lesenswert?

Hello,

ich nutze derzeit einen Olimex PIC Kit 3 Dongle zum 
Programmieren/Debuggen lernen mit Pics.

Ich bin mal sanft eingestiegen, Schaltung ist erstmal nebensächlich. Auf 
einem Steckbrett habe ich einen 4Mhz Xtal Oszillator (GND und 5V 
angeschlossen, output an den PIC-OSC1 Pin) an meinem PIC18F248. Dazu 
noch MCLR mit 10K gegen 5V gezogen und den Debugger wie beschrieben 
angeschlossen.
An RA0 hängt eine LED mit vorwiderstand.

Einfacher Test, LED an/aus mit der internen Delayfunktion - geht prima.

Nun mit Timer weitergemacht, aber hier habe ich Probleme. Egal, ich 
wollte mal debuggen, aber ich bekomme immer:

"Programming/Verify complete
The target device is not ready for debugging. Please check your 
configuration bit settings and program the device before proceeding. The 
most common causes for this failure are oscillator and/or PGC/PGD 
settings."

Hier mal mein Minicode:
1
#include <pic18f248.h>
2
#include <xc.h>
3
#include "functions.h"
4
#include <stdio.h>
5
6
// CONFIG1H
7
#pragma config OSC = EC         // Oscillator Selection bits (EC oscillator w/ OSC2 configured as divide-by-4 clock output)
8
9
void Switch_LED(int i) {
10
    if (i == 0)
11
        LATA0 = 0;
12
    else if (i == 1)
13
        LATA0 = 1;
14
}
15
16
void main(void) {
17
    TRISAbits.RA0 = 0; //LED Pin als Ausgang schalten
18
    
19
while(1)
20
  {
21
    Switch_LED(1);
22
    __delay_ms(50);
23
    Switch_LED(0);
24
    __delay_ms(50);
25
  }//end while
26
}

Was mache ich falsch?

Grüße

von Microman (Gast)


Angehängte Dateien:

Lesenswert?

Hier übrigens noch eine Meldung, die kommt, wenn ich Debuggen will.

Wenn ich ja klicke kommt obige Meldung, bei nein kommt:
"The requested operation cannot continue with the following 
configuration bit setting(s):

Watchdog Timer Enable bit = On
Data EEPROM Write Protection bit = Data EEPROM write protected
Table Read Protection bit = Block 0 (000200-001FFFh) protected from 
Table Reads executed in other blocks
Table Read Protection bit = Block 1 (002000-003FFFh) protected from 
Table Reads executed in other blocks

Please fix the setting(s) and try the operation again.
Failed to program device"

von Max H. (hartl192)


Angehängte Dateien:

Lesenswert?

Microman schrieb:
> // CONFIG1H
> #pragma config OSC = EC         // Oscillator Selection bits (EC
> oscillator w/ OSC2 configured as divide-by-4 clock output)
Die configs sind ein bisschen schwach...

Stell mal bei allen Configs (wo, siehe Anhang) etwas Sinnvolles ein und 
exportiere es in den Quellcode.

von Microman (Gast)


Lesenswert?

1
// CONFIG1H
2
#pragma config OSC = EC         // Oscillator Selection bits (EC oscillator w/ OSC2 configured as divide-by-4 clock output)
3
#pragma config OSCS = OFF       // Oscillator System Clock Switch Enable bit (Oscillator system clock switch option is disabled (main oscillator is source))
4
5
// CONFIG2L
6
#pragma config PWRT = OFF       // Power-up Timer Enable bit (PWRT disabled)
7
#pragma config BOR = ON         // Brown-out Reset Enable bit (Brown-out Reset enabled)
8
#pragma config BORV = 25        // Brown-out Reset Voltage bits (VBOR set to 2.5V)
9
10
// CONFIG2H
11
#pragma config WDT = ON         // Watchdog Timer Enable bit (WDT enabled)
12
#pragma config WDTPS = 128      // Watchdog Timer Postscale Select bits (1:128)
13
14
// CONFIG4L
15
#pragma config STVR = ON        // Stack Full/Underflow Reset Enable bit (Stack Full/Underflow will cause Reset)
16
#pragma config LVP = ON         // Low-Voltage ICSP Enable bit (Low-Voltage ICSP enabled)
17
18
// CONFIG5L
19
#pragma config CP0 = OFF        // Code Protection bit (Block 0 (000200-001FFFh) not code protected)
20
#pragma config CP1 = OFF        // Code Protection bit (Block 1 (002000-003FFFh) not code protected)
21
22
// CONFIG5H
23
#pragma config CPB = OFF        // Boot Block Code Protection bit (Boot Block (000000-0001FFh) not code protected)
24
#pragma config CPD = OFF        // Data EEPROM Code Protection bit (Data EEPROM not code protected)
25
26
// CONFIG6L
27
#pragma config WRT0 = OFF       // Write Protection bit (Block 0 (000200-001FFFh) not write protected)
28
#pragma config WRT1 = OFF       // Write Protection bit (Block 1 (002000-003FFFh) not write protected)
29
30
// CONFIG6H
31
#pragma config WRTC = OFF       // Configuration Register Write Protection bit (Configuration registers (300000-3000FFh) not write protected)
32
#pragma config WRTB = OFF       // Boot Block Write Protection bit (Boot Block (000000-0001FFh) not write protected)
33
#pragma config WRTD = OFF       // Data EEPROM Write Protection bit (Data EEPROM not write protected)
34
35
// CONFIG7L
36
#pragma config EBTR0 = OFF      // Table Read Protection bit (Block 0 (000200-001FFFh) not protected from Table Reads executed in other blocks)
37
#pragma config EBTR1 = OFF      // Table Read Protection bit (Block 1 (002000-003FFFh) not protected from Table Reads executed in other blocks)
38
39
// CONFIG7H
40
#pragma config EBTRB = OFF      // Boot Block Table Read Protection bit (Boot Block (000000-0001FFh) not protected from Table Reads executed in other blocks)

Alles richtig so? Er bringt mir aber immernoch die Fehlermeldung aus 
Post 2...

von Max H. (hartl192)


Lesenswert?

Microman schrieb:
> #pragma config WDT = ON         // Watchdog Timer Enable bit (WDT
> enabled)

Der WDT ist noch an.

von Microman (Gast)


Lesenswert?

Ach mist. Ja habe ich geändert.

Nun ist in der Meldung die erste Zeile mit dem WDT verschwunden, die 
anderen drei habe ich immernoch, egal ob ich WRTD/WRT0/WRT1/CPD auf ON 
oder OFF setze :(

von Microman (Gast)


Lesenswert?

Mh lustig, wenn ich "#pragma config OSC = EC" auskommentiere, geht das 
LED geblinke immernoch.

Eventuell geht der Oszillator nicht? Kann ich das ohne Oszi irgendwie 
testen?

Grüße & DANKE!

von Microman (Gast)


Lesenswert?

//PS: Wenn ich aber den Quarzoszillator rausziehe, bleibt das blinken 
stehen. Irgendwas geht also schon...

von Microman (Gast)


Lesenswert?

Keine Ideen?

von Microman (Gast)


Lesenswert?

//Kurze Lösung: Keine.
Arbeite jetzt mit dem mMn sowieso viel handlicheren C18 und da gehts 
einwandfrei.

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.