Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve some issues with the UART applet's auto-baud detection. #260

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions software/glasgow/applet/interface/uart/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def elaborate(self, platform):

m.d.comb += uart.bit_cyc.eq(self.bit_cyc)
with m.If(self.use_auto):
with m.If((uart.rx_ferr | uart.rx_perr) & (self.auto_cyc != ~0)):
with m.If(self.auto_cyc != ~0):
m.d.sync += self.bit_cyc.eq(self.auto_cyc)
with m.Else():
m.d.sync += self.bit_cyc.eq(self.manual_cyc)
Expand Down Expand Up @@ -260,7 +260,11 @@ async def _monitor_errors(self, device):
self.logger.warning("%d frame or parity errors detected", delta)

new_bit_cyc = await device.read_register(self.__addr_bit_cyc, width=4)
if new_bit_cyc != cur_bit_cyc:

cur_bit_cyc_lo = cur_bit_cyc * 0.95
cur_bit_cyc_hi = cur_bit_cyc * 1.05

if new_bit_cyc < cur_bit_cyc_lo or new_bit_cyc > cur_bit_cyc_hi:
self.logger.info("switched to %d baud",
self.__sys_clk_freq // (new_bit_cyc + 1))
cur_bit_cyc = new_bit_cyc
Expand Down