打算用EVA来做这这个
时钟设置:
SysCtrlRegs.PLLCR.bit.DIV = 0x4; //主频应该是60M
........
SysCtrlRegs.HISPCP.all = 0x0001;
SysCtrlRegs.LOSPCP.all = 0x0001;
.........
EVA设置:
// Set the Period for the GP timer 2 to 0x0200;
EvaRegs.T2PR = 0x06; // Period
EvaRegs.T2CMPR = EvaRegs.T2PR/4; // Compare Reg
// Enable Period interrupt bits for GP timer 2
// Count up, x128, internal clk, enable compare, use own period
EvaRegs.EVAIMRB.bit.T2PINT = 1;
EvaRegs.EVAIFRB.bit.T2PINT = 1;
// Clear the counter for GP timer 2
EvaRegs.T2CNT = 0x0000;
EvaRegs.T2CON.all = 0x1042;
中断设置:
interrupt void eva_timer2_isr(void)
{
EvaTimer2InterruptCount++;
// Enable more interrupts from this timer
EvaRegs.EVAIMRB.bit.T2PINT = 1;
if(OSCL_Flag == 1)
{
OSCL=1;
OSCL_Flag = 0;
}else{
OSCL=0;
OSCL_Flag = 1;
}
// Note: To be safe, use a mask value to write to the entire
// EVAIFRB register. Writing to one bit will cause a read-modify-write
// operation that may have the result of writing 1's to clear
// bits other then those intended.
EvaRegs.EVAIFRB.all = BIT0;
// Acknowledge interrupt to receive more interrupts from PIE group 3
PieCtrlRegs.PIEACK.all = PIEACK_GROUP3;
}
按照上面的设置,应该得到,10M,占空比为25%的PWM,但是结果不是,而是1M左右的PWM,好像占空比也没有改变,这是为何?清高手指教 |