#include "stm8s.h"
#include "stm8s_tim1.h"
#include "stm8s_gpio.h"
#include "stm8s_flash.h"
void TIM1_Init(void)
{
u8 status;
TIM1_DeInit();
GPIO_Init(GPIOB, GPIO_PIN_ALL , GPIO_MODE_IN_FL_NO_IT );
FLASH_Unlock(FLASH_MEMTYPE_DATA);
FLASH_ProgramOptionByte(0x4803,0x20);
status = FLASH_WaitForLastOperation(FLASH_MEMTYPE_DATA);
if (status == FLASH_STATUS_SUCCESSFUL_OPERATION)
{
}
FLASH_Lock(FLASH_MEMTYPE_DATA);
TIM1_ETRClockMode2Config(TIM1_EXTTRGPSC_DIV2, TIM1_EXTTRGPOLARITY_INVERTED, 0x00);
TIM1_Cmd(ENABLE);
}
u8 COUN1=0;
int main(void)
{
while(1)
{
COUN1=TIM1->CNTRH;
}
}
调用库函数,这个程序能实现这个功能吗? |