十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
main.c
创新互联专业为企业提供卓尼网站建设、卓尼做网站、卓尼网站设计、卓尼网站制作等企业网站建设、网页设计与制作、卓尼企业网站模板建站服务,十载卓尼做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。include "beep.h"
extern void printf(const char *fmt, ...);
void delay_ms(int ms)
{
int i,j;
for(i = 0; i< ms;i++)
for (j = 0; j< 1800; j++);
}
int main(void)
{
//unsigned int i =0;
//hai_beep_init();
//hai_mada_init();
hai_fen_init();
while(1)
{
}
return 0;
}
beep.c
#include "beep.h"
void hai_beep_init()
{
//RCC 章节
//RCC_MP_AHB4ENSETR[1] = 1
RCC->MP_AHB4ENSETR |= (0x1<< 1);
//RCC_MP_APB1ENSETR[2] = 1
RCC->MP_APB1ENSETR |= (0x1<< 2);
//GPIO章节
//GPIO->AFRL[27:24] = 0010
GPIOB->AFRL &= (~(0xf<<24));
GPIOB->AFRL |= (0x1<< 25);
//GPIO->MODER[13:12] = 10
GPIOB->MODER &= (~(0x3<< 12));
GPIOB->MODER |= (0x1<< 13);
//TIME4章节
TIM4->PSC = 0xD0;
TIM4->ARR = 0x3E8;
TIM4->CCR1 = 0x2BC;
TIM4->CR1 |= (0x1<< 7);
TIM4->CR1 &= (~(0x3<< 5));
TIM4->CR1 |= (0x4<< 4);
TIM4->CR1 |= (0x1<< 0);
TIM4->CCMR1 &= (~(0x1<< 16));
TIM4->CCMR1 &= (0x7<< 4);
TIM4->CCMR1 |= (0x3<< 5);
TIM4->CCMR1 |= (0x1<< 3);
TIM4->CCMR1 &= (~(0x3<< 0));
TIM4->CCER |= (0x1<< 3);
TIM4->CCER &= (~(0x1<< 1));
TIM4->CCER |= (0x1<< 0);
}
void hai_mada_init()
{
RCC->MP_AHB4ENSETR |= (0x1<< 5);
RCC->MP_APB2ENSETR |= (0x1<< 3);
GPIOF->AFRL &= (~(0xf<<24));
GPIOF->AFRL |= (0x1<< 24);
GPIOF->MODER &= (~(0x3<< 12));
GPIOF->MODER |= (0x1<< 13);
TIM16->PSC = 0xD0;
TIM16->ARR = 0x3E8;
TIM16->CCR1 = 0x12C;
TIM16->CR1 |= (0x1<< 0);
TIM16->CR1 |= (0x1<< 7);
TIM16->CCMR1 &= (~(0x1<< 16));
TIM16->CCMR1 &= (~(0x7<< 4));
TIM16->CCMR1 |= (0x3<< 5);
TIM16->CCMR1 |= (0x1<< 3);
TIM16->CCMR1 &= ((~0x3<< 0));
TIM16->CCER |= (0x1<< 0);
TIM16->CCER &= (~(0x1<< 3));
TIM16->CCER |= (0x1<< 1);
TIM16->BDTR |= (0x1<< 15);
}
void hai_fen_init()
{
RCC->MP_AHB4ENSETR |= (0x1<< 4);
RCC->MP_APB2ENSETR |= (0x1<< 0);
GPIOE->MODER &= (~(0x3<< 18));
GPIOE->MODER |= (0x1<< 19);
GPIOE->AFRH &= (~(0xf<< 4));
GPIOE->AFRH |= (0x1<< 4);
//PSC
TIM1->PSC = 0xD0;
//ARR
TIM1->ARR = 0x1F4;
//CCR1
TIM1->CCR1 = 0x12C;
//CR1
TIM1->CR1 |= (0x1<< 7);
TIM1->CR1 &= (~(0x3<< 5));
TIM1->CR1 |= (0x1<< 4);
TIM1->CR1 |= (0x1<< 0);
//设置为PWM1模式
TIM1->CCMR1 &= (~(0x1<< 16));
TIM1->CCMR1 &= (0x7<< 4);
TIM1->CCMR1 |= (0x3<< 5);
TIM1->CCMR1 |= (0x1<< 3);
TIM1->CCMR1 &= (~(0x3<< 0));
//CCER
TIM1->CCER |= (0x1<< 3);
TIM1->CCER &= (~(0x1<< 1));
TIM1->CCER |= (0x1<< 0);
//BDTR
TIM1->BDTR |= (0x1<< 15);
}
你是否还在寻找稳定的海外服务器提供商?创新互联www.cdcxhl.cn海外机房具备T级流量清洗系统配攻击溯源,准确流量调度确保服务器高可用性,企业级服务器适合批量采购,新人活动首月15元起,快前往官网查看详情吧