7 years, 10 months ago.

LPC824 MAX のPWM

PwmOutのperiodの変更がループの2回目以降には、for文内でpwm_ch0.write(0.0);しているにも関わらずパルスが出てしまうようです。 どのように回避すればよいでしょうか?

include the mbed library with this snippet

#include "mbed.h"

PwmOut pwm_ch0(P0_22);
PwmOut pwm_ch1(P0_18);
PwmOut pwm_ch2(P0_17);

int main()
{

   LPC_SCT->CONFIG |= 0x01; // unified 32-bit counter

   while(1) {
       for(float p = 0.0f; p < 1.0f; p += 0.01f) {
           
           pwm_ch0.period_us(1000);
           pwm_ch0.write(0.0);
           pwm_ch1.period_us(1000);
           pwm_ch1 = p;
           pwm_ch2.period_us(1000);
           pwm_ch2 = 1.0-p;

           wait(0.01);
       }
       
       
        wait(2);
        
        //LPC_SCT->CONFIG |= 0x01; // unified 32-bit counter
        pwm_ch0.period(1.0/3000.0);
        pwm_ch0.write(0.5);
        wait_ms(10);
        pwm_ch0.write(0.0);
        
        wait(1);
   }
}

こちら( https://developer.mbed.org/questions/61392/LPC824PwmOut/ )に関連した問題かもしれません.ライブラリをアップデートすることで改善が見られるでしょうか?

posted by Tedd OKANO 18 Jun 2016

最新版ですがやはり2周目は失敗するようです。 LPC824MAXと、スイッチサイエンスさんのLPC824はターゲットは別のプログラムだということですかね?? (スイッチサイエンスさんの方だけ直っているとか?)

whileループ1周目のfor文 /media/uploads/Info/1--.png

whileループ2周目以降のfor文 /media/uploads/Info/2--.png

posted by mille feuille 20 Jun 2016
Be the first to answer this question.