Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 0:ca2ba2d69aac, committed 2019-11-20
- Comitter:
- Polanco
- Date:
- Wed Nov 20 00:14:32 2019 +0000
- Commit message:
- Programa del profe
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/PinNames.h Wed Nov 20 00:14:32 2019 +0000
@@ -0,0 +1,156 @@
+/* mbed Microcontroller Library
+ *******************************************************************************
+ * Copyright (c) 2014, STMicroelectronics
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of STMicroelectronics nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *******************************************************************************
+
+ */
+#ifndef MBED_PINNAMES_H
+#define MBED_PINNAMES_H
+
+#include "cmsis.h"
+#include "PinNamesTypes.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum {
+ // Not connected
+ NC = (int)0xFFFFFFFF,
+
+ // Ports
+ PA_0 = 0x00,
+ PA_1 = 0x01,
+ PA_2 = 0x02,
+ PA_3 = 0x03,
+ PA_4 = 0x04,
+ PA_5 = 0x05,
+ PA_6 = 0x06,
+ PA_7 = 0x07,
+ PA_8 = 0x08,
+ PA_9 = 0x09,
+ PA_10 = 0x0A,
+ PA_11 = 0x0B,
+ PA_12 = 0x0C,
+ PA_13 = NC,
+ PA_14 = NC,
+ PA_15 = 0x0F,
+
+ PB_0 = 0x10,
+ PB_1 = 0x11,
+ PB_2 = NC,
+ PB_3 = 0x13,
+ PB_4 = 0x14,
+ PB_5 = 0x15,
+ PB_6 = 0x16,
+ PB_7 = 0x17,
+ PB_8 = 0x18,
+ PB_9 = 0x19,
+ PB_10 = 0x1A,
+ PB_11 = 0x1B,
+ PB_12 = 0x1C,
+ PB_13 = 0x1D,
+ PB_14 = 0x1E,
+ PB_15 = 0x1F,
+
+ PC_0 = NC,
+ PC_1 = NC,
+ PC_2 = NC,
+ PC_3 = NC,
+ PC_4 = NC,
+ PC_5 = NC,
+ PC_6 = NC,
+ PC_7 = NC,
+ PC_8 = NC,
+ PC_9 = NC,
+ PC_10 = NC,
+ PC_11 = NC,
+ PC_12 = NC,
+ PC_13 = 0x2D,
+ PC_14 = 0x2E,
+ PC_15 = 0x2F,
+
+ PD_2 = NC,
+
+ // ADC internal channels
+ ADC_TEMP = 0xF0,
+ ADC_VREF = 0xF1,
+
+ // Arduino connector namings
+ A0 = PA_0,
+ A1 = PA_1,
+ A2 = PA_4,
+ A3 = PB_0,
+ A4 = NC,
+ A5 = NC,
+ D0 = PA_3,
+ D1 = PA_2,
+ D2 = PA_10,
+ D3 = PB_3,
+ D4 = PB_5,
+ D5 = PB_4,
+ D6 = PB_10,
+ D7 = PA_8,
+ D8 = PA_9,
+ D9 = NC,
+ D10 = PB_6,
+ D11 = PA_7,
+ D12 = PA_6,
+ D13 = PA_5,
+ D14 = PB_9,
+ D15 = PB_8,
+
+ // Generic signals namings
+ Red_Led = NC,
+ Green_Led = PC_13,
+ Blue_Led = NC,
+ LED1 = PC_13,
+ LED2 = NC,
+ LED3 = NC,
+ LED4 = NC,
+ USER_BUTTON = NC,
+ SERIAL_TX = PA_2,
+ SERIAL_RX = PA_3,
+ USBTX = PA_12,
+ USBRX = PA_11,
+ CANRX = PB_8,
+ CANTX = PB_9,
+ I2C_SCL = PB_8,
+ I2C_SDA = PB_9,
+ SPI_MOSI = PA_7,
+ SPI_MISO = PA_6,
+ SPI_SCK = PA_5,
+ SPI_CS = PB_6,
+ PWM_OUT = PB_3
+} PinName;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SysClockConf.h Wed Nov 20 00:14:32 2019 +0000 @@ -0,0 +1,2 @@ +#pragma once +void confSysClock(void);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Wed Nov 20 00:14:32 2019 +0000
@@ -0,0 +1,546 @@
+/* #############################################################################
+** Archivo : main.c
+** Proyecto : STM32-103C8_Barrido_Displays
+** Procesador : STM32F103C8
+** Herramienta : Mbed
+** Compilador : Mbed Online C Compiler
+** Version : 5.14
+** Descripción :
+** Este proyecto provee lo necesario para el despliegue de números y
+** caracteres en un display de 7 segmentos.
+** Contiene un Generador de Caracteres y las rutinas de Barrido para un
+** Display de 7 segmentos de Ãnodo Común de 4 dÃgitos.
+** This module contains user's application code.
+** Componentes : GPIO, Ticker, Terminal Serial.
+** Configuraciones :
+** Modo 0.- Despliega números de hasta cuatro digitos
+** Modo 1.- Despliega una cadena de caracteres con desplazamiento a la
+** Izquierda.
+** Modo 2.- Realiza el Parpadeo (Blinking) del valor que se esta
+** deplegando (por implementar)
+**
+** Autores :
+** ATEAM Development Group:
+** - Antulio Morgado Valle
+**
+** Versión : Beta
+** Revisión : A
+** Release : 0
+** Bugs & Fixes :
+** Date : 20/10/2019
+** Added support for Shift Messages
+**
+** ###########################################################################*/
+/*
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+: Includes
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+*/
+#include "stm32f103c8t6.h"
+#include "mbed.h"
+//#include "AnalogIn.h"
+//#include "ADC.h"
+//#include "Led_RGB.h"
+#include "Serial.h"
+//#include "TextLCD.h"
+//#include "I2C.h"
+//#include "SPI.h"
+#include "stdio.h"
+/*
+:...............................................................................
+: Definiciones
+:...............................................................................
+*/
+#define on 0 // Estado para boton presionado
+#define off 1 // Estado para boton sin presionar
+#define hold 2 // Estado para boton mantenido
+#define release 3 // Estado para boton liberado
+#define FALSE 0 // Estado FALSO
+#define TRUE 1 // Estado VERDADERO
+#define Ticker_Rate 1000 // Periodo de interrupción (us)
+#define Rate_Time 2 // Tiempo de Encendido de los Digitos (ms)
+#define Scan_Time 2 // Tiempo de Barrido del Display (ms)
+#define Shift_Time 10 // Tiempo de corrimiento (x Counter_Time)
+#define Counter_Time 100 // Tiempo de counter (ms)
+#define Size_String 20 // Tamaño del Buffer de Caracteres
+#define Digit_Null 0xFF // Valor para apagar los Segmentos
+#define Degree_Symbol 0x0F // Valor para el SÃmbolo de Grados
+/*
++-------------------------------------------------------------------------------
+| Configuración de Puertos
++-------------------------------------------------------------------------------
+*/
+
+DigitalOut led_monitor(LED1); // Inicializa el Led de Monitor
+PwmOut buzzer (PB_1); // PWM para el Buzzer
+AnalogIn sensor1 (PA_0); // Canal Analógico para sensor 1
+AnalogIn sensor2 (PA_1); // Canal Analógico para sensor 2
+BusIn Teclado (PB_5,PB_6,PB_7,PB_8); // Teclado Matricial
+BusOut Anodos (PB_12, PB_13, PB_14, PB_15); // Anodos: (Uni Dec Cent Mill) A1 A2 A3 A4
+BusOut Catodos (PA_8,PA_9,PA_10,PA_11,PA_12,PA_15,PB_3,PB_4); // Cátodos: p e d c b a f g (lsb -> msb))
+// ***** Host PC Terminal Communication channels
+Serial Terminal (PA_2, PA_3); // Inicializa la comunicación serial a la PC (Tx,Rx)
+//Serial Terminal(USBTX, USBRX,115200);// Tx, Rx Baud Rate - Terminal Serial por USB @ 115,200 Bauds
+// ***** I2C Communication
+//I2C i2c_LCD(PB_9,PB_8,); // SDA, SCL
+// ***** SPI Communication
+//SPI spi_LCD(PA_7,PA_6,PA_5,PB_6); // MOSI, MISO, SCLK, SS
+Ticker Barrido; // Interrupción por Timer
+/*
+** -------------------------------------------------------------------
+** Instanciación del LCD
+** -------------------------------------------------------------------
+*/
+// LCD instantiation
+//TextLCD lcd(PTC5, PTC6, PTC8, PTC9, PTC10, PCT11, TextLCD::LCD20x2); // 4bit bus: rs, e, d4-d7
+//TextLCD_SPI lcd(&spi_LCD, PB_6, TextLCD::LCD16x4, TextLCD::AC780); // SPI bus, CS, LCD Type
+//TextLCD_I2C lcd(&i2c_LCD, 0x7E, TextLCD::LCD20x4); // I2C bus, PCF8574A Arduino Shield, LCD Type
+
+/*
++-------------------------------------------------------------------------------
+| Variables Globales de Usuario
++-------------------------------------------------------------------------------
+*/
+uint16_t Rate=1000; // Velocidad de barrido (1000us = 1ms)
+// ++++++++++++++++++++ Generador de Caracteres ++++++++++++++++++++++++++++++++
+// Offset: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
+//Caracter a Desplegar: 0 1 2 3 4 5 6 7 8 9 A b C d E f G h I j K L M n o P q r S t u V W X y Z space a e /e @ ñ [ ] U /U /_ - _ _/_ /= = == ° +/c +n +/c +u o c n /c u ^ ¬ + > ^ / v < v > i +i /i +/i ii +ii # /# J /J -J -/J | || | + /+ F +F /F +/F null ! " # $ % & ' ( ) * + - . / : ; < > ? @
+uint8_t Segmentos[]={0x81,0xE7,0x49,0x43,0x27,0x13,0x11,0xC7,0x01,0x03,0x05,0x31,0x99,0x61,0x19,0x1D,0x91,0x35,0xBD,0xE3,0x2D,0xB9,0x85,0x75,0x71,0x0D,0x07,0x7D,0x13,0x39,0xF1,0xB1,0xA1,0x25,0x23,0x49,0xFF,0x41,0x09,0x03,0x11,0x55,0x99,0xC3,0xA1,0x85,0xDF,0x7F,0xFB,0xDB,0x7B,0x5F,0x5B,0x0F,0x1F,0x8F,0x4F,0x2F,0x71,0x79,0x75,0x73,0xF1,0x3F,0x9F,0xCF,0x6F,0x7D,0xF9,0xF3,0x77,0xFD,0xBF,0xF7,0xEF,0xF5,0xAF,0x6D,0x37,0xE3,0xB9,0x9D,0xC7,0xBD,0xA5,0xE7,0x3D,0x67,0x1D,0x47,0x63,0x39,0x00};
+// ++++++++++++++++++++++ Selector de Digitos ++++++++++++++++++++++++++++++++++
+uint8_t Digitos[]={0x08,0x04,0x02,0x01,0x00,0x0F}; // Millares, Centenas, Decenas, Unidades, Apagados, Encendidos
+uint8_t Numeros[]={1,0,2,4}; // Valor a Desplegar
+uint8_t Cadena[]={33,0,21,10,36,14,28,18,22,14,36,35,10,12,10,29,14,23,12,24,36,36,36}; // Mensaje a Desplegar
+uint8_t punto_decimal=0; // Posición del punto decimal: 0=sin punto, 1=unidades, 2=decenas, 3=centemas 4=millares,
+uint8_t cont_1ms; // Contador de milésimas de Segundo
+uint8_t cont_10ms; // Contador de centésimas de Segundo
+uint8_t cont_100ms; // Contador de décimas de Segundo
+uint8_t cont_1s; // Contador de Segundos
+uint8_t scan_rate = Scan_Time ;
+uint8_t shift_rate= Shift_Time;
+uint8_t display_rate=10; // Display Rate = 10ms
+uint16_t counter=1250;
+uint8_t i=0;
+uint8_t nchar=0;
+bool mode=0;
+bool flag1=FALSE;
+bool flag2=FALSE;
+
+/*
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+| Definición de Funciones Prototipo y Rutinas de los Vectores de Interrupción
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+*/
+void Barrido_OnInterrupt(void);
+/* END definitions */
+
+/*
+#===============================================================================
+|
+| P R O G R A M A P R I N C I P A L
+|
+#===============================================================================
+*/
+int main()
+{ // Inicialización de variables, puertos e interrupciones
+confSysClock(); // Configure system clock (72MHz HSE clock, 48MHz USB clock)
+Barrido.attach_us(&Barrido_OnInterrupt, Rate); // Le asigna el periodo de barrido de 1ms (Rate=1000)
+Terminal.baud(115200); // Se configura la velocodad de transmisión
+Terminal.printf("\e[2J"); // Clear Screen
+Terminal.printf(" System is Wake Up!.\n\r"); // e inicia la comunicación serial
+Terminal.printf ("\t\e[1;37;41mInstituto Politecnico Nacional\e[0m\n\r");
+Terminal.printf ("\e[1;37;42mESCUELA SUPERIOR DE INGENIERIA MECANICA Y ELECTRICA\e[0m\n\r\v");
+Terminal.printf ("\t\e[1;34;40mBarrido \e[1;37;40mdel \e[1;32;40mDisplay \e[1;33;40mde \e[1;31;40m7 Segmentos\e[0m\n\r\v\v\e[0m");
+
+Terminal.printf ("\nSelecciona el Modo de Operacion:\n\r");
+Terminal.printf ("Modo 0 = Normal (4 Digitos)\n\r");
+Terminal.printf ("Modo 1 = Corrimiento \n\r");
+
+ while (TRUE) // El Lazo del Programa principal está aquà !!!
+ {
+ if (flag1==TRUE) // Está puesta la Bandera 1 ?
+ {
+ if (mode==1) // Está en modo 1? (corrimiento de mensaje)
+ {
+ Numeros[i]=Cadena[i+nchar];// Copia 4 caracteres al buffer de despliegue
+ if (nchar >= Size_String) nchar=0; // Restablece el contador de caractres
+ if (i==4) //
+ {
+ i=0; //
+ mode=0; //
+ }
+ }
+ //------------------ Barrido de los Digitos ------------------------
+ /* ................. Display de Ãnodo Común ........................
+ */
+ Anodos= Digitos[4]; // Apaga todos los Digitos (Evita fantasmas)
+ Catodos= Segmentos[Numeros[i]]; // Actualiza los segmentos
+ if (i==4-punto_decimal) Catodos=(Segmentos[Numeros[i]]& 0xFE); // Enciende el punto decimal
+ Anodos= Digitos[i]; // Activa el Digito en cuestión
+
+ /* ................. Display de Cátodo Común ........................
+ Anodos= 0x0F - (Digitos[4]); // Apaga todos los Digitos (Evita fantasmas)
+ Catodos= 0x0FF - (Segmentos[Numeros[i]]); // Actualiza los segmentos
+ if (i==4-punto_decimal) Catodos=(Segmentos[Numeros[i]]& 0xFE); // Enciende el punto decimal
+ Anodos= 0x0F - (Digitos[i]); // Activa el Digito en cuestión
+ */
+ i++; // Apunta al siguiente dÃgito
+ if (i==4) // Es el últino dÃgito?
+ {
+ i=0; // Reinicia el Barriodo
+ }
+ flag1=FALSE; // Apaga la Bandera 1
+ }
+
+ //------------------ Corrimiento de los Digitos ------------------------
+ if (flag2==TRUE) // Está puesta la Bandera 2?
+ {
+ shift_rate--; // Decrementa el contador de Corrimientos
+ if (!shift_rate) // Es Cero?
+ {
+ mode=1; // Tiempo entre desplazamientos del mensaje
+ shift_rate = Shift_Time;// Restablece el tiempo de los corrimientos
+ nchar++; // corrimiento al siguiente conjunto de de caracteres
+ i=0; // Restablece el barrido de los digitos
+ }
+ led_monitor=!led_monitor; // parapadeo del led_monitor
+ flag2=FALSE; // Limpia la Bandera 2
+ }
+ }
+}
+/* END main */
+
+/*
+................................................................................
+: Rutinas de los Vectores de Interrupción
+................................................................................
+*/
+void Barrido_OnInterrupt() // Rutina de Atención al Ticker
+{
+ cont_1ms++; // Incrmenta el contador de milisegundos
+ counter--; // Decrementa el contador de eventos
+ scan_rate--; // Decrementa el tiempo de despliege
+ if(!scan_rate) // Se acabo el tiempo de desplige?
+ {
+ scan_rate=Scan_Time; // Se restable el tiempo de despliegue
+ flag1=TRUE; // Enciende la bandera para las rutinas de despliege
+ }
+ if (cont_1ms>=10) // Son 10ms?
+ {
+ cont_10ms++; // Incrementa el contador de decimas de ms
+ cont_1ms=0; // Restablece el contador de ms
+ }
+ if (cont_10ms>=10) // Son 100ms?
+ {
+ cont_100ms++; // Incrementa el contador de centecimas de ms
+ cont_10ms=0; // Restablece el contador de decimas de seg
+ }
+ if (cont_100ms>=10) // Son 1000ms o sea 1 seg?
+ {
+ cont_1s++; // Incrementa el contador de segundos
+ cont_100ms=0; // Restablece el contador de centesimas de seg
+ }
+ if (cont_1s>=10) // Son 10seg?
+ {
+ cont_1s=0; // Restablece el contador de segundos
+ }
+ if (!counter)
+ {
+ counter=Counter_Time; // Restablece el contador de eventos
+ flag2=TRUE;
+ }
+}
+/* END Events */
+/*
+________________________________________________________________________________
+|
+| Funciones Prototipo
+|_______________________________________________________________________________
+*/
+ // Las Funciones Prototipo van aquà !
+
+
+/* END program */
+/*+-----------------------------------------------------------------------------
+*+ Descripción del Display de 7 Segmentos de Anodos Comunes en modo multiplexado
+*+------------------------------------------------------------------------------
+*+ 13 12 11 10 9 8
+*+ | | | | | |
+*+ | | | | | |
+*+ --------------------------------------------------
+*+ | A a f A A b |
+*+ | 4 3 2 |
+*+ | ______________________________________________ |
+*+ | | ____ ____ _____ _____ | |
+*+ | | / / / / / / / / | |
+*+ | | /____ / /____ / . /____ / /____ / | |
+*+ | | / / / / . / / / / | |
+*+ | | /____ /. /_____/ . /____ /. /____ /. | |
+*+ | | | |
+*+ | |______________________________________________| |
+*+ | |
+*+ | A |
+*+ | e d p c g 1 |
+*+ --------------------------------------------------
+*+ | | | | | | |
+*+ | | | | | | |
+*+ 1 2 3 4 5 6 7
+*+
+*+ Display: HS410561K-D30
+*+
+*+
+*+ 13 12 11 10 9 8
+*+ | | | | | |
+*+ | | | | | |
+*+ --------------------------------------------------
+*+ | A g f p a b |
+*+ | 4 |
+*+ | ______________________________________________ |
+*+ | | ____ ____ _____ _____ | |
+*+ | | / / / / / / / / | |
+*+ | | /____ / /____ / . /____ / /____ / | |
+*+ | | / / / / . / / / / | |
+*+ | | /____ /. /_____/ /____ /. /____ /. | |
+*+ | | | |
+*+ | |______________________________________________| |
+*+ | |
+*+ | A A A |
+*+ | e 3 2 c d 1 |
+*+ --------------------------------------------------
+*+ | | | | | | |
+*+ | | | | | | |
+*+ 1 2 3 4 5 6 7
+*+
+*+ Display: BQ-M544RE
+*+
+*+
+*+ 12 11 10 9 8 7
+*+ | | | | | |
+*+ | | | | | |
+*+ --------------------------------------------------
+*+ | A a f A A b |
+*+ | 4 3 2 |
+*+ | ______________________________________________ |
+*+ | | ____ ____ _____ . _____ | |
+*+ | | / / / / / / / / | |
+*+ | | /____ / /____ / . /____ / /____ / | |
+*+ | | / / / / . / / / / | |
+*+ | | /____ /. /_____/ . /____ /. /____ /. | |
+*+ | | | |
+*+ | |______________________________________________| |
+*+ | |
+*+ | A A |
+*+ | e d p c g 1 |
+*+ --------------------------------------------------
+*+ | | | | | |
+*+ | | | | | | p1 = g
+*+ 1 2 3 4 5 6 p2 = c
+*+ p3 = d
+*+ Display: HS-5463BS p4 = e
+*+ Cátodo Común pu = b
+*+ pd = f
+*+
+*+
+*+ 16 15 14 13 11
+*+ | | | | |
+*+ | | | | |
+*+ --------------------------------------------------
+*+ | b g a c f |
+*+ | |
+*+ | ______________________________________________ |
+*+ | | ____ ____ _____ . _____ | |
+*+ | | / / / / / / / / | |
+*+ | | /____ / /____ / . /____ / /____ / | |
+*+ | | / / / / . / / / / | |
+*+ | | /____ /. /_____/ . /____ /. /____ /. | |
+*+ | | | |
+*+ | |______________________________________________| |
+*+ | |
+*+ | A A A A A |
+*+ | 4 3 d p e 2 p 1 |
+*+ --------------------------------------------------
+*+ | | | | | | | |
+*+ | | | | | | | |
+*+ 1 2 3 4 5 6 7 8
+*+
+*+ Display: KEM-3942BSR
+*+
++*
+*+
+*+ 12 11 10 9 8 7
+*+ | | | | | |
+*+ | | | | | |
+*+ --------------------------------------------------
+*+ | A a f A A b |
+*+ | 4 3 2 |
+*+ | ______________________________________________ |
+*+ | | ____ ____ _____ _____ | |
+*+ | | / / / / / / / / | |
+*+ | | /____ / /____ / . /____ / /____ / | |
+*+ | | / / / / . / / / / | |
+*+ | | /____ /. /_____/ . /____ /. /____ /. | |
+*+ | | | |
+*+ | |______________________________________________| |
+*+ | |
+*+ | A |
+*+ | e d p c g 1 |
+*+ --------------------------------------------------
+*+ | | | | | |
+*+ | | | | | |
+*+ 1 2 3 4 5 6
+*+
+*+ Display: FYQ-2841BH
+*+
+*+
+*+ PB_15 PB_14 PB_13 PB_12
+*+ A4 A3 A2 A1
+*+ Mill Cent Dec Uni
+*+
+*+ STM32-F103C8 PB_4 PB_3 PA_15 PA_12 PA_11 PA_10 PA_9 PA_8 # Hex Offset
+*+ a
+*+ ______ g f a b c d e p
+*+ / / 1 0 0 0 1 0 0 0 0 0x81 0
+*+ f / g / b 1 1 0 1 1 1 1 0 1 0xE7 1
+*+ /_____/ 1 0 1 1 0 1 0 0 2 0x49 2
+*+ / / 1 0 0 1 0 1 0 0 3 0x43 3
+*+ e / / c 1 1 0 1 0 0 1 0 4 0x27 4
+*+ /_____/ . 1 0 0 1 0 0 0 1 5 0x13 5
+*+ d p 1 0 0 0 0 0 0 1 6 0x11 6
+*+ 1 1 0 1 1 1 0 0 7 0xC7 7
+*+ 1 0 0 0 0 0 0 0 8 0x01 8
+*+ 1 0 0 1 0 0 0 0 9 0x03 9
+*+ 1 1 0 0 0 0 0 0 A 0x05 10
+*+ 1 0 0 0 0 0 1 1 b 0x31 11
+*+ 1 0 1 0 1 0 0 1 C 0x99 12
+*+ 1 0 0 0 0 1 1 0 d 0x61 13
+*+ 1 0 1 0 0 0 0 1 E 0x19 14
+*+ 1 1 1 0 0 0 0 1 f 0x1D 15
+*+ 1 0 0 0 1 0 0 1 G 0x91 16
+*+ 1 1 0 0 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0x8E 68
+*+ 1 1 0 1 1 0 0 0 -/J 0xD8 69
+*+ 1 1 1 0 1 0 1 1 | 0xEB 70
+*+ 1 1 0 0 1 0 1 0 || 0xCA 71
+*+ 1 1 0 1 0 1 1 0 + 0xD6 72
+*+ 1 1 1 0 0 0 1 1 /+ 0xE3 73
+*+ 1 0 0 1 1 0 1 1 espacio 0xFF 74
+*+
+*+ Nota: Cada dÃgito se activa al hacer la señal A correspondiente en "alto"
+*+ y enviar las señales de los segmentos que se desean encender en "bajo"
+*+
+*+----------------------------------------------------------------------------*/
+/* END documentation */
+/*
++-------------------------------------------------------------------------------
+| EJERCICIO
+|
+| 1.- Implementar el menú para seleccionar entre Modo 0 y Modo 1 por el usuario
+| 2.- Crear la función para convertir cualquier valor entero a codigo BCD
+| y representarlo en un buffer de un arreglo de Millares, Centenas, Decenas
+| y unidades para su despliegue en el display de 7 segmentos.
+| 3.- Implementar la rutina para eliminación de los ceros a la izquierda
+| (Blanking).
+|
++------------------------------------------------------------------------------+
+|
+| EXAMEN
+|
+| 1.- Modificar este programa para:
+| a) Leer una cadena de caracteres (Mensaje) desde la terminal serial.
+| b) Convertir todos los caracteres de la cadena a Mayúsculas.
+|
+| 2.- Utilizando el generador de caracteres para el display
+| a) Traducir los caracteres de la cadena a su equivalente de caracteres
+| para ser desplegados por el display de 7 segmentos.
+| b) Crear los buffers corresponedientes para depositar las nuevas cadenas
+| generadas y poderlas desplegar.
+| c) Delimitar el tamaño del buffer de despliegue para que se ajuste a la
+| longitud de la cadena a desplegar más 4 especios.
+| (La longitud para el Buffer para despliegue no debe exceder los 80
+| caracters).
+|
+| Tip.- Consultar la Tabla ASCII
+| (Para los números, restarles 0x30 y para las letras, restarles 0x37)
+| (Para la Ñ, restar 0x7C y para el espacio, sumarle 0x04)
+|
+| 3.- Utilizando el Convertidor Analógico/Digital.
+| a) Obtener una medición en representación flotante (0.0 a 1.0) y escalarla
+| para poder ser representada en formato BCD de 4 dÃgitos (0-9999).
+| b) proveer rutinas para poder escalar por medio del punto decimal.
+|
++------------------------------------------------------------------------------+
+*+ Powered by
+*+
+*+ T H E A N T U L I U ' S T E A M R&D Unltd
+*+
+*+ Research, Development, Systems, Equipment, Support & Spare Parts.
+*+ (C) Copyright 1989-2019, All Rights Reserved
+*+
+*+ Welcome to The Beaners Proyect Community!
+*+----------------------------------------------------------------------------*/
+/* END Mbed */
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Nov 20 00:14:32 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/stm32f103c8t6.cpp Wed Nov 20 00:14:32 2019 +0000
@@ -0,0 +1,56 @@
+/*
+ ******************************************************************************
+ * @file SysClockConf.c
+ * @version
+ * @date 05-July-2016
+ * @brief System Clock configuration for STM32F103C8T6
+ *****************************************************************************
+ *
+ * All rights reserved.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "SysClockConf.h"
+#include "mbed.h"
+
+void HSE_SystemClock_Config(void) {
+ RCC_OscInitTypeDef RCC_OscInitStruct;
+ RCC_ClkInitTypeDef RCC_ClkInitStruct;
+ RCC_PeriphCLKInitTypeDef PeriphClkInit;
+
+ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
+ RCC_OscInitStruct.HSEState = RCC_HSE_ON;
+ RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1;
+ RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
+ RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
+ RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9;
+ HAL_RCC_OscConfig(&RCC_OscInitStruct);
+ RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
+ RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
+ RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
+ RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
+ RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
+ HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2);
+ PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_ADC|RCC_PERIPHCLK_USB;
+ PeriphClkInit.AdcClockSelection = RCC_ADCPCLK2_DIV6;
+ PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_PLL_DIV1_5;
+ HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit);
+}
+
+void confSysClock(void) {
+ HAL_RCC_DeInit();
+ HSE_SystemClock_Config();
+ SystemCoreClockUpdate();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/stm32f103c8t6.h Wed Nov 20 00:14:32 2019 +0000 @@ -0,0 +1,3 @@ +#pragma once +#include "PinNames.h" +#include "SysClockConf.h"