Using a Timer Without An IRQ

	//Setup the timer
	OpenTimer2((T2_ON | T2_IDLE_CON | T2_GATE_OFF | T2_PS_1_1 | T2_32BIT_MODE_OFF | T2_SOURCE_INT), 100);

	INTClearFlag(INT_T2);
	
	//Wait for timer to loop
	while (!INTGetFlag(INT_T2))
		;
	INTClearFlag(INT_T2);

 

Faster Bit Test Of IRQ Flag

The INTGetFlag() function is not particuarly fast.  If you want very tight timing then do a bit test instead:


	//Wait for timer to loop
	//while (!INTGetFlag(INT_T2))
	//	;
	//T2 is IFS0<8>
	while (!(IFS0 & 0x0100))
		;

 

USEFUL?
We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.

Comments

Your email address will not be published. Required fields are marked *