Can you post a link to this please? I'd like to look at it.Berni wrote:The USART example on the xmos website has its baud rate slightly off in the high speeds. A slightly off baudrate typically results in large chunks of data not sending properly as the clock loses sync til the end.
UART problem - help needed
-
- XCore Addict
- Posts: 165
- Joined: Wed Feb 10, 2010 2:32 pm
-
- Respected Member
- Posts: 363
- Joined: Thu Dec 10, 2009 10:17 pm
Here it is : http://www.xmos.com/applications/comms/uart-two-threads
I remember i had problems using it at 115200 baud, then i tweaked the baud rate setting (Up i think) a little and it started to work reliably.
I remember i had problems using it at 115200 baud, then i tweaked the baud rate setting (Up i think) a little and it started to work reliably.
-
- XCore Addict
- Posts: 207
- Joined: Thu Dec 10, 2009 11:00 pm
- Location: Mexico
@Woody: flow control was set to NONE (re-checked), sorry for misleading you.
I have linked the Arduino's Tx to the PC directly (via FT232 serial-to-usb-virtual com port) and check that it works OK.
I will try to make an echo test as you suggest.
@Berni: could you please provide more details on what could be done to tweak baudrade?
I use: and approach.
Should I use smaller/bigger BIT_TIME value?
I have linked the Arduino's Tx to the PC directly (via FT232 serial-to-usb-virtual com port) and check that it works OK.
I will try to make an echo test as you suggest.
@Berni: could you please provide more details on what could be done to tweak baudrade?
I use:
Code: Select all
#define BIT_RATE 9600
#define BIT_TIME XS1_TIMER_HZ / BIT_RATE
Code: Select all
t when timerafter(time) :> void;
Should I use smaller/bigger BIT_TIME value?
-
- XCore Expert
- Posts: 546
- Joined: Thu Dec 10, 2009 10:41 pm
- Location: St. Leonards-on-Sea, E. Sussex, UK.
To check the baud rate accurately you could output 'U' continuously (alternating ones and zeros) and check the frequency with a counter.
This code of mine works OK at 115k:
http://www.xmoslinkers.org/node/347
Leon
This code of mine works OK at 115k:
http://www.xmoslinkers.org/node/347
Leon
-
- XCore Addict
- Posts: 207
- Joined: Thu Dec 10, 2009 11:00 pm
- Location: Mexico
I am very ashamed - multimeter is all I have right now, please, give me some time to equip my lab! ;)
-
- XCore Expert
- Posts: 546
- Joined: Thu Dec 10, 2009 10:41 pm
- Location: St. Leonards-on-Sea, E. Sussex, UK.
You could use some code on a spare thread, or a different board, to check the frequency. Of course, it won't show if the crystal is off-frequency if you use the same board, but it might help.
-
- Respected Member
- Posts: 363
- Joined: Thu Dec 10, 2009 10:17 pm
Tweak the BIT_RATE define a bit and see if it helps. It might be the same problem as i had at 115200. It could be the boards clock wrong all together or the code introducing a tiny delay that ruins the timing.
-
- XCore Addict
- Posts: 165
- Joined: Wed Feb 10, 2010 2:32 pm
That's a really great suggestion! And as Leon says, looping that round into another port will allow you to time it.leon_heller wrote:To check the baud rate accurately you could output 'U' continuously (alternating ones and zeros) and check the frequency with a counter.
If there is a problem with the clock setup it's likely to be by orders of magnitude rather than 5% out, so getting an LED to flash once a second allows you to check this with a stopwatch.
-
- Respected Member
- Posts: 363
- Joined: Thu Dec 10, 2009 10:17 pm
Well sometime il get my XLogic project done, then you will be able to turn one thread on a xmos chip in to a logic analyzer.
-
- XCore Addict
- Posts: 165
- Joined: Wed Feb 10, 2010 2:32 pm
In response to Berni's comments about the UART, I reviewed the UART code on xmos.com. I thought had rather a lot of non UART related code in it, so I've changed it. You can see the new code here http://www.xmos.com/applications/comms/uart
There are two UART implementations: a simple two thread implementation based on the example in 2.5 of 'Programming XC on XMOS Devices' (http://www.xmos.com/system/files/xcuser_en.pdf); and a single thread implementation. These are simple implementations, designed to demonstrate how a UART can be implemented. Any additional features or interface solutions should be easy to add for your application.
There are two UART implementations: a simple two thread implementation based on the example in 2.5 of 'Programming XC on XMOS Devices' (http://www.xmos.com/system/files/xcuser_en.pdf); and a single thread implementation. These are simple implementations, designed to demonstrate how a UART can be implemented. Any additional features or interface solutions should be easy to add for your application.