C program to read Channel 4 of the HC12 A/D in 8-bit mode

C program ad.c
/* Read temperature from PAD4.  Turn on heater if temp too low,
 * turn off heater if temp too high.  Heater connected to Bit 0
 * of Port A.
 */
#include "hc12.h"

#define TRUE 1
#define SET_POINT 72	/* Temp at which to turn heater on or off */

main()
{
	ATDCTL2 = 0x80;  /* Power up A/D, no interrupts */
	ATDCTL4 = 0x01;	 /* 9 us/conversion, 8-bit mode */
	ATDCTL5 = 0x64;  /* 0 1 1 0 0 1 0 0
						  | | | \____/
						  | | |    |
						  | | |    \___  Bit 4 of Port AD
						  | | \________  Mult = 0 => one channel only
						  | \__________  Scan = 1 => continuous conversion
						  \____________  S8CM => do eight conversions
				 	*/
/**************************************************************************/

	DDRA = 0xff;	/* Make Port A output */
	PORTA = 0x00;   /* Turn off heater */

/*****************************************************************************/

	while (TRUE) 
	{
		if (ADR0H > SET_POINT)
			PORTA &= ~0x01;
		else
			PORTA |= 0x01;
	}
}