赞
踩
程序实现了控制蜂鸣器输入pwm频率和开关功能。输入数字1开启蜂鸣器,输入数字0关闭蜂鸣器,输入字符+增加蜂鸣器输入pwm频率,输入字符-减少蜂鸣器输入pwm频率。代码如下:
1 #include "def.h"
2 #include "option.h"
3 #include "2440addr.h"
4 #include "2440lib.h"
5 #include "2440slib.h"
6
7 void dely(U32 tt)
8 {
9 U32 i;
10 for(;tt>0;tt--)
11 {
12 for(i=0;i<10000;i++){}
13 }
14 }
15
16 int Main(int argc, char **argv)
17 {
18 int i;
19 U8 key;
20 U32 mpll_val=0;
21 int data;
22 int readLength = 0;
23 int buzzerWork = 0;
24 U16 freq = 1000;
25
26 mpll_val = (92<<12)|(1<<4)|(1);
27
28 //init FCLK=400M, so change MPLL first
29 ChangeMPllValue((mpll_val>>12)&0xff, (mpll_val>>4)&0x3f, mpll_val&3);
30 ChangeClockDivider(key, 12);
31
32 Uart_Init( 0,115200 );
33 Uart_Select( 0 );
34 Uart_SendByte('\n');
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。