Exemplo n.º 1
0
void StopWatchSetUp(float time)
{
    // CPU Timer0
    // Initialize address pointers to respective timer registers:
    StopWatch.RegsAddr = &CpuTimer0Regs;
    // Initialize timer period to maximum:
    CpuTimer0Regs.PRD.all  = 0xFFFFFFFF;
    // Initialize pre-scale counter to divide by 1 (SYSCLKOUT):
    CpuTimer0Regs.TPR.all  = 0;
    CpuTimer0Regs.TPRH.all = 0;
    // Make sure timer is stopped:
    CpuTimer0Regs.TCR.bit.TSS = 1;
    // Reload all counter register with period value:
    CpuTimer0Regs.TCR.bit.TRB = 1;
    // Reset interrupt counters:
    StopWatch.InterruptCount = 0;

    ConfigCpuTimer(&StopWatch,CPU_FREQ_MHZ , time);

    //pie interrupt
    IER |= M_INT1;
    PieCtrlRegs.PIEIER1.bit.INTx7 = 1;

    ReloadCpuTimer0();
    StartCpuTimer0();
}
Exemplo n.º 2
0
bool Timers::start(u_int16 tNum, u_int32 periodMc) {
	if (tNum == 0) {
		CPUTIMER[0].regs_addr->PRD.all = sysClockMhz * periodMc;
		ReloadCpuTimer0();
		StartCpuTimer0();
	}
	else {
		CPUTIMER[1].regs_addr->PRD.all = sysClockMhz * periodMc;
		ReloadCpuTimer1();
		StartCpuTimer1();
	}
	return true;
}