CH32V307KCS
2023
20221203.6 Timer 6
int main(void)
{
//u16 i ;
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
Delay_Init();
USART_Printf_Init(115200);
printf("SystemClk:%d\r\n",SystemCoreClock);
printf("This is printf example\r\n");
GPIO_InitTypeDef GPIO_InitStructure = {0};
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, DISABLE);
RCC->APB2PCENR |= 0x04 ; //RCC_APB2PCENR RCC->APB2PCENR
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_WriteBit(GPIOA, GPIO_Pin_15, 1); //Bit_SET Bit_RESET
RCC->APB1PCENR |= 1<<4 ;
//TIM6->ATRLR = 0x0000 ;
TIM6->PSC = 0xFFF ;
TIM6->CTLR1 = 0x01 ;
while(1)
{
//GPIO_WriteBit(GPIOA, GPIO_Pin_15, 1);
//while((TIM6->INTFR&0x01)==0);
//TIM6->INTFR &= ~0x01 ;
//while(TIM6->CNT != 0xF000);
if ( (TIM6->CNT&(1<<12))==(1<<12) )
{ GPIOA->OUTDR |= 1<<15 ;}
//Delay_Ms(10); }
else GPIOA->OUTDR &= ~1<<15 ;
//Delay_Ms(100);
//while((TIM6->INTFR&0x01)==0);
//TIM6->INTFR &= ~0x01 ;
//while(TIM6->CNT != 0xF000);
//GPIOA->OUTDR &= ~1<<15 ;
//GPIO_WriteBit(GPIOA, GPIO_Pin_15, 0);
//Delay_Ms(100);
}
}
Connect CH32V307 board to PC
Launch WCHISP
Hold down 'BOOT0'
Press and release 'RST'
Release 'BOOT0'
Click 'Remove protect'
Launch MounRiver Studio
Edit
Build
Load HEX file in WCHISP
Hold down 'BOOT0'
Press and release 'RST'
Release 'BOOT0'
Download
Click 'Remove protect' to run
Comments
Post a Comment