main.c
創(chuàng)新互聯(lián)專(zhuān)業(yè)為企業(yè)提供卓尼網(wǎng)站建設(shè)、卓尼做網(wǎng)站、卓尼網(wǎng)站設(shè)計(jì)、卓尼網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁(yè)設(shè)計(jì)與制作、卓尼企業(yè)網(wǎng)站模板建站服務(wù),十載卓尼做網(wǎng)站經(jīng)驗(yàn),不只是建網(wǎng)站,更提供有價(jià)值的思路和整體網(wǎng)絡(luò)服務(wù)。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 章節(jié)
//RCC_MP_AHB4ENSETR[1] = 1
RCC->MP_AHB4ENSETR |= (0x1<< 1);
//RCC_MP_APB1ENSETR[2] = 1
RCC->MP_APB1ENSETR |= (0x1<< 2);
//GPIO章節(jié)
//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章節(jié)
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);
//設(shè)置為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);
}
你是否還在尋找穩(wěn)定的海外服務(wù)器提供商?創(chuàng)新互聯(lián)www.cdcxhl.cn海外機(jī)房具備T級(jí)流量清洗系統(tǒng)配攻擊溯源,準(zhǔn)確流量調(diào)度確保服務(wù)器高可用性,企業(yè)級(jí)服務(wù)器適合批量采購(gòu),新人活動(dòng)首月15元起,快前往官網(wǎng)查看詳情吧