JakeKarson
Newbie level 1
So on my STM32F103c8(T6) that I program in the Arduino interface, I have setup a hardware timer at 1 kHz and a Serial baud rate of 1.5 MHz. The interrupt handler simply updates a volatile long int t to set it to the current time using micros().
The program is an infinite loop where if a change in t is noticed, the value of t is transmitted over serial in binary using Serial.write(). With the 1 kHz timer, this works fine: if I log the signal with Putty, I get exactly what I expect. However, if I increase the frequency to 2 kHz, I receive nonsense (the signal looks like noise with an amplitude of a billion).
This I do not understand. With 1.5 MHz baud rate, in theory you can send unsigned ints at 46.875 kHz. Why can it do 1 kHz but not even 2? Also, although the microcontroller should support 4.5 Mbit/s USART speeds, a baud rate of 2 MHz does not work either. I need a 8 kHz PID control loop for my project.
The program is an infinite loop where if a change in t is noticed, the value of t is transmitted over serial in binary using Serial.write(). With the 1 kHz timer, this works fine: if I log the signal with Putty, I get exactly what I expect. However, if I increase the frequency to 2 kHz, I receive nonsense (the signal looks like noise with an amplitude of a billion).
This I do not understand. With 1.5 MHz baud rate, in theory you can send unsigned ints at 46.875 kHz. Why can it do 1 kHz but not even 2? Also, although the microcontroller should support 4.5 Mbit/s USART speeds, a baud rate of 2 MHz does not work either. I need a 8 kHz PID control loop for my project.