/**
******************************************************************************
* @file : main.c
* @author : Auto-generated by STM32CubeIDE
* @brief : Main program body
******************************************************************************
* @attention
*
* Copyright (c) 2026 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
#include <stdint.h>
#include "stm32f103xb.h"
#include "lcd.h"
void delay_ms(uint16_t ms);
void delay_us(uint16_t us);
int main(void)
{
RCC->APB2ENR |= 1 << 2; // Enable GPIOA clock
RCC->APB2ENR |= 1 << 4; // Enable GPIOC clock
// PC13 as 2MHz push-pull output
GPIOC->CRH &= ~(0x0F << 20);
GPIOC->CRH |= 1 << 21;
GPIOC->ODR |= (1 << 13);
LCD_Init();
LCD_SetCursor(0, 0);
LCD_Print("Hola Mundo");
LCD_SetCursor(0, 1);
LCD_Print("Juanpa"); // Nombre
// Loop
}
void delay_ms(uint16_t ms) {
volatile unsigned long t = 0;
for(uint16_t i = 0; i < ms; i++)
{
for(t = 0; t < 800; t++);
}
}
void delay_us(uint16_t us)
{
for (volatile unsigned int cycles = 0; cycles < us; cycles++);
}