9bit uart on 11920 baud rate Topic is solved

New to XMOS and XCore? Get started here.
jolly
Member
Posts: 12
Joined: Fri Mar 12, 2021 10:55 am

9bit uart on 11920 baud rate

Post by jolly »

Hey XE
I just got a XK-AUDIO-216-MC-AB and need to find out if it would be possible to set up a uart with 9bits on the board?
I have an old legacy system I need to connect it to, with 9bit uart on 11920 baud rate.
I found the Uart lib and datasheet but can find it mention anywhere if possible, so before I wasted countless week trying to, I figured id ask first :D

Best regards
Jolly


View Solution
User avatar
akp
XCore Expert
Posts: 578
Joined: Thu Nov 26, 2015 11:47 pm

Post by akp »

Yes, it's possible. The selected platform isn't the best for getting GPIO. You're probably in luck that the MIDI IO will support the baud rate you need. However, you'll need to write your own uart code (you can modify the existing stuff) since the existing code doesn't consider 9 bits bytes. It allows 1 to 8 bits per byte.

You will have to write it yourself. At 11920 bps you've got tons of clock cycles so you don't have to worry about your code being efficient.
jolly
Member
Posts: 12
Joined: Fri Mar 12, 2021 10:55 am

Post by jolly »

I am missing a zero :(, it should be a standard 19200 baud rate (my bad).
I had a look in the Uart lib and look like that i would be possible to modify the files.
Also, it seems like the IO I can use on the board would be the MI_RX and MI_TX?

Thanks for taking time responding and helping me.
jolly
Member
Posts: 12
Joined: Fri Mar 12, 2021 10:55 am

Post by jolly »

I cannot seem to hit the keyboard right today, i mean 19200 ofc. Jesus
Lucky it is Friday
jolly
Member
Posts: 12
Joined: Fri Mar 12, 2021 10:55 am

Post by jolly »

Would it be possible to use the SDI0(1-3) pins as half duplex uart pins? it seems if i take off the jumper it would work just as free pins.
I am trying to run the example code of the half duplex but cant seem to get it to work just with 8bit(befor i try to get it to 9) :)
User avatar
akp
XCore Expert
Posts: 578
Joined: Thu Nov 26, 2015 11:47 pm

Post by akp »

That would probably work. The whole 4 bit port would have to be all output or all input at the same time, you won't be able to have one of the pins as an input and another as an output in push pull mode. There is an open drain mode that could probably do half duplex with multiple pins on a port transmitting and receiving at the same time but I haven't looked at the half duplex uart so I don't know if that's supported with the out of the box code.
jolly
Member
Posts: 12
Joined: Fri Mar 12, 2021 10:55 am

Post by jolly »

Hey agian AKP, thank you for taking time to help a newb :)
So, it would not be possible to do an in and out pin at the same time with the xSDI pins? i though if i reconfigured them it would be possible?
I am trying to go off the https://www.xmos.ai/download/lib_uart-[ ... .0rc1).pdf page 8
Maybe i should reconfigure some other pins on the board? i know it no the smartest plan as a new person to xmos, but i need the audio interface :,)
User avatar
akp
XCore Expert
Posts: 578
Joined: Thu Nov 26, 2015 11:47 pm

Post by akp »

Sorry, the SDI pins are on one bit ports so you can absolutely use them for UART if you don't need them for audio.
jolly
Member
Posts: 12
Joined: Fri Mar 12, 2021 10:55 am

Post by jolly »

Hey guys, got the UART up and running on a SDI pin and even got it to send 9bit but only the 9th as a empty one.
So, I modified the lib of UART to accept 9 bit, but it seems like there’s a place in there where it only transfer 8 of those but is still sending the 9th empty along.
The code I have been tampering with is the uart_half_duplex.xc from the lib_uart and it seems to work with sending the 9bit along the 9th one is just not getting passed.?

And thanks for the help befor :)

Best regards Jolly
Attachments
uart_half_duplex(xc).PNG
(21.96 KiB) Not downloaded yet
uart_half_duplex(xc).PNG
(21.96 KiB) Not downloaded yet
Uart9 bit code.PNG
(23.2 KiB) Not downloaded yet
Uart9 bit code.PNG
(23.2 KiB) Not downloaded yet
9bit uart.PNG
9bit uart.PNG (3.56 KiB) Viewed 6154 times
9bit uart.PNG
9bit uart.PNG (3.56 KiB) Viewed 6154 times
User avatar
akp
XCore Expert
Posts: 578
Joined: Thu Nov 26, 2015 11:47 pm

Post by akp »

Off the bat your test variable in the testapp task is a uint8_t which only holds 8 bits -- so that's the immediate reason your MS bit is getting dropped. And unless you've changed the buffering that only supports 8 bit values, too. The easiest thing to do would be to change the code so it can handle up to 16 bit words and use 16 bit slots in the buffer. Of course that's pretty inefficient use of memory but maybe it's not a problem.
Post Reply