Wie der Betreff schon sagt versuche ich gerade mein PWM vom PIC12f1501
zu Initialisieren und wollte euch bitten, den Code kurz anzuschauen und
mir zusagen ob ich soweit richtig bin.
1 | #include <pic12f1501.h>
|
2 | #include <stdio.h>
|
3 | #include <stdlib.h>
|
4 | #include <delays.h>
|
5 |
|
6 |
|
7 | // PIC12F1501 Configuration Bit Settings
|
8 |
|
9 | #include <xc.h>
|
10 |
|
11 | // CONFIG1
|
12 | #pragma config FOSC = INTOSC // Oscillator Selection Bits (INTOSC oscillator: I/O function on CLKIN pin)
|
13 | #pragma config WDTE = OFF // Watchdog Timer Enable (WDT disabled)
|
14 | #pragma config PWRTE = ON // Power-up Timer Enable (PWRT enabled)
|
15 | #pragma config MCLRE = ON // MCLR Pin Function Select (MCLR/VPP pin function is MCLR)
|
16 | #pragma config CP = ON // Flash Program Memory Code Protection (Program memory code protection is enabled)
|
17 | #pragma config BOREN = OFF // Brown-out Reset Enable (Brown-out Reset disabled)
|
18 | #pragma config CLKOUTEN = OFF // Clock Out Enable (CLKOUT function is disabled. I/O or oscillator function on the CLKOUT pin)
|
19 |
|
20 | // CONFIG2
|
21 | #pragma config WRT = OFF // Flash Memory Self-Write Protection (Write protection off)
|
22 | #pragma config STVREN = ON // Stack Overflow/Underflow Reset Enable (Stack Overflow or Underflow will cause a Reset)
|
23 | #pragma config BORV = LO // Brown-out Reset Voltage Selection (Brown-out Reset Voltage (Vbor), low trip point selected.)
|
24 | #pragma config LPBOR = OFF // Low-Power Brown Out Reset (Low-Power BOR is disabled)
|
25 | #pragma config LVP = OFF // Low-Voltage Programming Enable (High-voltage on MCLR/VPP must be used for programming)
|
26 |
|
27 |
|
28 |
|
29 | /*
|
30 | *
|
31 | */
|
32 | void main(void) {
|
33 |
|
34 | //INITIALIZING PORTA
|
35 | PORTA = 0x00;
|
36 | LATA = 0x00;
|
37 | ANSELA = 0x00;
|
38 | TRISA = 0x00;
|
39 |
|
40 |
|
41 | //INITIALIZING PWM
|
42 | // Fosc = 16000000 Hz
|
43 | // Fpwm = 10000.00 Hz
|
44 | // Duty Cycle = 50 %
|
45 |
|
46 | PWM1CON = 0x00;
|
47 | PWM2CON = 0x00;
|
48 | PWM3CON = 0x00;
|
49 | PWM4CON = 0x00;
|
50 |
|
51 | PR2 = 0x7C ;
|
52 |
|
53 | PWM1DCH = 0x00;
|
54 | PWM2DCH = 0x00;
|
55 | PWM3DCH = 0x00;
|
56 | PWM4DCH = 0x00;
|
57 |
|
58 | PWM1DCL = 0x3F;
|
59 | PWM2DCL = 0x3F;
|
60 | PWM3DCL = 0x3F;
|
61 | PWM4DCL = 0x3F;
|
62 |
|
63 | T2CON = 0x05 ;
|
64 |
|
65 |
|
66 |
|
67 | while(1);
|
68 |
|
69 | }
|
Bedanke mich schon im vorraus!!!
Gruß