c - How to generate note without library? -


i'm trying generate note example , do's frequency 523. wrote codes but, did not work systick 8 mhz

void note1(void){ // note          (int = 0; < 523; i++){          gpioe->odr = 0x4000;         delay_ms(1);         gpioe->odr = 0x0000;         delay_ms(1);     } } 

how can solve problem ?

easymx pro v7

i'm calling function that

void button_handler(void) {     note1();      // clear pending bit depending on 1 pending     if (exti->pr & (1 << 0)){          exti->pr = (1 << 0);     }     else if (exti->pr & (1 << 1)){          exti->pr = (1 << 1);     }        } 

523 times sending 1 , 0 , delay_ms 1 = 1 ms

1000 = 1 sec

on stm32 (as can see have it) have timers can configured pwm output. use timer, set period , prescaler values according needed frequency , set duty cycle on channel 50%.

if need 523hz pwm output, set timer pwm 523hz using prescaler , period value:

timer_overflow_frequency = timer_input_clock /                             (prescaler_value + 1) /                             (period_value + 1) ; 

then, output channel set value half of timer period value.

for standard peripheral library, tutorial can used here: https://stm32f4-discovery.net/2014/05/stm32f4-stm32f429-discovery-pwm-tutorial/

link unwind cube https://electronics.stackexchange.com/questions/179546/getting-pwm-to-work-on-stm32f4-using-sts-hal-libraries


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -