2195 views|2 replies

38

Posts

0

Resources
The OP
 

[RISC-V MCU CH32V103 Review] Tick Timer [Copy link]

 

When using STM32, the best thing to use is probably systick. Does Qinheng have this chip? First find the relevant information:

And it is a 64-bit timer

Must like

Then, start coding

int main(void)
{
    NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
    //Delay_Init();

    Systick_Init();

    USART_Printf_Init(9600);
    printf("\r\n");
    printf("SystemClk:%d\r\n", SystemCoreClock);

    LED_Init();


	while(1)
	{
	    printf("SysTick_Counter:%d\r\n", SysTick_Counter);
	}
}

Is the current code architecture becoming more and more familiar and clearer?

Next is the configuration of systick.

initialization:

void Systick_Init(void)
{
    //sysTickPerUs = SystemCoreClock / 8000000;//1us
    SysTick_Config(SystemCoreClock / 8000);//1ms
}

Interrupt:

void SysTick_Handler(void)
{
    SysTick->CNTL0 = 0;
    SysTick->CNTL1 = 0;
    SysTick->CNTL2 = 0;
    SysTick->CNTL3 = 0;

    SysTick_Counter ++;

    if(SysTick_Counter >= 1000)
    {
        SysTick_Counter = 0;
        LED1_TOGGLE();
    }
}

image.png (220.41 KB, downloads: 0)

image.png
This post is from Domestic Chip Exchange

Latest reply

It's getting smoother.  Details Published on 2021-4-22 08:50
 
 

1662

Posts

0

Resources
2
 

Qinheng's chip should have

This post is from Domestic Chip Exchange
 
 
 

693

Posts

7

Resources
3
 

It's getting smoother.

This post is from Domestic Chip Exchange
 
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list