Forum: Mikrocontroller und Digitale Elektronik PIC 16F877 & MPLAB & PICC-lite unbekanntes Pragma


von Wolfgang T. (wolfgang_bku)


Angehängte Dateien:

Lesenswert?

Ich versuche meine ersten Schritte mit MPLAB und PICC-lite von HiTech 
mit PIC 16F877
//first77.c
#include <16F877.h>
#include <htc.h>
__IDLOC (3F31); //__config = 0x3F31
//#pragma warning disable 335
void main (void)
{
unsigned int i;
TRISD = 0;
while(1)
{
PORTD = 0x0F;
for (i=60000;i>0;i--);
PORTD = 0xF0;
for (i=60000;i>0;i--);
}
}

#pragma warning disable 335 verursacht aber Errors:
Error [715] D:\_Projekts\PIC_16F877-C\first77.c; 5. falsches pragma "n"
Error [715] D:\_Projekts\PIC_16F877-C\first77.c; 5. falsches pragma "3"
In Manual 3.10.3.9.1 habe ich keine Hilfe gefunden.

Ohne dieses pragma kommen viele Warnings:
Warning [335] D:\_Projekts\PIC_16F877-C\first77.c; 2.1 unbekanntes 
pragma "chip"
Warning [335] D:\_Projekts\PIC_16F877-C\first77.c; 2.1 unbekanntes 
pragma "PIC16F877"
Warning [335] D:\_Projekts\PIC_16F877-C\first77.c; 2.1 unbekanntes 
pragma "core"
Warning [335] D:\_Projekts\PIC_16F877-C\first77.c; 2.1 unbekanntes 
pragma "14"
...

Aber auch Compiler-Meldungen:
Executing: "C:\Programme\MPLAB\HI-TECH 
Software\PICC\LITE\9.60\bin\picl.exe" "-ofirst 16F877-c.cof" "-mfirst 
16F877-c.map" first77.obj --chip=16F877 -P --opt=none,+asm,+9 --warn=0 
--double=24 -q -g --asmlist "--errformat=Error [%n] %f; %l.%c %s" 
"--msgformat=Advisory[%n] %s" "--warnformat=Warning [%n] %f; %l.%c %s"

Memory Summary:
Program space used 24h ( 36) of 800h words ( 1.8%)
Data space used 2h ( 2) of B0h bytes ( 1.1%)
EEPROM space used 0h ( 0) of 100h bytes ( 0.0%)
Configuration bits used 0h ( 0) of 1h word ( 0.0%)
ID Location space used 4h ( 4) of 4h bytes (100.0%)

Loaded D:\_Projekts\PIC_16F877-C\first 16F877-c.cof.

ICD2 kann das hex-file in den PIC "brennen", aber das Programm läuft 
nicht.
Wenn ich in das "Disassembly Listing" schaue, dann sehe ich, dass der 
Code fehlerhaft und nicht vollständig ist (kein BCF STATUS,RP0 nach 
TRISD, keine Endlosschleife ...):

--- D:\_Projekts\PIC_16F877-C\first77.c 
--------------------------------------------------------
1: //first77.c
2: #include <16F877.h>
3: #include
4: __IDLOC (3F31); //__config = 0x3F31
5: //#pragma warning disable 335
6: void main (void)
7: {
8: unsigned int i;
9: TRISD = 0;
07DF 1683 BSF 0x3, 0x5
07E0 1303 BCF 0x3, 0x6
07E1 0188 CLRF 0x8
10: while(1)
11: {
12: PORTD = 0x0F;
07E2 300F MOVLW 0xf
07E3 1283 BCF 0x3, 0x5
07E4 0088 MOVWF 0x8
13: for (i=60000;i>0;i--);
07E5 3060 MOVLW 0x60
07E6 00A0 MOVWF 0x20
07E7 30EA MOVLW 0xea
07E8 00A1 MOVWF 0x21
07E9 08A0 MOVF 0x20, F
07EA 1903 BTFSC 0x3, 0x2
07EB 03A1 DECF 0x21, F
07EC 03A0 DECF 0x20, F
07ED 0821 MOVF 0x21, W
07EE 0420 IORWF 0x20, W
07EF 1D03 BTFSS 0x3, 0x2
07F0 2FE9 GOTO 0x7e9
14: PORTD = 0xF0;
07F1 30F0 MOVLW 0xf0
07F2 0088 MOVWF 0x8
15: for (i=60000;i>0;i--);
07F3 3060 MOVLW 0x60

Das Listing endet hier. Das *.LST file sieht etwas anders aus (vgl. 
Anhang)!?

Mit dem PIC 18F4525 kann ich unter MPLAB ohne "Third Party" (PICC-lite) 
problemlos compilieren und brennen und das Programm läuft!

Was mache ich falsch ?
Wolfgang

von Stefan (Gast)


Lesenswert?

Hallo Wolfgang,

vielleicht ist dein Problem ja noch "aktuell" :-)
Bin zufällig darauf gestoßen.

Wozu bindest du #include <16F877.h> ein?
das mit dem PIC-device "regelt" doch alles die <htc.h>.

Eventuell bringt das schonmal was...
Die Fehlermeldungen "chip", "core" usw. scheinen mit der 16F877.h 
zusammenzuhängen, oder?

Gruß
Stefan

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.