Hot answers tagged

9

The problem is sending constant data stream without any pauses between symbols. The ASCII symbol 'S' has a value of 0x53, so it is sent over the wire as repeating pattern of 0110010101 which includes the start and stop bits. Because there is no pauses between transmissions, the receiving UART does not know which bits are the start and stop bits in the ...


5

As an addition to Justmes answer (feel free to combine this into your answer): This is a UART Transmission of an S: This is what happens if you dont have an idle: And this part is what the receiver sees as a repeating 0xAA: edit: to be clear, i dont think this should be marked as the answer. This should just be an addendum to Justme's answer


4

I think the problem is the itoa() function. Its parameter is a normal signed integer, so your unsigned int is being coerced to a signed int.


4

Branching to the interrupt, saving registers, restoring registers, and then returning from the interrupt all take clock cycles. If the only thing you are doing is transmitting this serial data, then not having the interrupt is going to use less clock cycles overall. Some other comments about the code. Blocking while you send multiple characters within an ...


3

Your method 1 does not work, because in a single interrupt, you are writing all characters of the string to the Uart Data Register. When an UDRE interrupt happens, it is ready to accept one (1) character until another UDRE interrupt happens. Which is the reason why your method 2 works, because it expicitly waits for the Uart Data Register to be empty before ...


3

This is a generic method. The ubrr is an unsigned int which makes it 16 bits wide (2 bytes). To break this into discrete bytes like in the example, you need to shift the bits right by 8 to get the high byte. In your specific example it doesn't matter because the high byte is empty anyway, but what if you need a ubrr of 3,096? Also, you might be confusing ...


2

The way to do this is with a fifo structure. The transmit function loads your string into the fifo and turns on the interrupt. The UDRE interrupt has just one if statement. It checks if fifo is empty. If empty, it turns the interrupt off, since the transmission is done. If not empty, it takes one character out of the fifo and puts it into the UDR register ...


2

A UART receiver has to be "told" beforehand how many data bits there are and whether parity is used or not and, if used, whether it's even parity or odd parity or forced parity. It also has to be "told" beforehand the data rate. Sometimes, it's even necessary to inform a UART that there might be two stop bits before the next byte is ...


2

When you configure your UART you need to specify not only the baudrate but also the number of bits. Your example has configured it to 7 data bits and one parity bit, thus the receiver knows that the first 8 bits can not be stop bits.


1

Problem was in UART pin configuration: it needed to be pulled up instead of open drain: GPIO_InitTypeDef pin = { .Pin = SERVO_PIN, .Mode = GPIO_MODE_AF_PP, .Pull = GPIO_PULLUP, ...


1

The clock coming from the generator would be (typically) 16 times the baud rate, to allow for oversampling of input data by 16x. So each bit on bus is 16 clocks. Start bit detection logic looks for incoming start bit to start the reception of a data frame. It typically checks that too short glitches is not considered as start of frame, while long enough ...


1

Update: the problem was related to my PC turning off USB ports to conserve power. I fixed it by disabling this feature in Device Manager


Only top voted, non community-wiki answers of a minimum length are eligible