User Tools

Site Tools


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.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
teaching:ie0624:actividad_stm32_timer_uart [2018/10/29 18:35] – [Parte 2. STM32 TIMER] dgarciateaching: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_hsi_8mhz[RCC_CLOCK_64MHZ]);+    rcc_clock_setup_hsi(&rcc_hsi_configs[RCC_CLOCK_HSI_64MHZ]);
     leds_init();     leds_init();
   }   }
Line 138: Line 138:
      
     /* Reset TIM1 peripheral. */     /* Reset TIM1 peripheral. */
-    timer_reset(TIM1);+    //timer_reset(TIM1); 
 +    rcc_periph_reset_pulse(RST_TIM1);
      
     /* Timer global mode:     /* Timer global mode:
Line 233: Line 234:
   * 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. **   * 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://en.wikipedia.org/wiki/Buzzer| buzzer]], y una resistencia para limitar la corriente por el buzzer. ** O) Cuál pieza es esta? haga un video **
 +
 +  * Cree la función ''delay'', que toma como entrada un entero y hace que el STM se espere esa cantidad de tiempo.
 +  * Cree la función ''tone'', que se encarga de crear una señal cuadrada en un pin específico a una frecuencia dada y por un tiempo específico. 
 +  * Cree l función ''song'', que contiene ls instrucciones para reproducir una pieza musical simple.
 +  * 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,uint16_t gpios, uint32_t frequency, uint32_t duration);
 +  
 +  /*
 +   * song()
 +   * Reproduces a song
 +   *
 +   * Eample: song()
 +   * Reproduces a song
 +   */
 +  void song(void); 
 +</code> 
 +
 +  * También se incluye la implementación de la función ''song'':
 +
 +<code C>
 +void song(void) {
 +  tone(9,660,100);
 +  delay(150);
 +  tone(9,660,100);
 +  delay(300);
 +  tone(9,660,100);
 +  delay(300);
 +  tone(9,510,100);
 +  delay(100);
 +  tone(9,660,100);
 +  delay(300);
 +  tone(9,770,100);
 +  delay(550);
 +  tone(9,380,100);
 +  delay(575);
 +  
 +  tone(9,510,100);
 +  delay(450);
 +  tone(9,380,100);
 +  delay(400);
 +  tone(9,320,100);
 +  delay(500);
 +  tone(9,440,100);
 +  delay(300);
 +  tone(9,480,80);
 +  delay(330);
 +  tone(9,450,100);
 +  delay(150);
 +  tone(9,430,100);
 +  delay(300);
 +  tone(9,380,100);
 +  delay(200);
 +  tone(9,660,80);
 +  delay(200);
 +  tone(9,760,50);
 +  delay(150);
 +  tone(9,860,100);
 +  delay(300);
 +  tone(9,700,80);
 +  delay(150);
 +  tone(9,760,50);
 +  delay(350);
 +  tone(9,660,80);
 +  delay(300);
 +  tone(9,520,80);
 +  delay(150);
 +  tone(9,580,80);
 +  delay(150);
 +  tone(9,480,80);
 +  delay(500);
 +  
 +  tone(9,510,100);
 +  delay(450);
 +  tone(9,380,100);
 +  delay(400);
 +  tone(9,320,100);
 +  delay(500);
 +  tone(9,440,100);
 +  delay(300);
 +  tone(9,480,80);
 +  delay(330);
 +  tone(9,450,100);
 +  delay(150);
 +  tone(9,430,100);
 +  delay(300);
 +  tone(9,380,100);
 +  delay(200);
 +  tone(9,660,80);
 +  delay(200);
 +  tone(9,760,50);
 +  delay(150);
 +  tone(9,860,100);
 +  delay(300);
 +  tone(9,700,80);
 +  delay(150);
 +  tone(9,760,50);
 +  delay(350);
 +  tone(9,660,80);
 +  delay(300);
 +  tone(9,520,80);
 +  delay(150);
 +  tone(9,580,80);
 +  delay(150);
 +  tone(9,480,80);
 +  delay(500);
 +  
 +  tone(9,500,100);
 +  delay(300);
 +  
 +  tone(9,760,100);
 +  delay(100);
 +  tone(9,720,100);
 +  delay(150);
 +  tone(9,680,100);
 +  delay(150);
 +  tone(9,620,150);
 +  delay(300);
 +  
 +  tone(9,650,150);
 +  delay(300);
 +  tone(9,380,100);
 +  delay(150);
 +  tone(9,430,100);
 +  delay(150);
 +  
 +  tone(9,500,100);
 +  delay(300);
 +  tone(9,430,100);
 +  delay(150);
 +  tone(9,500,100);
 +  delay(100);
 +  tone(9,570,100);
 +  delay(220);
 +  
 +  tone(9,500,100);
 +  delay(300);
 +  
 +  tone(9,760,100);
 +  delay(100);
 +  tone(9,720,100);
 +  delay(150);
 +  tone(9,680,100);
 +  delay(150);
 +  tone(9,620,150);
 +  delay(300);
 +  
 +  tone(9,650,200);
 +  delay(300);
 +  
 +  tone(9,1020,80);
 +  delay(300);
 +  tone(9,1020,80);
 +  delay(150);
 +  tone(9,1020,80);
 +  delay(300);
 +  
 +  tone(9,380,100);
 +  delay(300);
 +  tone(9,500,100);
 +  delay(300);
 +  
 +  tone(9,760,100);
 +  delay(100);
 +  tone(9,720,100);
 +  delay(150);
 +  tone(9,680,100);
 +  delay(150);
 +  tone(9,620,150);
 +  delay(300);
 +  
 +  tone(9,650,150);
 +  delay(300);
 +  tone(9,380,100);
 +  delay(150);
 +  tone(9,430,100);
 +  delay(150);
 +  
 +  tone(9,500,100);
 +  delay(300);
 +  tone(9,430,100);
 +  delay(150);
 +  tone(9,500,100);
 +  delay(100);
 +  tone(9,570,100);
 +  delay(420);
 +  
 +  tone(9,585,100);
 +  delay(450);
 +  
 +  tone(9,550,100);
 +  delay(420);
 +  
 +  tone(9,500,100);
 +  delay(360);
 +  
 +  tone(9,380,100);
 +  delay(300);
 +  tone(9,500,100);
 +  delay(300);
 +  tone(9,500,100);
 +  delay(150);
 +  tone(9,500,100);
 +  delay(300);
 +  
 +  tone(9,500,100);
 +  delay(300);
 +  
 +  tone(9,760,100);
 +  delay(100);
 +  tone(9,720,100);
 +  delay(150);
 +  tone(9,680,100);
 +  delay(150);
 +  tone(9,620,150);
 +  delay(300);
 +  
 +  tone(9,650,150);
 +  delay(300);
 +  tone(9,380,100);
 +  delay(150);
 +  tone(9,430,100);
 +  delay(150);
 +  
 +  tone(9,500,100);
 +  delay(300);
 +  tone(9,430,100);
 +  delay(150);
 +  tone(9,500,100);
 +  delay(100);
 +  tone(9,570,100);
 +  delay(220);
 +  
 +  tone(9,500,100);
 +  delay(300);
 +   
 +  tone(9,760,100);
 +  delay(100);
 +  tone(9,720,100);
 +  delay(150);
 +  tone(9,680,100);
 +  delay(150);
 +  tone(9,620,150);
 +  delay(300);
 +   
 +  tone(9,650,200);
 +  delay(300);
 +  
 +  tone(9,1020,80);
 +  delay(300);
 +  tone(9,1020,80);
 +  delay(150);
 +  tone(9,1020,80);
 +  delay(300);
 +  
 +  tone(9,380,100);
 +  delay(300);
 +  tone(9,500,100);
 +  delay(300);
 +   
 +  tone(9,760,100);
 +  delay(100);
 +  tone(9,720,100);
 +  delay(150);
 +  tone(9,680,100);
 +  delay(150);
 +  tone(9,620,150);
 +  delay(300); 
 +  
 +  tone(9,650,150);
 +  delay(300);
 +  tone(9,380,100);
 +  delay(150);
 +  tone(9,430,100);
 +  delay(150);
 +  
 +  tone(9,500,100);
 +  delay(300);
 +  tone(9,430,100);
 +  delay(150);
 +  tone(9,500,100);
 +  delay(100);
 +  tone(9,570,100);
 +  delay(420);
 +  
 +  tone(9,585,100);
 +  delay(450);
 +  
 +  tone(9,550,100);
 +  delay(420);
 +  
 +  tone(9,500,100);
 +  delay(360);
 +  
 +  tone(9,380,100);
 +  delay(300);
 +  tone(9,500,100);
 +  delay(300);
 +  tone(9,500,100);
 +  delay(150);
 +  tone(9,500,100);
 +  delay(300);
 +   
 +  tone(9,500,60);
 +  delay(150);
 +  tone(9,500,80);
 +  delay(300);
 +  tone(9,500,60);
 +  delay(350);
 +  tone(9,500,80);
 +  delay(150);
 +  tone(9,580,80);
 +  delay(350);
 +  tone(9,660,80);
 +  delay(150);
 +  tone(9,500,80);
 +  delay(300);
 +  tone(9,430,80);
 +  delay(150);
 +  tone(9,380,80);
 +  delay(600);
 +  
 +  tone(9,500,60);
 +  delay(150);
 +  tone(9,500,80);
 +  delay(300);
 +  tone(9,500,60);
 +  delay(350);
 +  tone(9,500,80);
 +  delay(150);
 +  tone(9,580,80);
 +  delay(150);
 +  tone(9,660,80);
 +  delay(550);
 +  
 +  tone(9,870,80);
 +  delay(325);
 +  tone(9,760,80);
 +  delay(600);
 +  
 +  tone(9,500,60);
 +  delay(150);
 +  tone(9,500,80);
 +  delay(300);
 +  tone(9,500,60);
 +  delay(350);
 +  tone(9,500,80);
 +  delay(150);
 +  tone(9,580,80);
 +  delay(350);
 +  tone(9,660,80);
 +  delay(150);
 +  tone(9,500,80);
 +  delay(300);
 +  tone(9,430,80);
 +  delay(150);
 +  tone(9,380,80);
 +  delay(600);
 +  
 +  tone(9,660,100);
 +  delay(150);
 +  tone(9,660,100);
 +  delay(300);
 +  tone(9,660,100);
 +  delay(300);
 +  tone(9,510,100);
 +  delay(100);
 +  tone(9,660,100);
 +  delay(300);
 +  tone(9,770,100);
 +  delay(550);
 +  tone(9,380,100);
 +  delay(575);
 +  }
 +</code>  
 ===== Referencias ===== ===== Referencias =====
  
teaching/ie0624/actividad_stm32_timer_uart.1540838122.txt.gz · Last modified: 2022/09/20 00:08 (external edit)