Hey, thanks for passing my mail through the filters :), but ...
On Mon, Jun 8, 2015 at 3:14 PM, Darryl Piper
<
darryl...@googlemail.com> wrote:
> argh, just realised I dont use the standard hardware serial routines !
>
> dont forget the UDR0 register is for both reading and writing, and at high
> speed. the UCSR0A bit 6 is set when data has been transmited out and no data
> is waiting in the UDR0 register.
>
> so blindly reading data from it even when data is flagged as being ready by
> bit 7 of UCSR0A. doesnt work. test the TXC0 flag, and then you can read
> the right data.
>
>
Suddenly, we're not even talking about my firmware and we're talking
foobar. Please no.
The UART (well USART, but we use UART features...) has a shift
register and a buffer register both directions, UDR mapped to the
proper buffer register for a given direction. UDRE will give the
status of the TX buffer register so you have a byte of time to fill it
without losing full speed transmission (if it didnt exist, it would be
practically impossible to send at full speed). TXC will flag when the
TX shift register is empty if you're waiting to do something when all
data really is out (like go to sleep or turn off UART).
RXC flags when data is moved from RX shift register to RX buffer
register, so you again have one byte of time to take it out (again,
2Mbaud receive would be ~impossible without it, given you'd have one
bit time (8 cycles!) to take the data out ...)
> On 8 June 2015 at 12:31, Darryl Piper <
darryl...@googlemail.com> wrote:
>>
>> the usbserial code for the 16u2 and 8u2 is broken.... its incorrectly
>> ignores that the calculated baud rate setting might be greater than 4095.
>> thus it doesnt switch into the use_2x mode correctly on some baud_rates.
The default code uses U2X for all baud rates except 57600, what are
you talking about?
... oh you mean it should switch off U2X in the low end... (U2X
increases baudrate given divisor, so increases minimum baudrate, maybe
you have this inside out?...)
I (already before, just look at my github) improved the code a tiny
bit to turn off U2X for those rates which have no improvement in the
baudrate error with U2X (for better noise performance), but i'll need
to check if it applies to this one case i figured out.
At 16Mhz U2X: 16M / 8 / 4096, max baudrate 488 .... baud. Okay so
baudrates lower than 488 will fail.
But 16Mhz without U2X is just max 244 baud,
so what standard rates didnt work (that could): 300 baud.
I'll go and check that, but it wasnt part of my goals for a _fast_ usbserial :P
--
Urja Rannikko