Problem mit verwenden von BCM2835 processor auf Raspberry Pi 2B PWM chan1 oder PWM chan2

  • ich habe Problem mit BCM2835 processor auf Raspberry Pi 2B .

    Ich benutze PWM chan1 oder PWM chan2. Serialisier Mode. Als Data Input: FIFO. Datenausgabe wird entweder über chan1 oder chan2 passieren. Während mit chan1 keine Probleme gibt, habe ich Probleme mit chan2. BCM2835 befindet sich in endloser Schleife: während Bit STA_FIFO_FULL bei Verwendung PWM chan2 abgetastet wird. Bit ist immer 1. Wie sie sehen Code ist für beide Kanäle ähnlich. Hier ist vereinfachte Code:

    if(channel & PWM0)

    {

    for(pos = 0; pos <= (length) && BIT_IS_CLR(PWM_STA_FIFO_FULL, *pwm_statep); pos++) //fill empty FIFO till full

    {

    *pwm_fifop = data[pos];

    }

    *(pwm + PWM_CTL) |= PWM0_ENABLE ; //enable PWM0

    for(; pos <= (length ); pos++) //move next data to FIFO till End of data

    {

    while(BIT_IS_SET(PWM_STA_FIFO_FULL, *pwm_statep)) //Wait for free place in FIFO for next data

    {

    delayMicroseconds(20);

    }

    *pwm_fifop = data[pos];//next data ins FIFO

    }

    if BIT_IS_SET(PWM_STA_GAP0, *pwm_statep) //Check for GAP in STA

    {

    gapCounter++;

    * pwm_statep |= PWM_STA_GAP0; //reset GAP Bit

    }

    if BIT_IS_SET(PWM_STA_BERR, *pwm_statep)// Check for BUS Error in STA

    {

    berrCounter++;

    * pwm_statep |= PWM_STA_BERR; //reset BERR Bit

    }

    while( BIT_IS_SET(PWM_STA_FIFO_EMPT, *pwm_statep)) // wait for channel works to the end

    {

    delayMicroseconds(380);

    }

    *(pwm + PWM_CTL) &= ~ PWM0_ENABLE; //desable PWM0


    //Short code for PWM channel1:

    else if(channel & PWM1)

    {

    for(pos = 0; pos <= (length) && BIT_IS_CLR(PWM_STA_FIFO_FULL, *pwm_statep); pos++)//check if FIFO not full

    {

    *pwm_fifop = data[pos]; //fill FIFO with data

    }

    *(pwm + PWM_CTL) |= PWM1_ENABLE ;

    for(; pos <= (length ); pos++) //move next data to FIFO till end of data

    {

    while(BIT_IS_SET(PWM_STA_FIFO_FULL, *pwm_statep)) //Wait for free place in FIFO for nest data

    {

    delayMicroseconds(20);

    }

    *pwm_fifop = data[pos]; //fill free place in FIFO with next Data

    }

    if BIT_IS_SET(PWM_STA_GAP1, *pwm_statep)

    {

    gapCounter++;

    * pwm_statep |= PWM_STA_GAP1; //reset GAP Bit

    }

    if BIT_IS_SET(PWM_STA_BERR, *pwm_statep)

    {

    berrCounter++;

    * pwm_statep |= PWM_STA_BERR; //reset BERR Bit

    }

    while(BIT_IS_SET (PWM_STA_FIFO_EMPT, *pwm_statep)) // wait for fifo empty

    {

    delayMicroseconds(380);

    }

    *(pwm + PWM_CTL) &= ~ PWM1_ENABLE; //disable PWM chanel2

    }

    return pos;

    }

    Nach CTRL+C funktioniert Kanal2, aber beim nächster Ausführung habe ich endlose Schleife (rot markiert). Kanal 1 geht aber immer. Beide Code sind gleich. Warum Schwierigkeiten mit Kanal2 kommen??

    Könnten sie helfen?


  • Problem mit verwenden von BCM2835 processor auf Raspberry Pi 2B PWM chan1 oder PWM chan2? Schau mal ob du hier fündig wirst!

Jetzt mitmachen!

Du hast noch kein Benutzerkonto auf unserer Seite? Registriere dich kostenlos und nimm an unserer Community teil!