?? test_pwm.c
字號:
/****************************************************************************
【文 件 名 稱】main.c
【功 能 描 述】三星S3C2410A板demo程序代碼
【程 序 版 本】4.0
【創建人及創建日期】icesoar//2002年11月19日19:26
【修改人及修改日期】icesoar//2004-12-8 17:25
****************************************************************************/
//***************************************************************************
#include "def.h"
#include "2410addr.h"
#include "config.h"
#include "board.h"
#include "utils.h"
#define MaxBeepFreq 20000
#define MinBeepFreq 20
/****************************************************************************
【功能說明】系統主函數
****************************************************************************/
void TestPwm(void)
{
U16 BeepFreq = 500;
// U16 ratio = 50;
printf( "S3C2410A PWM Test( Beep ) !\n\n" ) ;
printf( "Press +/- to increase/reduce the frequency of beep !\n" ) ;
//printf( "Press h/l to increase/reduce the hi-ratio of beep !\n" ) ;
printf( "Press 'ESC' to Exit this test program !\n\n" );
Beep(BeepFreq, 200);
while( 1 )
{
U8 key;
key = getch();
putch( key );
if( key == '+' )
if( BeepFreq < 20000 )
BeepFreq += 100 ;
if( key == '-' )
if( BeepFreq > 100 )
BeepFreq -= 100 ;
/* if( key == 'H' || key == 'h' )
if( ratio < 100 )
ratio += 1 ;
if( key == 'L' || key == 'l' )
if( ratio > 0 )
ratio -= 1 ;
*/
if( key == ESC_KEY ) break ;
Beep( BeepFreq, 200 ) ;
//printf( "\tNow beep frequence is %dHz Hi-ratio %d%%\n", BeepFreq, ratio ) ;
printf( "Now beep frequence is %dHz\n", BeepFreq) ;
}
printf( "\n" ) ;
}
static char title[] = "蜂鳴器輸出實驗";
static char tip[] = "實驗由S3C2410A的定時器產生的PWM輸出控制蜂鳴器,按+/-鍵調節PWM的頻率,按ESC鍵返回";
//TestPwmItem在prog_entry.c里被引用
TEST_PROGRAM_ITEM TestPwmItem = {
(TEST_PROGRAM)TestPwm, //入口地址
title, //顯示名稱
tip, //幫助或提示信息,可為NULL
1}; //使用printf,puts,putch等函數時在LCD上也顯示輸出字符(串)
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -