PIC18F46K80 Grundlage

OP #3639436
Lesenswert?

Hallo Zusammen,

ich teste gerade mit einem neuen Controller. I²C-Bus , A/D-Wandler usw. 
habe ich zum laufen gebracht. Allerdings macht mir eine simple For - 
Next Schleife Probleme. Ich weiß nicht warum der Controller überhaupt 
nichts tut. Habe ich in den Config-Bits ggf. etwas laut Datenblatt 
vergessen. Ich arbeite mit dem C18 und Alternativ auch mit dem XC8. Bei 
beiden Compilern ist es das idenische Funktionsverhalten.

Hier wäre mein Code:

Hatte das schon jemand?

Danke und Gruß
Ingo Schick
1
/************************************************************************/
2
// Lauflicht Beispiel Nr. 1
3
// Datum: 01.05.2014
4
// Autor: Ingo Schick
5
/************************************************************************/
6

7
/************************************************************************/
8
//Include Dateien
9
/************************************************************************/
10
#include <p18f46k80.h>      // PIC18F46K80 auswählen
11
#include <stdio.h>      // Standard-Bibiotheken einbeziehen
12
#include "SP_PIC18F46K80.H"
13
#include "Warten_MS.C"
14
/************************************************************************/
15

16
/************************************************************************/
17
// Microcontroller-Konfiguration
18
/************************************************************************/
19
// CONFIG1L
20
#pragma config RETEN = OFF    
21
#pragma config INTOSCSEL = LOW 
22
#pragma config SOSCSEL = DIG
23
#pragma config XINST = OFF
24

25
// CONFIG1H 
26
#pragma config FOSC = HS2       // Oscillator (HS oscillator (Medium power, 16 MHz - 25 MHz)) 
27
#pragma config PLLCFG = OFF      
28
#pragma config FCMEN = OFF       
29
#pragma config IESO = OFF      
30

31
// CONFIG2L 
32
#pragma config PWRTEN = OFF     // Power Up Timer (Disabled) 
33
#pragma config BOREN = OFF 
34
#pragma config BORV = 3         // Brown-out Reset Voltage bits (1.8V) 
35
#pragma config BORPWR = ZPBORMV // BORMV Power level (ZPBORMV instead of BORMV is selected) 
36

37
// CONFIG2H 
38
#pragma config WDTEN = SWDTDIS  // Watchdog Timer (WDT enabled in hardware; SWDTEN bit disabled) 
39
#pragma config WDTPS = 1048576  // Watchdog Postscaler (1:1048576) 
40

41
// CONFIG3H 
42
#pragma config CANMX = PORTC    // ECAN Mux bit (ECAN TX and RX pins are located on RB2 and RB3, respectively) 
43
#pragma config MSSPMSK = MSK7   // MSSP address masking (7 Bit address masking mode) 
44
#pragma config MCLRE = ON       // Master Clear Enable (MCLR Enabled, RG5 Disabled) 
45

46
// CONFIG4L 
47
#pragma config STVREN = OFF      // Stack Overflow Reset (Disabled) 
48
#pragma config BBSIZ = BB2K     // Boot Block Size (2K word Boot Block size) 
49

50
// CONFIG5L 
51
#pragma config CP0 = OFF        // Code Protect 00800-03FFF (Disabled) 
52
#pragma config CP1 = OFF        // Code Protect 04000-07FFF (Disabled) 
53
#pragma config CP2 = OFF        // Code Protect 08000-0BFFF (Disabled) 
54
#pragma config CP3 = OFF        // Code Protect 0C000-0FFFF (Disabled) 
55

56
// CONFIG5H 
57
#pragma config CPB = OFF        // Code Protect Boot (Disabled) 
58
#pragma config CPD = OFF        // Data EE Read Protect (Disabled) 
59

60
// CONFIG6L 
61
#pragma config WRT0 = OFF       // Table Write Protect 00800-03FFF (Disabled) 
62
#pragma config WRT1 = OFF       // Table Write Protect 04000-07FFF (Disabled) 
63
#pragma config WRT2 = OFF       // Table Write Protect 08000-0BFFF (Disabled) 
64
#pragma config WRT3 = OFF       // Table Write Protect 0C000-0FFFF (Disabled) 
65

66
// CONFIG6H 
67
#pragma config WRTC = OFF       // Config. Write Protect (Disabled) 
68
#pragma config WRTB = OFF       // Table Write Protect Boot (Disabled) 
69
#pragma config WRTD = OFF       // Data EE Write Protect (Disabled) 
70

71
// CONFIG7L 
72
#pragma config EBTR0 = OFF      // Table Read Protect 00800-03FFF (Disabled) 
73
#pragma config EBTR1 = OFF      // Table Read Protect 04000-07FFF (Disabled) 
74
#pragma config EBTR2 = OFF      // Table Read Protect 08000-0BFFF (Disabled) 
75
#pragma config EBTR3 = OFF      // Table Read Protect 0C000-0FFFF (Disabled) 
76

77
// CONFIG7H 
78
#pragma config EBTRB = OFF      // Table Read Protect Boot (Disabled) 
79
/************************************************************************/
80

81

82
/************************************************************************/
83
// sonstige Deklarationen
84
/************************************************************************/
85
#define True      1
86
#define False      0  
87
/************************************************************************/
88

89
/************************************************************************/
90
// Hauptprogramm
91
/************************************************************************/
92

93
void main(void)
94
{
95
  char i;
96
    
97
    TRISB = 0x00;           
98
    PORTB = 0X00;
99
    
100
    TRISC= 0b01011000;           // PORTC initalisieren
101
    PORTC= 0b01011000;          
102
  
103
    TRISD = 0x00;          
104
    PORTD = 0x00;          
105
    
106
//*****************************************************************************
107
// Start der Hauptprogramm-Schleife 
108
//*****************************************************************************  
109
    
110
 while(1)                    // Ganzes Programm ist Endlosschleife
111
 {     
112
  for (i=0 ; i<7 ;i++)
113
    {
114
      PORTD = PORTD << 1;
115
      Warten_MS(150);
116
    }
117
  
118
    for (i=0 ; i<7 ;i++)
119
    {
120
      PORTD = PORTD >> 1;
121
      Warten_MS(150);
122
    }      
123
 }
124
//*****************************************************************************    
125
 }  // Ende des Hauptprogramm
126
//*****************************************************************************

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