So I have been trying to send a large amount of data via UART, say 256 to 1024 bytes at a time to the imp and polling the UART pin via uart.read(). I am then appending this data as it comes in to a string. In my current set up, I poll the UART buffer to see if there is any data every 0.0001 seconds:
When I send 256 bytes, I am able to read all of the values, but if I go to 512 or 1024, I only am able to receive maybe 80% of the transmitted values. Also, at 256 bytes, the data is captured all at once, but at higher rates I will get chunks of maybe 50-60 bytes rapidly after another
UART is being transmitted by code composer via an MSP430 with a simple counter and the baud rates match up correctly.
Does anyone have any advice on this issue?
This sort of thing is what the UART data-ready callback is for. See http://devwiki.electricimp.com/doku.php?id=electricimpapi:uart:configure for an example.
Part of the problem with your current code is that the imp.wakeup call does not have sub-millisecond resolution. Currently imp.wakeup(0.0001,…) behaves the same as imp.wakeup(0.01,…), i.e. it only has centisecond resolution. We do have a plan for how to achieve microsecond resolution everywhere, but it’s a faaar-future feature.
The example probably comes from Sparkfun and dates back to a time before the callback was available. Perhaps someone should request Jim at Sparkfun update the code or put a comment on the page regarding this feature.
Ah, it really ought to mention the time resolution in the API documentation. I’ll add that now.
@mjkuwp94 that would be a good idea. i also started with the sparkfun code not knowing that there was a better callback method available
Can the imp do 115,200 baud rate?
Yes but there doesn’t be a clear listing of baud rate range in the wiki
See last line of code example here
I have tried this with an Arduino, but I did not manage to get it to work at that baudrate
I’ll check in the STM32 datasheet what the actual baud rate ranges are. But certainly all the UARTs can do 115,200, or even 230,400. Whether you can process the data in Squirrel at that speed might be a different matter.
I’ve tested the UART at baud rates in excess of 900,000 (just to test the limits) and had it work successfully.
I looked into it, and updated the wiki. The available baud rates range from 920baud to 3,750,000baud (3.75MBd) for uart1289 and uart6E, and 460–1,875,000 for the other UARTs.
I was a bit surprised at how high the lower limits were, but then it is some decades since I last saw a 300baud modem…