#include "PalmType.h"
#include "PalmChip.h"

void Run_22Mhz()
{
	XBYTE[PLL_BYPASS] &= 0xfe;
	XBYTE[PLL_CONWS] = 0x0; // 0 wait state
	XBYTE[PLL1_SUP] = 36;	// 12MHz * (37/20) = 22.2MHz
	XBYTE[PLL1_SDN] = 19;
	XBYTE[PLL1_MODE] = 0xd;	// 1101
	XBYTE[PLL_CTRL] &= 0xfe;

    while(!(XBYTE[PLL_CTRL] & 0x10));
	XBYTE[PLL_BYPASS] |= 0x01;	// use PLL1 as system clock 
}

// 45.6/22.2 = 2.054
void Run_46Mhz()
{
	XBYTE[PLL_CONWS] = 0x14; // 5 wait state
	XBYTE[PLL_BYPASS] &= 0xfe;
	XBYTE[PLL1_SUP] = 18;	// 12MHz * (19/5) = 41MHz
	XBYTE[PLL1_SDN] = 4;
	XBYTE[PLL1_MODE] = 0x0f;	// 0111
	XBYTE[PLL_CTRL] &= 0xfe;

    while(!(XBYTE[PLL_CTRL] & 0x10));
	XBYTE[PLL_BYPASS] |= 0x01;	// use PLL1 as system clock 
}



