2018-06-10 11:37 PM
Hi
How to change arduino uno code to STM32F103void setup(){ pinMode(9,OUTPUT); pinMode(10,OUTPUT); TCCR1B = (1<<WGM13)|(1<<CS10); TCCR1A = (1<<COM1A1)|(1<<COM1B1)|(1<<COM1B0); TIMSK1 = 1<<TOIE1; ICR1=511; OCR1B=0; } ISR (TIMER1_OVF_vect) { static uint8_t n=0; OCR1A = OCR1B= sine_wave[n]; n++; } void loop(){ }
Solved! Go to Solution.
2018-06-11 11:09 AM
Don't look at individual lines of code but blocks of code and ask yourself what those blocks are trying to do.
After that implement the functionality on your new target.
2018-06-11 11:06 AM
You'd be better starting with what you're trying to achieve, and re-implement.
Set up clocks and pins
Program periodicity of TIM
Set up circular DMA to point to Sine Wave table, and configure TIM/DMA to update pulse width at each period update.
2018-06-11 11:09 AM
Don't look at individual lines of code but blocks of code and ask yourself what those blocks are trying to do.
After that implement the functionality on your new target.
2018-06-11 01:25 PM
I am trying to modify simple sine wave generator for stm32f103, post # 21, click on - показать код
http://arduino.ru/forum/programmirovanie/shim-sinusoida#comment-152231
2018-06-11 08:25 PM
Set up circular DMA to point to Sine Wave table -
How to do that some links will help.Similar code for STM32
HardwareTimer pwmtimer2(2); void setup() { pinMode(PA3, PWM); //Pin mode selected pwmtimer2.pause(); pwmtimer2.setPrescaleFactor(1); // Prescaler setup pwmtimer2.setOverflow(10000-1); // 256 ? pwmtimer2.setCompare(TIMER_CH4, 5000); // ? pwmtimer2.refresh(); pwmtimer2.resume(); } void loop() { } // How to tell to produce sine ?