BasicChip bit-bang serial

Questions on UARTs, and serial communication
Post Reply
ronr
Posts: 19
Joined: Tue Nov 05, 2013 8:17 pm

BasicChip bit-bang serial

Post by ronr » Tue Jul 25, 2017 7:39 pm

I have used the bit-bang serial routines for the BasicChip on a few projects. I could not get things to work faster than 9600 baud, so I just stayed with 9600. Now I'd like to use 38400 and find that it and 19200 still do not work (garbled). I am using the SERIAL.bas with "waitmicro" calls (September 2015). Is there a newer version that could fix this problem? The documentation suggests that it should work up to 57K.
Thanks for any insight.



basicchip
Posts: 856
Joined: Fri Oct 19, 2012 2:39 am
Location: Lake Tahoe, CA
Contact:

Re: BasicChip bit-bang serial

Post by basicchip » Wed Jul 26, 2017 4:00 pm

SERIAL.bas was done originally with the Stamp sized module when there was only one serial port. Though I admit I too used bit-banged serial for a diagnostic port on an LPC4078 project, as all 4 other serial ports were in use.

There has been no work on bit banged serial since the beginning, and not much need for me to look at it. Could the code be sped up, maybe. But a better option is to use a part with more serial ports.

On the low end I tested the waters for an LPC812 based part, and still have a few lying around. Though it did not seem to gather enough interest to go to market. The same with the LPC11U37 (with builtin USB). Both of those have more than 1 serial port.

TodWulff
Posts: 31
Joined: Fri Oct 19, 2012 4:03 am
Location: The Mitten State - Shores of Lake Huron

Re: BasicChip bit-bang serial

Post by TodWulff » Sun Sep 30, 2018 1:05 am

As info, I am able to get a slow (30MHz) LPC824 to work reliably with bit banging an asynchronous 34800 baud serial input.

I went the bit banging route as I was, and still am, struggling with getting one of the unused UART peripherals working from w/in ARMbasic. However, that is a topic for another thread on this subforum. I'm sure that I'm missing something simple. I'll revisit that in the coming weeks, as an Iterative effort herein.

Anyways, I've been revisiting my ARMbasic code (from over a decade ago), to get it updated, and as an exercise in getting me reacquainted with the current ARMbasic environment.

Developing/refining existing bit banging code was kicking my arse a bit in that the timing of things on a slower device can be pretty finicky.

Having a scope was crucial in figuring out what was transpiring (at 38400, bit widths are on the order of 26uS , with halfbit times at 13uS (halfbit time is important on the first bit, to ensure sampling in the middle of the subsequent 8 bits (for each byte)) - throw in code to capture a timer here and there (a 2.4uS event for each intvar = timer instruction) and code to enable/disable interrupts, things can get out of hand pretty quickly when trying to debug).

Once I figured out the approach taken by Bruce with the bit banged library, and conjuring up an approach to the use of the scope to aid my efforts, things fell into place pretty quickly.

I've even figured out how to get get the device to autobaud at slower speeds (up to 38400, atm).

Now that the 38400 stuffs are working reliably, I'm going to push the code/ports, just to see how fast I can get the device to reliably receive async bit banged serial on a known serial input, and then I'll see if I can get it to autobaud at those faster rates.

This is largely an academic effort. I'll update herein with code, pics, and results, when appropriate, just so that folks can hopefully learn and benefit from the efforts. Until then...

basicchip
Posts: 856
Joined: Fri Oct 19, 2012 2:39 am
Location: Lake Tahoe, CA
Contact:

Re: BasicChip bit-bang serial

Post by basicchip » Sun Sep 30, 2018 10:32 am

Here is a simple UART test I use on SuperPRO, and Stamp for checking serial connection to the PC via TclTerm.

viewtopic.php?f=5&t=1262

Post Reply