-         

Ergebnis 1 bis 2 von 2

Thema: PWM output problem

  1. #1

    PWM output problem

    Anzeige

    Hallo,

    Habe ursprünglich die frage auf englisch verfasst, auf Deutsch zu anzworten ist kein Problem. Benütze den C18 compiler von Microchip.

    I have a problem generating consistent PWM outputs.
    Specifically, the output duty cycle varies every time I call the SetDCPWM1() function in my code below. Upon checking the RC2/CCP1 pin with the Oscilloscope, the PWM period stays constant, but the duty cycle is different in the while()-loop every time called, although the argument is the same

    More strangely, my RB4 output pin (which I use to Enable a H-Bridge Driver) after some seconds drops low - although its state shouldnt change in the while loop.

    Anyone have any idea? I´m using an external 6MHz Quarz, each pin connected also in parallell with two 27pF connected to GND. The PIC is a PIC18F248.


    #include <p18f248.h>
    #include <stdlib.h>
    #include <string.h>
    #include <pwm.h>
    #include <timers.h>
    #include <delays.h>

    #pragma config OSC = HS
    #pragma config PWRT = ON
    #pragma config BOR = OFF
    #pragma config WDT = OFF
    #pragma config LVP = OFF

    #pragma code

    void main(void)
    {
    OpenPWM1(0xf0);
    OpenTimer2(T2_PS_1_1 & T2_POST_1_10 & TIMER_INT_OFF);

    PORTC = 0; // Clear PORTC
    TRISC = 0xdb; // Make RC2/CCP1 and RC5(remove later) outputs

    LATB = 0x10; //0x10 = 00010000b = bit4 (RB4) of PORTB Register ON
    TRISB = 0xef; //0xEF = 11101111h = bit4 (RB4) of TRISB sets Output

    while (1)
    {
    Delay10KTCYx(255);
    SetDCPWM1(600);
    }
    }

    //END OF PROGRAM

  2. #2
    Benutzer Stammmitglied
    Registriert seit
    03.12.2004
    Beiträge
    89
    More strangely, my RB4 output pin (which I use to Enable a H-Bridge Driver) after some seconds drops low - although its state shouldnt change in the while loop.
    ich habe gerade im datenblatt vom PIC18F248 gelesen das der RA4 ein open-drain IO ist, wurde in der hardwareschaltung daran gedacht einen pull-up an den RA4 zu legen?

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •