# 1 - Blink LED

> **MPLAB X IDE - PIC Assembler**
>
> [**PIC18F4550 / PIC18F45K50**](https://docs.microside.com/practicas/mplab-x-ide/pic-as-compiler/pic18f4550-or-pic18f45k50)

<figure><img src="/files/jHeveF1fZrB7PdDgq0eB" alt=""><figcaption></figcaption></figure>

## **Introducción**

La siguiente práctica es una de las más básicas en programación de microcontroladores, consiste en controlar el encendido y apagado de un LED cada determinado tiempo.

## **Descripción**

En esta práctica se utiliza el LED que se encuentra conectado al pin A4 de la tarjeta **X-TRAINER** con el **PIC18F4550/PIC18F45K50**. El pin A4 es configurado como salida y señal digital, de esta forma enciende y apaga el LED cada determinado tiempo.

**Materiales:**

1 x Tarjeta **X-TRAINER**. [**Manuales**](https://docs.microside.com/tarjetas-de-desarrollo/x-trainer) | [**Comprar**](https://www.microside.com/shop/category/entrenadores-pic-1)

1 x Cable micro USB.

**Software:**

Windows 8.1 o posterior.

MPLAB X IDE. [**Descarga**](https://www.microchip.com/mplab/mplab-x-ide)

Compilador XC8. [**Descarga**](https://www.microchip.com/en-us/development-tools-tools-and-software/mplab-xc-compilers)

X-TRAINER Suite v1.0 [**Descarga**](https://raw.githubusercontent.com/MICROSIDE-TECHNOLOGY/microside_download_archive/main/Tools/X-TRAINER%20Suite/X-TRAINER%20Suite%20Setup.zip)

## **Procedimiento**

**1.** En el apartado de “[**Diagrama Esquemático**](#diagrama-esquematico)” selecciona el modelo de tu tarjeta, realiza las conexiones que se muestran en la imagen y conéctala a la computadora.

{% hint style="info" %}
Las conexiones mostradas en los diagramas esquemáticos son las mismas ya sea que la tarjeta **X-TRAINER** posea el **PIC18F4550** o el **PIC18F45K50**.
{% endhint %}

**2.** Ejecuta **MPLAB X IDE** y crea un nuevo proyecto con el código fuente que se encuentra en el apartado "[**Código**](#codigo)".

**3.** Realiza los siguientes pasos para configurar el **bootloader** y poder programar la tarjeta **X-TRAINER**:

* Da clic en ***File*** y ***Project Properties***.

<figure><img src="/files/yCQFXtIip1lV4CiDYuz2" alt=""><figcaption></figcaption></figure>

* Selecciona ***Building***, marca la casilla ***Insert unprotected checksum in user ID memory*** y da clic en ***Apply***.

<figure><img src="/files/iKMBNtdaNcHekMgCv29a" alt=""><figcaption></figcaption></figure>

* Selecciona ***pic-as Linker**,* escribe **-mrom=2000-7F00** en el campo ***Additional options*** y da clic en ***Apply***.

<figure><img src="/files/Zrt6ppord0hoWZigKHm0" alt=""><figcaption></figcaption></figure>

**4.** Una vez realizadas las configuraciones del bootloader compila el proyecto.

{% hint style="success" %}
Para compilar el proyecto dirígete a la barra de herramientas superior y da clic en el icono señalado.
{% endhint %}

<figure><img src="/files/IQtyn5WSmgCY6PjrDRvd" alt=""><figcaption></figcaption></figure>

**5.**  Abre el **Software X-TRAINER Suite v1.0** en el apartado **PIC18F4550/45K50**, selecciona el archivo .hex generado al compilar el proyecto y programa la tarjeta.

{% hint style="success" %}
Si tienes dudas de cómo realizar los pasos anteriores puedes encontrar un manual del **Software X-TRAINER Suite v1.0**. a través del siguiente[ **link**](https://docs.microside.com/tarjetas-de-desarrollo/software-x-trainer-suite).
{% endhint %}

**6.** Al terminar de programar, la tarjeta **X-TRAINER** se reiniciará automáticamente y se ejecutará el programa de esta práctica.

## **Diagrama esquemático**

Selecciona el modelo de tu tarjeta **X-TRAINER.**

{% tabs %}
{% tab title="LITE M R2" %}

<figure><img src="https://raw.githubusercontent.com/MICROSIDE-TECHNOLOGY/1-Blink-LED-PIC-Assembler-PIC18F4550-45K50/main/Diagrama%20de%20conexión/X-TRAINER_PIC18F45K50_PIC18F4550_MICROSIDE_01.png" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="LITE M R3" %}

<figure><img src="/files/37rYL4uzBTSLpqIplPpK" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="LITE F" %}

<figure><img src="https://raw.githubusercontent.com/MICROSIDE-TECHNOLOGY/1-Blink-LED-PIC-Assembler-PIC18F4550-45K50/main/Diagrama%20de%20conexión/X-TRAINER_PIC18F45K50_MICROSIDE_02.png" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="DIP" %}

<figure><img src="https://raw.githubusercontent.com/MICROSIDE-TECHNOLOGY/1-Blink-LED-PIC-Assembler-PIC18F4550-45K50/main/Diagrama%20de%20conexión/X-TRAINER_DIP_Practica-1_Microside_01-768x175.png" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="DIP R3" %}

<figure><img src="/files/zf2uYygA3NBuDx3SZs8n" alt=""><figcaption></figcaption></figure>

{% endtab %}

{% tab title="PRO R2" %}

<figure><img src="https://raw.githubusercontent.com/MICROSIDE-TECHNOLOGY/1-Blink-LED-PIC-Assembler-PIC18F4550-45K50/main/Diagrama%20de%20conexión/X-TRAINER_PIC18F45K50_MICROSIDE_03.png" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="PRO R3" %}

<figure><img src="/files/K6QjoR01IKbvYn0LznP0" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="PRO R4" %}

<figure><img src="/files/jEBcNMDYhlQiLY4KUMoQ" alt=""><figcaption></figcaption></figure>
{% endtab %}
{% endtabs %}

## **Código**

{% tabs %}
{% tab title="PIC18F4550" %}
{% embed url="<https://gist.github.com/microside-mx/68e64526b4c6a2f6e0773ee5866665bf>" %}
{% endtab %}

{% tab title="PIC18F45K50" %}
{% embed url="<https://gist.github.com/microside-mx/b63d44da3154f9de5e8a2246eb4ef014>" %}
{% endtab %}
{% endtabs %}

## **Descargas**

<table data-card-size="large" data-view="cards"><thead><tr><th align="center"></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td align="center"><mark style="color:green;"><strong>Software X-TRAINER Suite v1.0</strong></mark></td><td><a href="https://raw.githubusercontent.com/MICROSIDE-TECHNOLOGY/microside_download_archive/main/Tools/X-TRAINER%20Suite/X-TRAINER%20Suite%20Setup.zip">https://raw.githubusercontent.com/MICROSIDE-TECHNOLOGY/microside_download_archive/main/Tools/X-TRAINER%20Suite/X-TRAINER%20Suite%20Setup.zip</a></td></tr><tr><td align="center"><mark style="color:green;"><strong>Proyecto</strong></mark></td><td><a href="https://github.com/MICROSIDE-TECHNOLOGY/1-Blink-LED-PIC-Assembler-PIC18F4550-45K50/archive/refs/heads/main.zip">https://github.com/MICROSIDE-TECHNOLOGY/1-Blink-LED-PIC-Assembler-PIC18F4550-45K50/archive/refs/heads/main.zip</a></td></tr></tbody></table>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.microside.com/practicas/mplab-x-ide/pic-as-compiler/pic18f4550-or-pic18f45k50/1-blink-led.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
