1.昊芯RISC-V定时器
导语:
Haawking IDE 新建
导语:
Haawking IDE 新建
ConfigCpuTimer(&CpuTimer0, 120, 60000); //12MHz,1000us ,即为 1ms中断周期
CpuTimer0Regs.TPR.bit.TDDR= 10000;
CpuTimer0Regs.TCR.bit.TIE= 1; //使能中断
CpuTimer0Regs.TCR.bit.TSS= 0; // To start or restart the CPU-timer, set TSS to 0
//中断配置步骤-----2,重映射中断服务函数
// Interrupts that are used in this example are re-mapped to
// ISR functions found within this file.
EALLOW;
PieVectTable.TINT0= &cpu_timer0_isr;
EDIS;
//中断配置步骤-----3,连接CPU中断Y
IER_ENABLE(M_INT1);
//中断配置步骤-----4,连接Y中断里的第几位
PieCtrlRegs.PIEIER1.bit.INTx7= 1;
}
//CPU 定时器0 中断服务函数
INTERRUPT voidcpu_timer0_isr(void)
{
timer0Base.msCounter++;
timer0Base.Mark_Para.Status_Bits.OnemsdFlag= 1;
// Acknowledge this interrupt to receive more interrupts from group 1
EALLOW;
PieCtrlRegs.PIEACK.all= PIEACK_GROUP1;
EDIS;
}
点击编译、编译完成后点击下载。
全部评论