Ejemplo n.º 1
0
// Connected to INT13 of CPU (use MINT13 mask):
// ISR can be used by the user.
__interrupt void INT13_ISR(void)     // INT13 or CPU-Timer1
{
	 //***********************************WARNING!!********************************************\\
	//BE CAREFUL YOU NEED TO ALLOW NESTING FOR ANY INTERRUPT THAT MIGHT HAPPEN IN THIS INTERRUPT\\

	 EINT;		//enable all interrupts

	//todo USER: Define Clock ISR
	Clock_Ticks.DataOut++;
	Clock_Ticks.HeartBeat++;

	if (Clock_Ticks.DataOut >= DATAOUT_TICKS)
	{
		//send data or fill data
		Clock_Ticks.DataOut = 0;
	}

	if (Clock_Ticks.HeartBeat >= HEARTBEAT_TICKS)
	{
		HeartBeat();
		Clock_Ticks.HeartBeat = 0;
	}

	Buttons();

	ReloadCpuTimer1();
	StartCpuTimer1();

	DINT;
}
Ejemplo 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;
}
Ejemplo n.º 3
0
void ClockSetup()
{
	Clock.RegsAddr = &CpuTimer1Regs;
	// Initialize timer period to maximum:
	CpuTimer1Regs.PRD.all  = 0xFFFFFFFF;
	// Initialize pre-scale counter to divide by 1 (SYSCLKOUT):
	CpuTimer1Regs.TPR.all  = 0;
	CpuTimer1Regs.TPRH.all = 0;
	// Make sure timer is stopped:
	CpuTimer1Regs.TCR.bit.TSS = 1;
	// Reload all counter register with period value:
	CpuTimer1Regs.TCR.bit.TRB = 1;
	// Reset interrupt counters:
	Clock.InterruptCount = 0;

	ConfigCpuTimer(&Clock,CPU_FREQ_MHZ, CLOCK_PERIOD);

	//pie interrupt
	IER |= M_INT13;

	ReloadCpuTimer1();
	StartCpuTimer1();
}