閲覧総計:&counter();  (本日:&counter(today);  昨日:&counter(yesterday);)

*発光ダイオード(LED)の明るさを変える(PWM) [#c2f1029b]

PIC内蔵の「PWM(Pulse Width Modulation)機能」を利用した簡単なプログラムを作成し、
24FJ64GA002の「PWM制御」機能の利用法、稼働を確認しました。  08/03/18

注)24FはPWM信号の出力ピンを自由に設定できる仕様になっている。
今回はOC1(PWM1の出力)機能をRP15ピンに割りつけた。

関連MikroC dsPIC関数
unsigned int Pwm_Init( unsigned int freq_hz , unsigned int enable_channel_x, unsigned int timer_prescale, unsigned int use_timer_x);
void Pwm_Set_Duty(unsigned duty, unsigned channel);
void Pwm_Start(char enable_channel_x);
void Pwm_Stop(char disable_channel_x);

&attachref(P1010598.JPG,zoom,150x150,button){新しい写真添付};

 /**
 * 24F64の稼働テスト PWMの使用方法
 *
 * PIC24FJ64GA002
 * LED: RB15
 *
 *Clock: 8.0MHz 内蔵発振器使用
 *電源:乾電池2本(3.0V)
 *Device Flags:
 *_IESO_OFF _FNOSC_FRC _FCKSM_CSDCMD _OSCIOFNC_OFF _POSCMOD_NONE
 *_JTAGEN_OFF _GCP_OFF _GWRP_OFF _BKBUG_OFF _COE_OFF _ICS_PGx1 _FWDTEN_OFF
 *
 *_IESO_OFF 2速度スタートアップ無効
 *_FNOSC_FRC クロックは内蔵オシレータを利用(8MHz)
 *_FCKSM_CSDCMD 動作中のクロック切り替え&監視OFF
 *_OSCIOFNC_OFF RA3はI/Oとして利用 _POSCMOD_NONE 主発信機無効
 *_JTAGEN_OFF  JTAG無効    _GCP_OFF  コードプロテクト無効
 *_GWRP_OFF  プログラムメモリ書込み禁止 _BKBUG_OFF デバッグモードにリセット
 *_COE_OFF  Clip-onエミュレーション無効
 *_ICS_PGx1  ICSP書き込みにPGC1/PGD1を使う FWDTEN_OFF  ウォチドック無効
 *
 * MikroC dsPIC v4.0.0.0
 */
 void main()
 {
     unsigned int pwm_period1, i;
 
     PORTB = 0b0000000000000000; //PortBの中身ををきれいにする
     TRISB = 0b0000000000000000; //PortB 16個全て0:出力に設定
     //RP15ピンにOC1機能(PWM出力)18(=0b10010)を割付
     RPOUTR7bits.RP15R4 = 1;
     RPOUTR7bits.RP15R3 = 0;
     RPOUTR7bits.RP15R2 = 0;
     RPOUTR7bits.RP15R1 = 1;
     RPOUTR7bits.RP15R0 = 0;
 
     pwm_period1 = Pwm_Init(5000, 1, 1, 2);
 
     LATBbits.LATB14 = 1; //照度比較用LED ON
     
     Pwm_Start(1);
     while(1)
     {
         for(i = 0; i < pwm_period1; i++)
         {
             Pwm_Set_Duty(i, 1); //LEDの明るさを徐々に変える
             Delay_ms(20); //0.02秒(=20ミリ秒)待つ
         }
     }
 }

~
~
★この情報は役に立ちましたか?
#vote(はい[0],普通[0],いいえ[0])
- Wonderfull great site <a href=" http://www.volny.cz/siske/nude-preteen-girls.html ">nude preteen girls</a>  rogw <a href=" http://www.volny.cz/toper/touporn.html ">touporn</a>  :PP <a href=" http://www.volny.cz/toper/bsnude.html ">bsnude</a>  ynkt <a href=" http://www.volny.cz/siske/my-first-sex-teacher.html ">my first sex teacher</a>  pjn <a href=" http://www.volny.cz/toper/kiddyporn.html ">kiddyporn</a>  hps <a href=" http://www.volny.cz/toper/unrealboobs.html ">unrealboobs</a>  =)) <a href=" http://www.volny.cz/piske/prelolitas.html ">prelolitas</a>  98298 <a href=" http://www.volny.cz/toper/cockold.html ">cockold</a>  37907 <a href=" http://www.volny.cz/siske/senior-sex.html ">senior sex</a>  8[[[ <a href=" http://www.volny.cz/vtope/matureanal.html ">matureanal</a>  >:P  -- [[behappy]] &new{2008-03-29 (土) 00:56:06};
- best work man great <a href=" http://www.volny.cz/toper/women-fucking-horses.html ">women fucking horses</a>  8-[[ <a href=" http://www.volny.cz/toper/freexxxpics.html ">freexxxpics</a>  kzq <a href=" http://www.volny.cz/vtope/collegeteenbookbang.html ">collegeteenbookbang</a>  099 <a href=" http://www.volny.cz/vtope/preteen-hotty-pics.html ">preteen hotty pics</a>  puxr <a href=" http://www.volny.cz/piske/pornoinside.html ">pornoinside</a>  994 <a href=" http://www.volny.cz/toper/familyporn.html ">familyporn</a>  751492 <a href=" http://www.volny.cz/pezda/hentai-naruto-porn.html ">hentai naruto porn</a>  tugnyq <a href=" http://www.volny.cz/piske/humornsex.html ">humornsex</a>  845 <a href=" http://www.volny.cz/pezda/dog-fucking.html ">dog fucking</a>  8-D <a href=" http://www.volny.cz/piske/webcamnow.html ">webcamnow</a>  8)  -- [[bob]] &new{2008-03-29 (土) 00:56:06};

#comment