Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stm32f10x.h>
- #include "main.h"
- void Enable_GPIO(void)
- {
- RCC->APB2ENR |= 0x013C;
- }
- void Init_GPIO(void)
- {
- GPIOA->CRL = 0x00030004; // PA4 (Speaker) en Push-Pull et PA0 (Wake Up) en Floating Input
- }
- void TIM1_UP_IRQHandler(void)
- {
- if (TIM1->SR & 1)
- {
- GPIOA->ODR ^= 0x10;
- TIM1->SR &= ~1;
- }
- }
- int main (void)
- {
- int notes[] = {50, 500, 80, 90, 500, 68 };
- int i=0;
- Enable_GPIO();
- Init_GPIO();
- /* Initialisation Timer 1 (TIM1) */
- RCC->APB2ENR |= (1 << 11); // Validation Timer 1
- TIM1->CR1 |= 0x0001; // Timer 1 Enable
- TIM1->DIER |= 1;
- TIM1->ARR = 500;
- *(volatile unsigned long *)0xE000E100 |= (1<<25);
- while (1)
- {
- unsigned int cochon = 4000000;
- while (cochon--);
- TIM1->PSC = notes[i++];
- if (i >= sizeof(notes) / 4) i= 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement