<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>잡다한 인생</title>
    <link>https://electro-don.tistory.com/</link>
    <description></description>
    <language>ko</language>
    <pubDate>Sun, 12 Jul 2026 06:19:12 +0900</pubDate>
    <generator>TISTORY</generator>
    <ttl>100</ttl>
    <managingEditor>쿨한넘</managingEditor>
    <item>
      <title>get crossworks to work on 64-bit mint linux</title>
      <link>https://electro-don.tistory.com/entry/get-crossworks-to-work-on-64bit-mint-linux</link>
      <description>&lt;p style=&quot;margin: 0px 0px 12px; padding: 2px 0px 1px;&quot;&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;&lt;span style=&quot;line-height: 17.3999996185303px;&quot;&gt;계속 libusb-0.1-4.so 가 없다고 불평을 늘어 놓더니...&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 12px; padding: 2px 0px 1px;&quot;&gt;&lt;span style=&quot;line-height: 17.3999996185303px; font-family: Arial, Helvetica, sans-serif; font-size: 9pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 12px; padding: 2px 0px 1px;&quot;&gt;&lt;span style=&quot;line-height: 17.3999996185303px; font-family: 'Courier New'; font-size: 9pt;&quot;&gt;sudo apt-get install lib32asound2 lib32gcc1 lib32ncurses5 lib32stdc++6 lib32z1 libc6-i386 ia32-libs&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin: 0px 0px 12px; padding: 2px 0px 1px;&quot;&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;&lt;span style=&quot;line-height: 17.3999996185303px; font-family: 'Courier New';&quot;&gt;sudo apt-get install libstdc++6:i386 libxft2:i386 libxext6:i386 libusb-0.1-4:i386&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;&lt;p style=&quot;margin: 0px 0px 12px; padding: 2px 0px 1px;&quot;&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;&lt;span style=&quot;line-height: 17.3999996185303px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;&lt;p style=&quot;margin: 0px 0px 12px; padding: 2px 0px 1px;&quot;&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;&lt;span style=&quot;line-height: 17.3999996185303px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;</description>
      <author>쿨한넘</author>
      <guid isPermaLink="true">https://electro-don.tistory.com/82</guid>
      <comments>https://electro-don.tistory.com/entry/get-crossworks-to-work-on-64bit-mint-linux#entry82comment</comments>
      <pubDate>Thu, 23 Jul 2015 00:26:48 +0900</pubDate>
    </item>
    <item>
      <title>맥 바탕화면에서 .DS_Store 숨기기</title>
      <link>https://electro-don.tistory.com/entry/%EB%A7%A5-%EB%B0%94%ED%83%95%ED%99%94%EB%A9%B4%EC%97%90%EC%84%9C-DSStore-%EC%88%A8%EA%B8%B0%EA%B8%B0</link>
      <description>&lt;p&gt;갑자기 mac에서 .DS_Store 화일이 보일 때, 터미널에서...&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: 'Courier New';&quot;&gt;defaults write com.apple.finder AppleShowAllFiles FALSE&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: 'Courier New';&quot;&gt;killall Finder&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <author>쿨한넘</author>
      <guid isPermaLink="true">https://electro-don.tistory.com/81</guid>
      <comments>https://electro-don.tistory.com/entry/%EB%A7%A5-%EB%B0%94%ED%83%95%ED%99%94%EB%A9%B4%EC%97%90%EC%84%9C-DSStore-%EC%88%A8%EA%B8%B0%EA%B8%B0#entry81comment</comments>
      <pubDate>Thu, 16 Apr 2015 16:03:09 +0900</pubDate>
    </item>
    <item>
      <title>floating point value에 대해서.</title>
      <link>https://electro-don.tistory.com/entry/floating-point-value%EC%97%90-%EB%8C%80%ED%95%B4%EC%84%9C</link>
      <description>&lt;p&gt;csapp2e를 보다가 작성해서&amp;nbsp;테스트 해 본 코드.&lt;/p&gt;&lt;p&gt;math.h에 NAN은0x7fc00000 로 정의되어 있다. 그러나 이&amp;nbsp;floating point 밸류를 NAN과 비교해 판별하면 무조건 다르게 나온다는 점. NaN을 판별하려면 isnan() 함수를 사용하거나, exponent bits를 봐야 할 듯.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;brush: plain; smart-tabs: true; tab-size: 4; toolbar: false; auto-links: true&quot;&gt;//
//  main.c
//  floatingpoint_bits
//
//  Created by Seong-Su Kim on 2015. 3. 9..
//  Copyright (c) 2015년 Seong-Su Kim. All rights reserved.
//

#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;math.h&amp;gt;


void printfpValue(float fvalue);
void printbitsValue(unsigned bits);
void isNaN(unsigned bits);


int main(void)
{
	unsigned long count;
	unsigned long start, end;

	
	printf(&quot;\n# predefined values\n\n&quot;);
	printfpValue(NAN);
	printfpValue(INFINITY);

	if (NAN == NAN)
		printf(&quot;NAN == NAN!\n&quot;);	// will be never executed
	
	printf(&quot;\n\n# user bits to floating point value\n\n&quot;);
	printbitsValue(0xff800000); isNaN(0xff800000);
	printbitsValue(0x7f800001); isNaN(0x7f800001);
	printbitsValue(0x7fc00000); isNaN(0x7fc00000);
	printbitsValue(0xff800001); isNaN(0xff800001);
	

	printf(&quot;enter start value : &quot;);
	scanf(&quot;%lx&quot;, &amp;amp;start);
	printf(&quot;start value = %#lx\n&quot;, start);
	
	printf(&quot;enter end value : &quot;);
	scanf(&quot;%lx&quot;, &amp;amp;end);
	printf(&quot;end value = %#lx\n&quot;, start);
	
	for (count = start; count &amp;lt;= end; count++)
		printbitsValue((unsigned)count);
	
	return 0;
}


void printfpValue(float fvalue)
{
	unsigned *bp;

	bp = (unsigned *)(&amp;amp;fvalue);

	printf(&quot;%0#10x = %12e\n&quot;, *bp, fvalue);
}


void printbitsValue(unsigned bits)
{
	float *fp;
	
	fp = (float *)(&amp;amp;bits);
	
	printf(&quot;%0#10x = %12e\n&quot;, bits, *fp);

}


void isNaN(unsigned bits)
{
	float *fp;
	
	fp = (float *)(&amp;amp;bits);
	
	if (*fp == NAN)
		printf(&quot;%e == NAN,\t&quot;, *fp);
	else
		printf(&quot;%e != NAN,\t&quot;, *fp);

	
	if (isnan(*fp))
		printf(&quot;isnan() says it is NaN.\n\n&quot;);
	else
		printf(&quot;isnan() says it is not NaN.\n\n&quot;);

}
&lt;/pre&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <author>쿨한넘</author>
      <guid isPermaLink="true">https://electro-don.tistory.com/80</guid>
      <comments>https://electro-don.tistory.com/entry/floating-point-value%EC%97%90-%EB%8C%80%ED%95%B4%EC%84%9C#entry80comment</comments>
      <pubDate>Tue, 10 Mar 2015 01:16:27 +0900</pubDate>
    </item>
    <item>
      <title>compute GCD with Euclid's algorithms</title>
      <link>https://electro-don.tistory.com/entry/compute-GCD-with-Euclids-algorithms</link>
      <description>&lt;p&gt;ARM assembly를 좋아하지 않을 수 있을리가...&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;brush: plain; smart-tabs: true; tab-size: 4; toolbar: false; auto-links: true&quot;&gt;	// Get Greatest Common Divider (GCD)
	// using Euclid's algorithm
	//
	// while (a != b) {
	//	if (a &amp;gt; b)
	//		a = a - b;
	//	else
	//		b = b - a;
	// }

	.global	example8_5
	.global	gcd

example8_5:
gcd:
	cmp  	r0, r1
	subgt	r0, r1			// if r0 &amp;gt; r1, r0 -= r1
	sublt	r1, r0			// if r0 &amp;lt; r1, r1 -= r0
	bne	gcd

	bx  	lr			// if r0 == r1, return

	.end
&lt;/pre&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;/div&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>book/ARM Assembly Language, 2e</category>
      <author>쿨한넘</author>
      <guid isPermaLink="true">https://electro-don.tistory.com/79</guid>
      <comments>https://electro-don.tistory.com/entry/compute-GCD-with-Euclids-algorithms#entry79comment</comments>
      <pubDate>Mon, 16 Feb 2015 14:55:15 +0900</pubDate>
    </item>
    <item>
      <title>XMEGA clock setup</title>
      <link>https://electro-don.tistory.com/entry/XMEGA-clock-setup</link>
      <description>&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;마땅히 새로운게 없어 살펴보고 있는 xmega.&lt;/p&gt;&lt;p&gt;쓰면서 느끼지만, 호화스러운 페리페럴들. 럭져리한 경차 같은 느낌이다. atmega와 유사하지만, 레지스터들이 상당히 많아서 효율좋은 코드가 가능할 것 같다.&lt;/p&gt;&lt;p&gt;프로세서는 역시 클럭 셋팅부터. application note avr1003을 참조...라기보다는 걍 거의 그대로 가져다 써서 테스트. 아래 코드로&amp;nbsp;네가지의 클럭셋팅을 순서대로 돌아가며 사용하였다. 조금 신경을 써야 할 부분은, 페리페럴 클럭들이다. CLKper2와 CLKper4는 고클럭세팅전에 반드시 낮춰놓고 나중에 다시 맞게 세팅해야한다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;pre class=&quot;brush: plain; smart-tabs: true; tab-size: 4; toolbar: false; auto-links: true&quot;&gt;/*
 * avr1003_dons.c
 *
 * Created: 2014-08-28 오후 11:23:31
 *  Author: Don Quixote
 */
#include &amp;lt;avr/io.h&amp;gt;
#include &amp;lt;avr/interrupt.h&amp;gt;
#include &amp;lt;util/delay.h&amp;gt;

/* The LED to use for visual feedback. */
#define LEDPORT		PORTE
#define LEDMASK		0xFF

/* Which switches to listen to */
#define SWITCHPORT	PORTD
#define SWITCHMASK	0xFF

/*! \brief Define the delay_us macro for GCC. */
#define delay_us(us)	(_delay_us(us))

/* Definitions of macros. */

/*! \brief This macro enables the selected oscillator.
 *
 *  \note Note that the oscillator cannot be used as a main system clock
 *        source without being enabled and stable first. Check the ready flag
 *        before using the clock. The function CLKSYS_IsReady( _oscSel )
 *        can be used to check this.
 *
 *  \param  _oscSel Bitmask of selected clock. Can be one of the following
 *                  OSC_RC2MEN_bm, OSC_RC32MEN_bm, OSC_RC32KEN_bm, OSC_XOSCEN_bm,
 *                  OSC_PLLEN_bm.
 */
#define	CLKSYS_Enable(_oscSel)		(OSC.CTRL |= (_oscSel))

/*! \brief This macro check if selected oscillator is ready.
 *
 *  This macro will return non-zero if is is running, regardless if it is
 *  used as a main clock source or not.
 *
 *  \param _oscSel Bitmask of selected clock. Can be one of the following
 *                 OSC_RC2MEN_bm, OSC_RC32MEN_bm, OSC_RC32KEN_bm, OSC_XOSCEN_bm,
 *                 OSC_PLLEN_bm.
 *
 *  \return  Non-zero if oscillator is ready and running.
 */
#define	CLKSYS_IsReady(_oscSel)		(OSC.STATUS &amp;amp; (_oscSel))

/*! \brief This macro will protect the following code from interrupts. */
#define	AVR_ENTER_CRITICAL_REGION()	uint8_t volatile saved_sreg = SREG; \
									cli();
/*! \brief This macro must always be used in conjunction with AVR_ENTER_CRITICAL_REGION
 *        so the interrupts are enabled again.
 */
#define	AVR_LEAVE_CRITICAL_REGION()	SREG = saved_sreg;


void clk32m_setup(void);
void timer_setup(void);
void Port_setup(void);
void WaitForSwitches(void);

void CLKSYS_Prescalers_Config(CLK_PSADIV_t PSAfactor,
				CLK_PSBCDIV_t PSBCfactor);
uint8_t CLKSYS_Main_ClockSource_Select(CLK_SCLKSEL_t clockSource);
uint8_t CLKSYS_Disable(uint8_t oscSel);
void CLKSYS_PLL_Config(OSC_PLLSRC_t clockSource, uint8_t factor);
void CCPWrite(volatile uint8_t* address, uint8_t value);

void clk_32m(void);
void clk_pll30m(void);
void clk_2m(void);
void clk_32k(void);
void clk_pll32m(void);


int main(void)
{
	Port_setup();
	timer_setup();

	/* Enable low interrupt level in PMIC and enable global interrupts. */
	PMIC.CTRL |= PMIC_MEDLVLEN_bm;
	sei();

	while (1) {
		WaitForSwitches();
		LEDPORT.OUT = ~0x01 &amp;amp; 0x0f;
		clk_pll30m();


		WaitForSwitches();
		LEDPORT.OUT = ~0x02 &amp;amp; 0x0f;
		clk_32m();


		WaitForSwitches( );
		LEDPORT.OUT = ~0x04 &amp;amp; 0x0f;
		clk_pll32m();


		WaitForSwitches();
		LEDPORT.OUT = ~0x08 &amp;amp; 0x0f;
		clk_2m();
	}
}


/*! Just toggle LED(s) when interrupt occurs. */
ISR(TCC0_OVF_vect)
{
	LEDPORT.OUTTGL = 0xf0;
}


void timer_setup(void)
{
	/* Set up Timer/Counter 0 to work from CPUCLK/64, with period 10000 and
	 * enable overflow interrupt.
	 */
	TCC0.PER = 20000;
	TCC0.CTRLA = ( TCC0.CTRLA &amp;amp; ~TC0_CLKSEL_gm ) | TC_CLKSEL_DIV64_gc;
	TCC0.INTCTRLA = ( TCC0.INTCTRLA &amp;amp; ~TC0_OVFINTLVL_gm )
			| TC_OVFINTLVL_MED_gc;

}


void clk32m_setup(void)
{
	// enable 32Mhz internal osc.
	OSC.CTRL |= OSC_RC32MEN_bm;

	// check whether the 32Mhz internal clock
	while ((OSC.STATUS &amp;amp; OSC_RC32MRDY_bm) == 0);


}


/*
 *	setup LED port and switch port
 */
void Port_setup(void)
{

	/* Set up user interface. */
	LEDPORT.DIRSET = LEDMASK;
	LEDPORT.OUTSET = 0xf7;

	/* PORTC pin7 set to output */
	PORTC.DIRSET = 0x80;
	
	/* clkout on portc */
	PORTCFG.CLKEVOUT |= 0x01;
	
	SWITCHPORT.DIRCLR = SWITCHMASK;		// set input
	SWITCHPORT.PIN0CTRL = (SWITCHPORT.PIN0CTRL &amp;amp; ~PORT_OPC_gm)
				| PORT_OPC_PULLUP_gc;

}


void waitBtnPressed(void)
{
	while (1) {
		if ((SWITCHPORT.IN &amp;amp; 0x01) == 0x00) {
			_delay_ms(10);
			if ((SWITCHPORT.IN &amp;amp; 0x01) == 0x00)
				return;
		}
	}
}


void waitBtnRelesed(void)
{
	while (1) {

		if ((SWITCHPORT.IN &amp;amp; 0x01) == 0x01) {
			_delay_ms(10);
			if ((SWITCHPORT.IN &amp;amp; 0x01) == 0x01)
				return;
		}	
	}
}


/*! \brief This function waits for a button push and release before proceeding.
 */
void WaitForSwitches(void)
{
	waitBtnPressed();
	waitBtnRelesed();
	/*
	while ((SWITCHPORT.IN &amp;amp; 0x01) == 0x01);
	_delay_ms(10);
	while ((SWITCHPORT.IN &amp;amp; 0x01) == 0x00);
	_delay_ms(10);
	*/
}


/*! \brief This function changes the prescaler configuration.
 *
 *  Change the configuration of the three system clock
 *  prescaler is one single operation. The user must make sure that
 *  the main CPU clock does not exceed recommended limits.
 *
 *  \param  PSAfactor   Prescaler A division factor, OFF or 2 to 512 in
 *                      powers of two.
 *  \param  PSBCfactor  Prescaler B and C division factor, in the combination
 *                      of (1,1), (1,2), (4,1) or (2,2).
 */
void CLKSYS_Prescalers_Config(CLK_PSADIV_t PSAfactor,
                               CLK_PSBCDIV_t PSBCfactor)
{
	uint8_t PSconfig = (uint8_t) PSAfactor | PSBCfactor;
	CCPWrite(&amp;amp;CLK.PSCTRL, PSconfig);
}


/*! \brief This function selects the main system clock source.
 *
 *  Hardware will disregard any attempts to select a clock source that is not
 *  enabled or not stable. If the change fails, make sure the source is ready
 *  and running and try again.
 *
 *  \param  clockSource  Clock source to use as input for the system clock
 *                       prescaler block.
 *
 *  \return  Non-zero if change was successful.
 */
uint8_t CLKSYS_Main_ClockSource_Select(CLK_SCLKSEL_t clockSource)
{
	uint8_t clkCtrl = (CLK.CTRL &amp;amp; ~CLK_SCLKSEL_gm) | clockSource;

	CCPWrite(&amp;amp;CLK.CTRL, clkCtrl);
	clkCtrl = (CLK.CTRL &amp;amp; clockSource);

	return clkCtrl;
}


/*! \brief This function disables the selected oscillator.
 *
 *  This function will disable the selected oscillator if possible.
 *  If it is currently used as a main system clock source, hardware will
 *  disregard the disable attempt, and this function will return zero.
 *  If it fails, change to another main system clock source and try again.
 *
 *  \param oscSel  Bitmask of selected clock. Can be one of the following
 *                 OSC_RC2MEN_bm, OSC_RC32MEN_bm, OSC_RC32KEN_bm,
 *                 OSC_XOSCEN_bm, OSC_PLLEN_bm.
 *
 *  \return  Non-zero if oscillator was disabled successfully.
 */
uint8_t CLKSYS_Disable(uint8_t oscSel)
{
	OSC.CTRL &amp;amp;= ~oscSel;
	uint8_t clkEnabled = OSC.CTRL &amp;amp; oscSel;

	return clkEnabled;
}


/*! \brief This function configures the internal high-frequency PLL.
 *
 *  Configuration of the internal high-frequency PLL to the correct
 *  values. It is used to define the input of the PLL and the factor of
 *  multiplication of the input clock source.
 *
 *  \note Note that the oscillator cannot be used as a main system clock
 *        source without being enabled and stable first. Check the ready flag
 *        before using the clock. The macro CLKSYS_IsReady( _oscSel )
 *        can be used to check this.
 *
 *  \param  clockSource Reference clock source for the PLL,
 *                      must be above 0.4MHz.
 *  \param  factor      PLL multiplication factor, must be
 *                      from 1 to 31, inclusive.
 */
void CLKSYS_PLL_Config(OSC_PLLSRC_t clockSource, uint8_t factor)
{
	factor &amp;amp;= OSC_PLLFAC_gm;
	OSC.PLLCTRL = (uint8_t)clockSource | (factor &amp;lt;&amp;lt; OSC_PLLFAC_gp);
}


/*! \brief CCP write helper function written in assembly.
 *
 *  This function is written in assembly because of the timecritial
 *  operation of writing to the registers.
 *
 *  \param address A pointer to the address to write to.
 *  \param value   The value to put in to the register.
 */
void CCPWrite(volatile uint8_t* address, uint8_t value)
{
	AVR_ENTER_CRITICAL_REGION( );
	volatile uint8_t* tmpAddr = address;
#ifdef RAMPZ
	RAMPZ = 0;
#endif
	asm volatile(
		&quot;movw	r30, %0&quot;	&quot;\n\t&quot;
		&quot;ldi	r16, %2&quot;	&quot;\n\t&quot;
		&quot;out	%3, r16&quot;	&quot;\n\t&quot;
		&quot;st	Z, %1&quot;		&quot;\n\t&quot;
		:
		: &quot;r&quot; (tmpAddr), &quot;r&quot; (value), &quot;M&quot; (CCP_IOREG_gc), &quot;i&quot; (&amp;amp;CCP)
		: &quot;r16&quot;, &quot;r30&quot;, &quot;r31&quot;
	);

	AVR_LEAVE_CRITICAL_REGION( );
}


void clk_32m(void)
{
	/*  Enable internal 32 MHz ring oscillator and wait until it's
	 *  stable. Divide clock by two with the prescaler C and set the
	 *  32 MHz ring oscillator as the main clock source. Wait for
	 *  user input while the LEDs toggle.
	 */
	CLKSYS_Enable(OSC_RC32MEN_bm);
	while (CLKSYS_IsReady(OSC_RC32MRDY_bm) == 0);
	CLKSYS_Main_ClockSource_Select(CLK_SCLKSEL_RC32M_gc);
	CLKSYS_Prescalers_Config(CLK_PSADIV_1_gc, CLK_PSBCDIV_1_1_gc);
	CLKSYS_Disable(OSC_PLLEN_bm | OSC_XOSCEN_bm | OSC_RC32KEN_bm | OSC_RC2MEN_bm);
}


void clk_pll30m(void)
{
	/*  Configure PLL with the 2 MHz RC oscillator as source and
	 *  multiply by 30 to get 60 MHz PLL clock and enable it. Wait
	 *  for it to be stable and set prescaler C to divide by two
	 *  to set the CPU clock to 30 MHz. Disable unused clock and
	 *  wait for user input.
	 */
	CLKSYS_PLL_Config(OSC_PLLSRC_RC2M_gc, 30);
	CLKSYS_Enable(OSC_PLLEN_bm);
	while (CLKSYS_IsReady(OSC_PLLRDY_bm) == 0);
	CLKSYS_Prescalers_Config(CLK_PSADIV_2_gc, CLK_PSBCDIV_2_2_gc);
	CLKSYS_Main_ClockSource_Select(CLK_SCLKSEL_PLL_gc);
	CLKSYS_Prescalers_Config(CLK_PSADIV_1_gc, CLK_PSBCDIV_1_2_gc);
	CLKSYS_Disable(OSC_XOSCEN_bm | OSC_RC32KEN_bm | OSC_RC32MEN_bm);
}


void clk_pll32m(void)
{
	CLKSYS_Enable(OSC_RC32MEN_bm);
	while (CLKSYS_IsReady(OSC_RC32MRDY_bm) == 0);
	CLKSYS_Prescalers_Config(CLK_PSADIV_2_gc, CLK_PSBCDIV_2_2_gc);

	CLKSYS_PLL_Config(OSC_PLLSRC_RC32M_gc, 16);
	CLKSYS_Enable(OSC_PLLEN_bm);
	while (CLKSYS_IsReady(OSC_PLLRDY_bm) == 0);
	CLKSYS_Main_ClockSource_Select(CLK_SCLKSEL_PLL_gc);
	CLKSYS_Prescalers_Config(CLK_PSADIV_1_gc, CLK_PSBCDIV_2_2_gc);	
	CLKSYS_Disable(OSC_XOSCEN_bm | OSC_RC32KEN_bm | OSC_RC2MEN_bm);

}


void clk_2m(void)
{
	/*  Select 2 MHz RC oscillator as main clock source and diable
	 *  unused clock.
	 */
	CLKSYS_Enable(OSC_RC2MEN_bm);
	while (CLKSYS_IsReady(OSC_RC2MRDY_bm) == 0);

	CLKSYS_Main_ClockSource_Select(CLK_SCLKSEL_RC2M_gc);
	CLKSYS_Prescalers_Config(CLK_PSADIV_1_gc, CLK_PSBCDIV_1_1_gc);	
	CLKSYS_Disable(OSC_PLLEN_bm | OSC_XOSCEN_bm | OSC_RC32KEN_bm | OSC_RC32MEN_bm);
}


void clk_32k(void)
{
	/*  Enable internal 32 kHz calibrated oscillator and check for
	 *  it to be stable and set prescaler A, B and C to none. Set
	 *  the 32 kHz oscillator as the main clock source. Wait for
	 *  user input while the LEDs toggle.
	 */
	CLKSYS_Enable(OSC_RC32KEN_bm);
	while (CLKSYS_IsReady(OSC_RC32KRDY_bm) == 0);
	CLKSYS_Main_ClockSource_Select(CLK_SCLKSEL_RC32K_gc);
	CLKSYS_Disable(OSC_XOSCEN_bm | OSC_PLLEN_bm);
	CLKSYS_Prescalers_Config(CLK_PSADIV_1_gc, CLK_PSBCDIV_1_1_gc);
}
&lt;/pre&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;/div&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <author>쿨한넘</author>
      <guid isPermaLink="true">https://electro-don.tistory.com/78</guid>
      <comments>https://electro-don.tistory.com/entry/XMEGA-clock-setup#entry78comment</comments>
      <pubDate>Mon, 1 Sep 2014 11:59:01 +0900</pubDate>
    </item>
  </channel>
</rss>