Uart stops working

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
Post Reply
oli
Posts: 17
Joined: Wed Aug 05, 2015 9:13 am

Uart stops working

Post by oli » Wed Aug 05, 2015 9:20 am

Hi all,

i'm using the pyboard for LIN communication, and it is working well so far. But i have some trouble with the uart itself. at some point it stops working! there is no error, the script is working and i get output over the repl, but i get no bytes over the uart. restarting solves the issue. is there a way to find out, where the problem could be?

thank you!
Oli

oli
Posts: 17
Joined: Wed Aug 05, 2015 9:13 am

Re: Uart stops working

Post by oli » Fri Aug 28, 2015 12:01 pm

since no one had an answer and in my application i had a lot of problems with stopping uart, i found the cause (hopefully). the USARTx_SR register did indicate an ORE flag, and then the .any() returned "false". so the application stopped. now, i check the SR register and if the ORE bit is set, i read, according to the manual of the stm32f405, first the SR and then the DR register. this seems to solve my problems...

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Uart stops working

Post by dhylands » Fri Aug 28, 2015 3:58 pm

Interesting. It seems that the default is to use a 64-byte buffer, which means that an interrupt handler is installed to transfer data from the HW to the buffer, so I wouldn't have expected ORE errors to be occurring.

Obviously, the driver needs to be improved a bit since it should self recover from that rather than "lockup".

oli
Posts: 17
Joined: Wed Aug 05, 2015 9:13 am

Re: Uart stops working

Post by oli » Sun Aug 30, 2015 1:03 pm

hi,

i have the read_buffer_len set to "0", because i hve to receive the LIN-break and so the recv-flags must match the current received byte.

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Uart stops working

Post by dhylands » Sun Aug 30, 2015 2:41 pm

ok - I would expect overrun errors when using a read buffer of zero.

Perhaps we need to widen the existing fifo to include the character statuses (like break, parity error, etc)

oli
Posts: 17
Joined: Wed Aug 05, 2015 9:13 am

Re: Uart stops working

Post by oli » Mon Aug 31, 2015 6:41 am

that would definitly solve the problem. perhaps i can take a look into it...

JimTal001
Posts: 176
Joined: Thu Jul 30, 2015 4:59 pm

Re: Uart stops working

Post by JimTal001 » Fri Sep 04, 2015 3:52 pm

I am now using the USB serial converter suggested by blmorris
http://www.adafruit.com/products/954

I have it connected to X1,X2 and Gnd. I am happy to say it is now generally working (after many driver install issues).
However, the shell.py program written by Dave (dhylands) will not work. When I type import shell to the terminal it kills REPL (no more communication). Dave's program is very helpful in viewing log files stored on the SD. If anyone has suggestions I would appreciate the assistance.

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Uart stops working

Post by dhylands » Fri Sep 04, 2015 4:51 pm

I seem to recall having some issues with shell.py when using the HW UART.

You might want to try changing the repl = pyb.USB_VCP() line: https://github.com/dhylands/upy-shell/b ... ell.py#L35 to point to your uart instead. If that doesn't work, you can always uncomment the second implementation of term_size https://github.com/dhylands/upy-shell/b ... py#L48-L49 that hard codes a terminal size. The terminal height isn't used anywhere, and the only place that uses the terminal width is the ls command.

The code is sending a special escape sequence to your terminal and reading back the result. However this is problematic when the repl is being sent to 2 places (because then both places could reply), so I wound up having to hard code it to read from the USB REPL. Te way its coded right now, when you use the UART as a REPL it hangs waiting on the USB to reply .

The pyb.repl_source function that I proposed wasn't accepted, and I have on my todo list adding something called a "pluggable" REPL so that you can install your own REPL behaviour, but that hasn't happened yet.

JimTal001
Posts: 176
Joined: Thu Jul 30, 2015 4:59 pm

Re: Uart stops working

Post by JimTal001 » Fri Sep 04, 2015 5:41 pm

What did work was enabling the commented out terminal size function.
Thanks Dave.

Post Reply