📄 pwm.c
字号:
/*************************************************************************************
* Copyright (c) 2005 by National ASIC System Engineering Research Center.
* PROPRIETARY RIGHTS of ASIC are involved in the subject matter of this
* material. All manufacturing, reproduction, use, and sales rights
* pertaining to this subject matter are governed by the license agreement.
* The recipient of this software implicitly accepts the terms of the license.
*
* File Name: pwm.c
*
* File Description:
* The file includes three functions to initialize the lcd controller and
* display some pictures on the lcd.
*
* Function Description:
* STATUS ModulePwm(void)
* The top function of PWM experiment.
*
* void run_pwm(void)
* It start the Pwm to work.
*
* STATUS set_fix(U32 sample)
* The function is to set fixed period.
* sample: The sample is configured into FIFO of Pwm.
*
* STATUS set_unfix(U8 prescaler)
* The function is to set the unfixed period.
* prescaler: It configures the period by BUS frequence divided.
* Created by Michael <yuyu_zh@seu.edu.cn>, 2005-03-29
**************************************************************************************/
#include "hardware_intc.h"
#include "hardware_reg.h"
int sound_flag = 0;
int sound_time = 0;
void sound(void)
{
*(RP)(PWM2_C) = 0X000013ff;
//*(volatile unsigned long *)(0x1000c010) = 0 ;
if(sound_time == 0)
{
*(volatile unsigned long *)(0x1000c014) = 0xffff;
*(volatile unsigned long *)(0x1000c018) = 0X0000ffff;//PWM2_P为周期寄存器
}
sound_time++;
if(sound_time ==50)
{
//*(RP)(PWM2_S) = 0xffff;
*(RP)(PWM2_C) = 0 ;
sound_time =0;
sound_flag = 0;
}
}
void Alarm_Sound(void)
{
*(RP)(PWM2_C) = 0X000010ff;
//*(RP)(PWM2_S) = 0xffff;
*(RP)(PWM2_P) = 0X0000fffd;//PWM2_P为周期寄存器
}
void Break_Sound(void)
{
*(RP)(PWM2_C) = 0X00001000;
*(RP)(PWM2_S) = 0xffff;
*(RP)(PWM2_P) = 0X0000ffff;//PWM2_P为周期寄存器
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -