Recent Posts

Pages: [1] 2 3 ... 10
1
Vanakkam samyooo sangam na thalaivar irukkanum it na Evil irukkanum
Intha varam naan keka virumbum padam kayal
Naan keka virumbum paadal yenge pulla irukka song

Intha song namma ftc nanbargalukum pidikum nu ninaikiren
Rj mandakasayam machi pona varam taru maru takkali soru pannitinga dj Tejasvi neengalum kalakitinga smayoo
2
அன்று கருவில் சுமந்த தாயே
இன்று  கையில் சுமந்தாயே

உன்  மடியில்  என்னை  தாலாட்டினாயே
 தூக்கம் தொலைத்து தூங்க வைத்தாயே

என் அழுகை கண்டு பதறியதாயே 
பசியறியா எனக்கு பாலூட்டினாயே

அம்மா என்றதும் ஆனந்தம் அடைந்தாயே
அன்பால் என்றும் அரவணைத்தாயே

பண்பை எனக்கு போதித்தாயே
பணிவோடு வாழ கற்று கொடுத்தாயே

முத்தமிட்டு முத்தமிட்டு அன்பை பொழிந்தாயே
என் மழலை மொழி கேட்டு  முகம் மலந்தாயே

முத்தம் கேட்டு முத்தம் பெற்று
என்னோடு விளையாடிய தாயே

ஒரு கண்ணம் முத்தமிட்டல் மறு கண்ணம் முத்தமென்று
குழந்தையாய் மாறி மகிழ்ந்தாயே

என் தாயின்  மகிழ்ச்சி  எல்லாம்
நான் கொடுக்கும் முத்தமே...
3
GENERAL / Re: The Minds Journal
« Last post by சாக்ரடீஸ் on November 07, 2025, 11:29:39 AM »
4
Final Output  8)


Here is the result. The LED is blinking at a constant rate of 2Hz, i.e. with a delay of 500ms. A 2.2K resistor is used as a current limit resistor to protect the LED.



Final Code

Code: [Select]
#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);
    }

}

5
Uploading Code to Megawin Microcontroller

As we have already established there are multiple ways to upload the code to the MG82F6D17. Through OCD ICE or ISP Programmer or through UART. We will be showing two methods that include using OCD ICE and UART.

Using OCD ICE Adapter

First to uploading using OCD ICE, connect the OCD pins of the microcontroller to the OCD ICE adapter as shown below-


For MG82F6D17, we will only be using five lines including the VDD and GND. The CLK pin is not used in this case. To open the programmer UI, you can run ICPProgremmer.exe directly from the Database Installer folder from (EN)8051_OCD_ICE_For_Keil_v3.19.0.4.zip file or from the Keil installation directory (for me it was C:\Keil_v5\C51\INC\Megawin\ ICPProgrammer.exe). Select the Correct MCU Part Number



Click “Load File” and choose loading AP(Code) or IAP(Data). “Load File” can be clicked repeatedly to load different files. While loading IAP(Data), users have to key in Address. HEX and BIN data formats are supported for file loading.



Click “Insert ISP-Code” may choose to insert Megawin-provided ISP code or User-defined ISP code. If the ISP function is not needed, this step can be omitted.



H/W Option Setting let you configure ISP memory, IAP memory and fuse bits. Click on Update target to upload the firmware.









6
ஆன்மீகம் - Spiritual / Re: BIBLE VERSE of THE Day ✝️ 🙏
« Last post by MysteRy on November 07, 2025, 10:58:13 AM »
7
ஆன்மீகம் - Spiritual / Re: THOUGHT for Today ✝️🙏
« Last post by MysteRy on November 07, 2025, 10:56:12 AM »
8
ஆன்மீகம் - Spiritual / Re: MORNING PRAYER ✝️ 🙏
« Last post by MysteRy on November 07, 2025, 10:54:01 AM »
9
💡 LED Blinking Program on Megawin MG82F6D17

Now that we have finished setting up the IDE, let’s get into the coding part. 
Below is the sample LED Blink Code for the MG82F6D17 microcontroller.

Code: [Select]
#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);
    }
}

🧩 Code Explanation

Header and Definitions:
Code: [Select]
#include "MG82F6D17_CONFIG.h"
#define MCU_SYSCLK      12000000
#define MCU_CPUCLK      (MCU_SYSCLK)
#define LED_Pin         P33

In the header section, 
#include "MG82F6D17_CONFIG.h" adds all the necessary SPLs, header files, and definitions for the chip.

#define MCU_SYSCLK 12000000 sets the system oscillator frequency to 12 MHz. 
The CPU frequency is later multiplied using PLL up to 32 MHz (defined as MCU_CPUCLK).

---

⏱ Delay Functions

The delay functions are simple, software-based delays — no timers are used. 
They generate microsecond and millisecond delays using the [_nop_()] instruction. 
The number of [_nop_()] calls depends on the system clock frequency.

Microsecond Delay Function:
Code: [Select]
void DelayXus(u8 xUs)
{
    while(xUs!=0)
    {
        // Frequency-based delay using NOPs
        ...
        xUs--;
    }
}

Millisecond Delay Function: 
This calls the microsecond delay several times to approximate a 1 ms delay.
Code: [Select]
void DelayXms(u16 xMs)
{
    while(xMs!=0)
    {
        DelayXus(200);
        DelayXus(200);
        DelayXus(200);
        DelayXus(200);
        DelayXus(200);
        xMs--;
    }
}

Note: These are software delays, so they are not perfectly accurate — the precision depends on CPU frequency and compiler optimization.

---

🔁 Main Function

The main() function is straightforward because most of the system configuration is handled by the Megawin SPL.

Code: [Select]
void main ()
{
    System_Init();          // Initialize system registers and clock
    while(1)
    {
        LED_Pin = !LED_Pin; // Toggle LED pin
        DelayXms(500);      // Wait for 500 ms
    }
}

System_Init() is part of the Megawin driver and handles clock setup, I/O initialization, and system configuration automatically.

The loop simply toggles the LED connected to P3.3 every 500 ms — making it blink continuously. 

---

Summary
  • We used the MG82F6D17 Driver to simplify system setup.
  • The LED blink is achieved by toggling P3.3 and using software delay functions.
  • In future examples, we will use hardware timers for more accurate delays and better CPU performance.

Now let’s compile the program and see if there are any errors. For that click on Build Target from the Project menu or simply press the F7 key. If there are no errors the IDE will compile the code and generate the HEX file which can be found in the Object folder within the project folder.



That’s it! You’ve successfully written your first LED blinking program for the MG82F6D17 MCU!
10
🚀 Step-by-Step Working Procedure: Schematics for the Blink Example



Added a led and current limiting resistor to the Pin P3.3.


Here is the hardware setup. I used a SSOP to DIP adapter to use it with the breadboard. As shown in the schematics LED is connected to the pin P3.3 through a 2.2K resistor.


You can follow the circuit given above and make the connections, I have built everything on a breadboard and have also connected my programmer to the microcontroller. The set-up looks like this as shown above.
Pages: [1] 2 3 ... 10