![]() |
Forum Index : Microcontroller and PC projects : MM comms via UART.
Author | Message | ||||
Bowden_P Senior Member ![]() Joined: 20/03/2019 Location: United KingdomPosts: 162 |
Hi all, I've been experimenting with a UART interface between an MM v2 Backpack and an MM+ E100, and have read Geoff's primers in the MM manuals. I now have them communicating random character strings of various lengths successfully, so I started pushing up the baud rate to see when it all fell over. The 2 MM's are using the COM1: interface, and are connected via 3 feet of a figure-8 individually screened cable. A 'scope trace shows a fairly high amount of ringing at the highest frequency, yet the received character strings are rock solid. Starting at 20,000 baud, I eventually got to 1,000,000 baud without seeing any problems. However, in the manual Geoff states that the max. rate is 230,400 baud for the clock frequency I am using - 40MHz for both MM's. Is this likely to be possible, or am I being fooled somehow? With best regards, Paul. Nothing so constant as change. |
||||
Tinine Guru ![]() Joined: 30/03/2016 Location: United KingdomPosts: 1646 |
I seem to remember looking at the data sheets and not finding a BAUD specification which had me scratching my head. |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
The MM Plus can go to 1M without any problems. The standard Micromite is the one limited to 230400. As far as I know, that is still true but I have never pushed it. Jim VK7JH MMedit |
||||
Bowden_P Senior Member ![]() Joined: 20/03/2019 Location: United KingdomPosts: 162 |
Hi Tinine and Jim, Thanks for your replies. I guess 1Megabaud (is that a legitimate unit?) is possible if COM1: is a hardware peripheral - with a clock of 40MHz. I was pleasantly surprised to get such an improvement over my initial coding, which only worked to 20,000 baud. That code assessed each character as it was received - as per Geoff's GPS example, and checks for the CR at the end of the message. This latest code uses a fixed length message and has the COM1: interrupt set to the same number of characters, so reducing the program interaction until a message is received. I eventually hope to pass arrays of floats or integers via UART. Would you have any tips or tricks to suggest, to achieve this? With best regards, Paul. Nothing so constant as change. |
||||
Tinine Guru ![]() Joined: 30/03/2016 Location: United KingdomPosts: 1646 |
I only work with 32bit integers and I binary encode them in to four chr$ to keep the packets short. |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10310 |
BIN2STR$ and STR2BIN on the MM+ but not available on the MM2 where you would have to peek and poke into the variable Edited 2020-11-13 05:00 by matherp |
||||
Tinine Guru ![]() Joined: 30/03/2016 Location: United KingdomPosts: 1646 |
@matherp DOH! Didn't think of that. Right now I'm shifting and masking and I'm as obsessed with efficiency as the Cap'n. ![]() |
||||
MustardMan![]() Senior Member ![]() Joined: 30/08/2019 Location: AustraliaPosts: 175 |
There are many reasons the baud rates 300/600/1200... are common, most of those reasons being technical. An old-school modem might support 300/600/1200, which would suggest the channel (phone line) is capable of any speed below 1200. You might like to use 452 baud - if your modem could do it (which pretty much none of them would). As long as the transmitter and receiver agree on the rate, the baud can be pretty much anything you like. It is like how bit rates for MP3s have been standardised to a fixed set... 128kbps, 160kbps, 192kbps. For MP3 you can tell some encoders to do any rate you like (like telling your UART to run any baud rate you like). A few MP3 decoders can handle esoteric rates, but most can't. The inverse of most UARTs being able to handle esoteric bit rates, but there are some that can't. These days it is mostly poor programming that results in an artificially limited set. Most people stick to the 'standard' rates (for MP3 and UART) simply to keep things as widely compatible as possible. Cheers, |
||||
Bowden_P Senior Member ![]() Joined: 20/03/2019 Location: United KingdomPosts: 162 |
Thanks everyone. I looked at the spec. for the PIC32MX270 and didn't find a BAUD spec, but it does mention a rate for the UART of 12.5Mbps max, presumably for the 50MHz part. Therefore any rate of 1/4 the clock frequency would be OK - I assume. That would explain my comms still running at 1MBaud for clocks at 40MHz. Thanks for the BIN2STR$ and STR2BIN prompt, Peter. I am still using the older v5.05 manual, so missed that. I'll have a play with those. I plan to use variants of MM+ at both ends eventually, so data transfers will be easier than my current setup. ( BTW I am the so-and-so who has been talking to Phil Boyce about screen oddities on the MM+ E100 fitted with a 5" screen!) Thanks again for all your comments, Paul. Nothing so constant as change. |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |