11


#include "MG82F6D17_CONFIG.h"
#define MCU_SYSCLK 12000000
#define MCU_CPUCLK (MCU_SYSCLK)
#define LED_Pin P33
/*************************************************
µS Dealy Function
*************************************************/
void DelayXus(u8 xUs)
{
while(xUs!=0)
{
#if (MCU_CPUCLK>=11059200)
_nop_();
#endif
#if (MCU_CPUCLK>=14745600)
_nop_();
_nop_();
_nop_();
_nop_();
#endif
#if (MCU_CPUCLK>=16000000)
_nop_();
#endif
#if (MCU_CPUCLK>=22118400)
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
#endif
#if (MCU_CPUCLK>=24000000)
_nop_();
_nop_();
#endif
#if (MCU_CPUCLK>=29491200)
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
#endif
#if (MCU_CPUCLK>=32000000)
_nop_();
_nop_();
#endif
xUs--;
}
}
/*************************************************
mS Delay Function
*************************************************/
void DelayXms(u16 xMs)
{
while(xMs!=0)
{
DelayXus(200);
DelayXus(200);
DelayXus(200);
DelayXus(200);
DelayXus(200);
xMs--;
}
}
void main ()
{
System_Init();
while(1)
{
LED_Pin=!LED_Pin;
DelayXms(500);
}
}







#include "MG82F6D17_CONFIG.h"
#define MCU_SYSCLK 12000000
#define MCU_CPUCLK (MCU_SYSCLK)
#define LED_Pin P33
/*************************************************
µS Delay Function
*************************************************/
void DelayXus(u8 xUs)
{
while(xUs!=0)
{
#if (MCU_CPUCLK>=11059200)
_nop_();
#endif
#if (MCU_CPUCLK>=14745600)
_nop_();
_nop_();
_nop_();
_nop_();
#endif
#if (MCU_CPUCLK>=16000000)
_nop_();
#endif
#if (MCU_CPUCLK>=22118400)
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
#endif
#if (MCU_CPUCLK>=24000000)
_nop_();
_nop_();
#endif
#if (MCU_CPUCLK>=29491200)
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
#endif
#if (MCU_CPUCLK>=32000000)
_nop_();
_nop_();
#endif
xUs--;
}
}
/*************************************************
mS Delay Function
*************************************************/
void DelayXms(u16 xMs)
{
while(xMs!=0)
{
DelayXus(200);
DelayXus(200);
DelayXus(200);
DelayXus(200);
DelayXus(200);
xMs--;
}
}
void main ()
{
System_Init();
while(1)
{
LED_Pin = !LED_Pin;
DelayXms(500);
}
}
#include "MG82F6D17_CONFIG.h"
#define MCU_SYSCLK 12000000
#define MCU_CPUCLK (MCU_SYSCLK)
#define LED_Pin P33
void DelayXus(u8 xUs)
{
while(xUs!=0)
{
// Frequency-based delay using NOPs
...
xUs--;
}
}
void DelayXms(u16 xMs)
{
while(xMs!=0)
{
DelayXus(200);
DelayXus(200);
DelayXus(200);
DelayXus(200);
DelayXus(200);
xMs--;
}
}
void main ()
{
System_Init(); // Initialize system registers and clock
while(1)
{
LED_Pin = !LED_Pin; // Toggle LED pin
DelayXms(500); // Wait for 500 ms
}
}




MyFirstProject\
├── Source\
Code\Sample\Source
into your newly created Source folder.













