RISC-V技术论坛
直播中

卢化月

11年用户 17经验值
擅长:控制/MCU
私信 关注

【南京中科微CSM32RV20开发板试用体验】定时器点亮LED

非常感谢南京中科微联合电子发烧友平台提供的开发板

1.硬件介绍

cgi-bin_mmwebwx-bin_webwxgetmsgimg_&MsgID=2717589913215941870&skey=@crypt_31e4601d_353f3bf8cfc6d99de44d48b19593b3e4&mmweb_appid=wx_webfilehelper.jpg

2.电路图

cgi-bin_mmwebwx-bin_webwxgetmsgimg_&MsgID=5127511214331763328&skey=@crypt_31e4601d_353f3bf8cfc6d99de44d48b19593b3e4&mmweb_appid=wx_webfilehelper.jpg

3.新建项目

cgi-bin_mmwebwx-bin_webwxgetmsgimg_&MsgID=6441626982684995407&skey=@crypt_31e4601d_353f3bf8cfc6d99de44d48b19593b3e4&mmweb_appid=wx_webfilehelper.jpg

4.自动加载代码

cgi-bin_mmwebwx-bin_webwxgetmsgimg_&MsgID=6839956271048537450&skey=@crypt_31e4601d_353f3bf8cfc6d99de44d48b19593b3e4&mmweb_appid=wx_webfilehelper.jpg

5.定时点灯

uint16_t timer_ms;

//外设配置

Timer1_UpCounting_Mode_Init();//向上计数

//设置中断优先级

Interrupt_Level(TIMER1_updata_int_ID, INT_LEVEL1);//CLIC设置中断抢占级别

//使能外设中断

Interrupt_Enable(TIMER1_updata_int_ID);//CLIC使能中断

//使能系统总中断

SYS_Interrupt_Enable();//CLIC开总中断

中断点灯

void Timer1_Update_IRQhandler(void)

{

if(TIMER1->SR&0x1)

{

TIMER1->SR &= ~0x1;

if(++timer_ms == 1000)

{

timer_ms = 0;

GPIO_Toggle(GPIOA,PIN12);

}

}

}

回帖(1)

dianzi

2022-7-13 17:41:30
没有验证图片或视频吗?
举报

更多回帖

发帖
×
20
完善资料,
赚取积分