Writing /var/lib/dokuwiki/data/meta/teaching/ie0624/actividad_stm32_timer_uart.meta failed
teaching:ie0624:actividad_stm32_timer_uart
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
teaching:ie0624:actividad_stm32_timer_uart [2018/10/24 03:19] – dgarcia | teaching:ie0624:actividad_stm32_timer_uart [2022/09/20 00:08] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 84: | Line 84: | ||
| | ||
void system_init(void) { | void system_init(void) { | ||
- | rcc_clock_setup_hsi(& | + | rcc_clock_setup_hsi(& |
leds_init(); | leds_init(); | ||
} | } | ||
Line 138: | Line 138: | ||
| | ||
/* Reset TIM1 peripheral. */ | /* Reset TIM1 peripheral. */ | ||
- | timer_reset(TIM1); | + | |
+ | rcc_periph_reset_pulse(RST_TIM1); | ||
| | ||
/* Timer global mode: | /* Timer global mode: | ||
Line 227: | Line 228: | ||
* **3) Observe y describa el comportamiento de los LEDs.** (Utilice el Osciloscopio) | * **3) Observe y describa el comportamiento de los LEDs.** (Utilice el Osciloscopio) | ||
* Modifique el programa para que el LED GPIOE9 tenga in ciclo de trabajo de 10% | * Modifique el programa para que el LED GPIOE9 tenga in ciclo de trabajo de 10% | ||
- | * Modifique el programa para que la señal sea compatible con un servo. Igualmente como se realizó en la actividad 3, desde el ciclo principal del programa (while) cambie el valor del PWM de tal forma que el servo se mueva del máximo al mínimo de posición de manera intermitente cada 2 segundos. Observe el servo moverse del máximo al mínimo de posición. Capture ambos casos con el osciloscopio. | ||
+ | ==== Parte 2. Servo ==== | ||
+ | |||
+ | * Modifique el programa para que la señal sea compatible con un servo. Igualmente como se realizó en la actividad 3, desde el ciclo principal del programa (while) cambie el valor del PWM de tal forma que el servo se mueva del máximo al mínimo de posición de manera intermitente cada 2 segundos. Observe el servo moverse del máximo al mínimo de posición. **4) Capture ambos casos con el osciloscopio. ** | ||
+ | |||
+ | ==== Opcional ==== | ||
+ | |||
+ | En esta parte opcional se logrará reproducir una pieza simple con el STM. Necesita el STM32F3 Discovery, un [[https:// | ||
+ | |||
+ | * Cree la función '' | ||
+ | * Cree la función '' | ||
+ | * Cree l función '' | ||
+ | * A continuación se muestra las definiciones de dichas funciones: | ||
+ | |||
+ | <code C> | ||
+ | /* | ||
+ | * delay(time_ms) | ||
+ | * Waits a certain amount of mili seconds | ||
+ | * time_ms: integer with the miliseconds to wait | ||
+ | * | ||
+ | * Example: delay(100); | ||
+ | * Will wait for 100 miliseconds | ||
+ | */ | ||
+ | void delay(uint32_t time_ms); | ||
+ | | ||
+ | /* | ||
+ | * tone(port, pin, frequency, duration) | ||
+ | * Sends a square signal to the port/pin at the specified frequency, for duration miliseconds | ||
+ | * port: Port at which the signal must be sent | ||
+ | * pin: The pin that should be used | ||
+ | * frequency: Frequency in Hz of the desired signal | ||
+ | * duration: duration of the tone in miliseconds | ||
+ | * | ||
+ | * Example: tone(GPIOE, GPIO09, 440, 100); | ||
+ | * Will generate a sqare signal at pin E9, for 100 milisceonds at 440Hz | ||
+ | */ | ||
+ | void tone(uint32_t gpioport, | ||
+ | | ||
+ | /* | ||
+ | * song() | ||
+ | * Reproduces a song | ||
+ | * | ||
+ | * Eample: song() | ||
+ | * Reproduces a song | ||
+ | */ | ||
+ | void song(void); | ||
+ | </ | ||
+ | |||
+ | * También se incluye la implementación de la función '' | ||
+ | |||
+ | <code C> | ||
+ | void song(void) { | ||
+ | tone(9, | ||
+ | delay(150); | ||
+ | tone(9, | ||
+ | delay(300); | ||
+ | tone(9, | ||
+ | delay(300); | ||
+ | tone(9, | ||
+ | delay(100); | ||
+ | tone(9, | ||
+ | delay(300); | ||
+ | tone(9, | ||
+ | delay(550); | ||
+ | tone(9, | ||
+ | delay(575); | ||
+ | | ||
+ | tone(9, | ||
+ | delay(450); | ||
+ | tone(9, | ||
+ | delay(400); | ||
+ | tone(9, | ||
+ | delay(500); | ||
+ | tone(9, | ||
+ | delay(300); | ||
+ | tone(9, | ||
+ | delay(330); | ||
+ | tone(9, | ||
+ | delay(150); | ||
+ | tone(9, | ||
+ | delay(300); | ||
+ | tone(9, | ||
+ | delay(200); | ||
+ | tone(9, | ||
+ | delay(200); | ||
+ | tone(9, | ||
+ | delay(150); | ||
+ | tone(9, | ||
+ | delay(300); | ||
+ | tone(9, | ||
+ | delay(150); | ||
+ | tone(9, | ||
+ | delay(350); | ||
+ | tone(9, | ||
+ | delay(300); | ||
+ | tone(9, | ||
+ | delay(150); | ||
+ | tone(9, | ||
+ | delay(150); | ||
+ | tone(9, | ||
+ | delay(500); | ||
+ | | ||
+ | tone(9, | ||
+ | delay(450); | ||
+ | tone(9, | ||
+ | delay(400); | ||
+ | tone(9, | ||
+ | delay(500); | ||
+ | tone(9, | ||
+ | delay(300); | ||
+ | tone(9, | ||
+ | delay(330); | ||
+ | tone(9, | ||
+ | delay(150); | ||
+ | tone(9, | ||
+ | delay(300); | ||
+ | tone(9, | ||
+ | delay(200); | ||
+ | tone(9, | ||
+ | delay(200); | ||
+ | tone(9, | ||
+ | delay(150); | ||
+ | tone(9, | ||
+ | delay(300); | ||
+ | tone(9, | ||
+ | delay(150); | ||
+ | tone(9, | ||
+ | delay(350); | ||
+ | tone(9, | ||
+ | delay(300); | ||
+ | tone(9, | ||
+ | delay(150); | ||
+ | tone(9, | ||
+ | delay(150); | ||
+ | tone(9, | ||
+ | delay(500); | ||
+ | | ||
+ | tone(9, | ||
+ | delay(300); | ||
+ | | ||
+ | tone(9, | ||
+ | delay(100); | ||
+ | tone(9, | ||
+ | delay(150); | ||
+ | tone(9, | ||
+ | delay(150); | ||
+ | tone(9, | ||
+ | delay(300); | ||
+ | | ||
+ | tone(9, | ||
+ | delay(300); | ||
+ | tone(9, | ||
+ | delay(150); | ||
+ | tone(9, | ||
+ | delay(150); | ||
+ | | ||
+ | tone(9, | ||
+ | delay(300); | ||
+ | tone(9, | ||
+ | delay(150); | ||
+ | tone(9, | ||
+ | delay(100); | ||
+ | tone(9, | ||
+ | delay(220); | ||
+ | | ||
+ | tone(9, | ||
+ | delay(300); | ||
+ | | ||
+ | tone(9, | ||
+ | delay(100); | ||
+ | tone(9, | ||
+ | delay(150); | ||
+ | tone(9, | ||
+ | delay(150); | ||
+ | tone(9, | ||
+ | delay(300); | ||
+ | | ||
+ | tone(9, | ||
+ | delay(300); | ||
+ | | ||
+ | tone(9, | ||
+ | delay(300); | ||
+ | tone(9, | ||
+ | delay(150); | ||
+ | tone(9, | ||
+ | delay(300); | ||
+ | | ||
+ | tone(9, | ||
+ | delay(300); | ||
+ | tone(9, | ||
+ | delay(300); | ||
+ | | ||
+ | tone(9, | ||
+ | delay(100); | ||
+ | tone(9, | ||
+ | delay(150); | ||
+ | tone(9, | ||
+ | delay(150); | ||
+ | tone(9, | ||
+ | delay(300); | ||
+ | | ||
+ | tone(9, | ||
+ | delay(300); | ||
+ | tone(9, | ||
+ | delay(150); | ||
+ | tone(9, | ||
+ | delay(150); | ||
+ | | ||
+ | tone(9, | ||
+ | delay(300); | ||
+ | tone(9, | ||
+ | delay(150); | ||
+ | tone(9, | ||
+ | delay(100); | ||
+ | tone(9, | ||
+ | delay(420); | ||
+ | | ||
+ | tone(9, | ||
+ | delay(450); | ||
+ | | ||
+ | tone(9, | ||
+ | delay(420); | ||
+ | | ||
+ | tone(9, | ||
+ | delay(360); | ||
+ | | ||
+ | tone(9, | ||
+ | delay(300); | ||
+ | tone(9, | ||
+ | delay(300); | ||
+ | tone(9, | ||
+ | delay(150); | ||
+ | tone(9, | ||
+ | delay(300); | ||
+ | | ||
+ | tone(9, | ||
+ | delay(300); | ||
+ | | ||
+ | tone(9, | ||
+ | delay(100); | ||
+ | tone(9, | ||
+ | delay(150); | ||
+ | tone(9, | ||
+ | delay(150); | ||
+ | tone(9, | ||
+ | delay(300); | ||
+ | | ||
+ | tone(9, | ||
+ | delay(300); | ||
+ | tone(9, | ||
+ | delay(150); | ||
+ | tone(9, | ||
+ | delay(150); | ||
+ | | ||
+ | tone(9, | ||
+ | delay(300); | ||
+ | tone(9, | ||
+ | delay(150); | ||
+ | tone(9, | ||
+ | delay(100); | ||
+ | tone(9, | ||
+ | delay(220); | ||
+ | | ||
+ | tone(9, | ||
+ | delay(300); | ||
+ | |||
+ | tone(9, | ||
+ | delay(100); | ||
+ | tone(9, | ||
+ | delay(150); | ||
+ | tone(9, | ||
+ | delay(150); | ||
+ | tone(9, | ||
+ | delay(300); | ||
+ | |||
+ | tone(9, | ||
+ | delay(300); | ||
+ | | ||
+ | tone(9, | ||
+ | delay(300); | ||
+ | tone(9, | ||
+ | delay(150); | ||
+ | tone(9, | ||
+ | delay(300); | ||
+ | | ||
+ | tone(9, | ||
+ | delay(300); | ||
+ | tone(9, | ||
+ | delay(300); | ||
+ | |||
+ | tone(9, | ||
+ | delay(100); | ||
+ | tone(9, | ||
+ | delay(150); | ||
+ | tone(9, | ||
+ | delay(150); | ||
+ | tone(9, | ||
+ | delay(300); | ||
+ | | ||
+ | tone(9, | ||
+ | delay(300); | ||
+ | tone(9, | ||
+ | delay(150); | ||
+ | tone(9, | ||
+ | delay(150); | ||
+ | | ||
+ | tone(9, | ||
+ | delay(300); | ||
+ | tone(9, | ||
+ | delay(150); | ||
+ | tone(9, | ||
+ | delay(100); | ||
+ | tone(9, | ||
+ | delay(420); | ||
+ | | ||
+ | tone(9, | ||
+ | delay(450); | ||
+ | | ||
+ | tone(9, | ||
+ | delay(420); | ||
+ | | ||
+ | tone(9, | ||
+ | delay(360); | ||
+ | | ||
+ | tone(9, | ||
+ | delay(300); | ||
+ | tone(9, | ||
+ | delay(300); | ||
+ | tone(9, | ||
+ | delay(150); | ||
+ | tone(9, | ||
+ | delay(300); | ||
+ | |||
+ | tone(9, | ||
+ | delay(150); | ||
+ | tone(9, | ||
+ | delay(300); | ||
+ | tone(9, | ||
+ | delay(350); | ||
+ | tone(9, | ||
+ | delay(150); | ||
+ | tone(9, | ||
+ | delay(350); | ||
+ | tone(9, | ||
+ | delay(150); | ||
+ | tone(9, | ||
+ | delay(300); | ||
+ | tone(9, | ||
+ | delay(150); | ||
+ | tone(9, | ||
+ | delay(600); | ||
+ | | ||
+ | tone(9, | ||
+ | delay(150); | ||
+ | tone(9, | ||
+ | delay(300); | ||
+ | tone(9, | ||
+ | delay(350); | ||
+ | tone(9, | ||
+ | delay(150); | ||
+ | tone(9, | ||
+ | delay(150); | ||
+ | tone(9, | ||
+ | delay(550); | ||
+ | | ||
+ | tone(9, | ||
+ | delay(325); | ||
+ | tone(9, | ||
+ | delay(600); | ||
+ | | ||
+ | tone(9, | ||
+ | delay(150); | ||
+ | tone(9, | ||
+ | delay(300); | ||
+ | tone(9, | ||
+ | delay(350); | ||
+ | tone(9, | ||
+ | delay(150); | ||
+ | tone(9, | ||
+ | delay(350); | ||
+ | tone(9, | ||
+ | delay(150); | ||
+ | tone(9, | ||
+ | delay(300); | ||
+ | tone(9, | ||
+ | delay(150); | ||
+ | tone(9, | ||
+ | delay(600); | ||
+ | | ||
+ | tone(9, | ||
+ | delay(150); | ||
+ | tone(9, | ||
+ | delay(300); | ||
+ | tone(9, | ||
+ | delay(300); | ||
+ | tone(9, | ||
+ | delay(100); | ||
+ | tone(9, | ||
+ | delay(300); | ||
+ | tone(9, | ||
+ | delay(550); | ||
+ | tone(9, | ||
+ | delay(575); | ||
+ | } | ||
+ | </ | ||
===== Referencias ===== | ===== Referencias ===== | ||
teaching/ie0624/actividad_stm32_timer_uart.1540351156.txt.gz · Last modified: 2022/09/20 00:08 (external edit)