Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 17:48 23 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Serial ports

Author Message
haiqu

Senior Member

Joined: 30/07/2011
Location: Australia
Posts: 152
Posted: 03:50pm 14 Aug 2011
Copy link to clipboard 
Print this post

I've noticed quite a few people requesting a serial port so I did an analysis of the design to see if there's a way to implement one. Tantalizingly there are several Tx or Rx lines available, just not pairs of them. So, can it be done? The answer is yes, but...

1. Moving signal SDO2 to spare pin 51 and using SDO3 would free up UART3
2. Moving signal !SS2 to spare pin 21 and using !SS4 would free up UART6
3. Moving signal SCK3/U5TX can't be done, it's used by the SD card
4. Moving signal OC3/U1RX can'rt be done, there's no spare OC pin

The first two look promising except they both conflict with Don's RTC module on the SM1 board, but if you're not going to fit those parts then it's all systems go. However they both would also require changes to the internal MMBASIC code and would therefore make the system incompatible with everyone else's version.

One last possibility is to grab RD9/U4RX from the back connector and free up the other half (U4TX) by removing the resistor going to the audio pin. This is probably the simplest solution.

Add one MAX232 and some caps and you're golden.

Cheers,

Rob

unzip, strip, touch, finger, grep, mount, fsck, more, yes, fsck, fsck, fsck, umount, sleep
 
Bob

Regular Member

Joined: 11/08/2011
Location: United Kingdom
Posts: 41
Posted: 07:19pm 14 Aug 2011
Copy link to clipboard 
Print this post

  haiqu said   I've noticed quite a few people requesting a serial port so I did an analysis of the design to see if there's a way to implement one. Tantalizingly there are several Tx or Rx lines available, just not pairs of them. So, can it be done?

[trimmed]


Hi Rob,

Bear in mind that async serial doesn't demand that the Tx and Rx parts belong to the same channel. It's quite OK in theory to send from e.g. UART 2 and receive on UART 3, since the two directions of signal have no interaction.

You can't do this with e.g. SPI though, since the SDI and SDO require a common clock, and the architecture expects a single shift-register between SDI & SDO.

Nevertheless, a problem is that often the chip architecture defines a group of pin connections that are part of a functional block, so it may well be that apparently free pins are actually being controlled by some other necessary function. This occurs IIRC on the SPI channel 2 (SDO2) used for video generation, which puts a 20MHz clock out on SCK2 (pin 4, n/c) and I believe also ties up the SDI2 (pin 5, n/c). Both of these pins also have async alternative functions, but the video generator is critical.
So pins that appear to be available may actually be unusable.

In summary (E&OE <g>):

*note* that pins shown "n/c" may be unusable due to being configured by being part of some other, used, functional block.

UART1
Txd: pin 51 is n/c
Rxd: pin 50 is used for video cct

UART2
Txd: pin 32 is used for SDcard
Rxd: pin 31 is used for SDcard

UART3
Txd: pin 6 is used for video cct
Rxd: pin 5 is n/c but may be tied up by the video cct (SDI2)

UART4
Txd: pin 49 is used for sound
Rxd: pin 43 is available on the expansion plug!

UART5
Txd: pin 29 is used for SDcard
Rxd: pin 21 is n/c

UART6
Txd: pin 4 is n/c but is tied up by the video cct (SCK2)
Rxd: pin 8 is used for video cct.

Hopefully there is a way to do it on existing boards without re-allocation of anything, but it is going to be tricky!

It all gets complicated, doesn't it?

Regards,
Bob

Bob Dalley
http://www.m0rjd.co.uk
 
Mal_M

Newbie

Joined: 08/08/2011
Location: Australia
Posts: 6
Posted: 12:00am 15 Aug 2011
Copy link to clipboard 
Print this post

Hi Rob, I was looking at a similar issue over the weekend. I implemented LPRINT and LLIST commands, with output at 9600 baud on I/O Pin 20 (PIC32MX Pin RE7). No PIC UARTS are used.

Here is the code I am using to bang out the text to the printer (this sits in T4Interrupt() in keyboard.c, and runs every 20 uSec):

if (PrinterDataRegFull) PrinterTimer++; // if transmitting, increment timer
switch(PrinterTimer){
case 0:
// Serial transmitter is idle. Check if we have a byte to send
if(PrinterQueueHead != PrinterQueueTail){ // if non-equal, there are bytes in the buffer
// Get next byte and place it in the transmit data register
PrinterDataRegister = PrinterQueue[PrinterQueueTail]; // fetch next byte to transmit
PrinterQueueTail = (PrinterQueueTail + 1) % PRINTER_QUEUE_SIZE; // increment tail pointer
PrinterDataRegFull = 1; // signal that the transmit register is occupied
// Send start bit
PRINTER_TXD = 0; // set output to SPACE (TTL logic 0, RS232 +ve)
}
break;
case 5: // Start sending bit 0 at t=100 uSec (ideal = 104 uSec. Error = -4.0% of one bit)
case 10: // Start sending bit 1 at t=200 uSec (ideal = 208 uSec. Error = -8.0% of one bit)
case 16: // Start sending bit 2 at t=320 uSec (ideal = 313 uSec. Error = +7.2% of one bit)
case 21: // Start sending bit 3 at t=420 uSec (ideal = 417 uSec. Error = +3.2% of one bit)
case 26: // Start sending bit 4 at t=520 uSec (ideal = 521 uSec. Error = -0.8% of one bit)
case 31: // Start sending bit 5 at t=620 uSec (ideal = 625 uSec. Error = -4.8% of one bit)
case 36: // Start sending bit 6 at t=720 uSec (ideal = 729 uSec. Error = -8.8% of one bit)
case 42: // Start sending bit 7 at t=840 uSec (ideal = 833 uSec. Error = +6.4% of one bit)
PRINTER_TXD = (PrinterDataRegister & 1) ? 1 : 0; // start sending next databit (starting with D0)
PrinterDataRegister >>= 1; // rotate the transmit data register
break;
case 47: // Start sending 2 stop bits at t=940 uSec (ideal = 938 uSec. Error = +2.4% of one bit)
PRINTER_TXD = 1; // set output to MARK (TTL logic 1, RS232 -ve)
break;
case (57 - 1): // This will give next start bit at t=1140 uSec (ideal = 1146 uSec. Error = -5.6% of one bit)
// At next interrupt, we can start sending next byte
PrinterDataRegFull = 0; // signal that the transmit register is empty
PrinterTimer = 0; // clear the transmit timer
break;
}


All seems to work OK so far (at least, all looks fine on the test bench with a DSO!). I still need to add a handshaking line (to pause output when the printer is busy) which I plan to add on I/O line 1, and a timeout mechanism.

I'm happy to publish the rest of the LPRINT/LLIST code if there is any interest in it.

It wouldn't be too hard to modify the above code, to get a bi-directional 9600 baud serial interface. Lower baud rates would also be possible, but I think the timing (TX and RX) would be too marginal for higher speeds.

Cheers.
 
Keith @

Senior Member

Joined: 19/06/2011
Location: Australia
Posts: 167
Posted: 01:20am 15 Aug 2011
Copy link to clipboard 
Print this post

Hi Bob

If push comes to shove it would be easy to dump the audio on UART4 in favour of serial ... I'm sure there is more call for serial then audio.

Keith
The more we know, the more we know we don't know !
 
Keith @

Senior Member

Joined: 19/06/2011
Location: Australia
Posts: 167
Posted: 03:36am 15 Aug 2011
Copy link to clipboard 
Print this post

Hi all

Can anyone tell me if this is useable on the Maximite .... a USB to Serial Converter

www.coolcomponents.co.uk/catalog/product_info.php?cPath=50_7 4&products_id=761&osCsid=93413e9d8a2642cd27a72c3426a1a2bb

Keith
The more we know, the more we know we don't know !
 
haiqu

Senior Member

Joined: 30/07/2011
Location: Australia
Posts: 152
Posted: 03:59am 15 Aug 2011
Copy link to clipboard 
Print this post

Bob: Using input and output channels on separate ports might be theoretically possible but makes software drivers unnecessarily complex. In my case the intended use would preclude that option anyhow, since the code would never be accepted back into the SVN base (OK, time to spill the beans, I'm porting 2.11BSD Unix to the Maximite and it's almost done). My analysis did also take account of the odd things that happen to unused pins within a group when some are used for different functions, which is why I steered away from the pins associated with video and SD card.

Mal: Bit bashing a comms port when there are 6 UARTS on board? Masochist! I don't care too much about control lines, using the PDP-11 system (XON-XOFF).

Keith: Yep, that was my conclusion. I could easily live without a low-fi beeper. Tried your link but even when corrected it didn't go to a single product. That's how it is with linking to database-generated URLs unfortunately. Anyhow, we already have serial via the only USB port on board.

Rob


Edited by haiqu 2011-08-16
unzip, strip, touch, finger, grep, mount, fsck, more, yes, fsck, fsck, fsck, umount, sleep
 
Keith @

Senior Member

Joined: 19/06/2011
Location: Australia
Posts: 167
Posted: 04:29am 15 Aug 2011
Copy link to clipboard 
Print this post

Sorrrry about the link

try this one

www.coolcomponents.co.uk/catalog/product_info.php?cPath=50_7 4&products_id=761

Keith
The more we know, the more we know we don't know !
 
Keith @

Senior Member

Joined: 19/06/2011
Location: Australia
Posts: 167
Posted: 04:42am 15 Aug 2011
Copy link to clipboard 
Print this post

copied details ... second link appears ok but still getting 404 error?

Arduino USB to Serial Converter
Stock Code : 000761
LIVE - 3 units currently available





This board converts a USB connection into 5 volt TX and RX that you can connect straight to the Arduino Mini or other microcontrollers, allowing them to talk to the computer.

It features the ATmega8U2 programmed as a USB-to-serial converter, the same chip found on the Arduino Uno. The USB Serial module has an ISCP interface, allowing you to reprogram the chip when placed in DFU mode.

The pinouts on the connector are compatible with a standard FTDI header.

UK pounds 8.80
Arduino USB to Serial Converter

Keith


The more we know, the more we know we don't know !
 
Bob

Regular Member

Joined: 11/08/2011
Location: United Kingdom
Posts: 41
Posted: 09:14am 15 Aug 2011
Copy link to clipboard 
Print this post

Hi Keith,

  Keith @ said   Hi Bob

If push comes to shove it would be easy to dump the audio on UART4 in favour of serial ... I'm sure there is more call for serial then audio.

Keith


I agree; this would be the only reasonable approach. I have no transducer on the sound output anyway. Probably this is the same for a lot of us.
Also we would only need short R6 and there is even a connector for the pin!

Regards,
Bob
Bob Dalley
http://www.m0rjd.co.uk
 
haiqu

Senior Member

Joined: 30/07/2011
Location: Australia
Posts: 152
Posted: 09:58am 15 Aug 2011
Copy link to clipboard 
Print this post

Keith,

Looks nice, but we don't yet have an RS-232 port to connect it to! I did the mods today, will let you know how it goes.

Bob,

You'll also have to remove the resistor to ground (R8 on the original board), I found it simpler to just remove the series resistor and solder to the pad.
unzip, strip, touch, finger, grep, mount, fsck, more, yes, fsck, fsck, fsck, umount, sleep
 
Bob

Regular Member

Joined: 11/08/2011
Location: United Kingdom
Posts: 41
Posted: 12:21pm 15 Aug 2011
Copy link to clipboard 
Print this post

  haiqu said   Keith,

Bob,

You'll also have to remove the resistor to ground (R8 on the original board), I found it simpler to just remove the series resistor and solder to the pad.

Yes, removing R8 also would be best, although 1k to gnd is not a show-stopper.

I wonder if the sounder could be re-positioned onto one of the otherwise unused pins of the programming header (unused by MMBasic) so that it can be plugged in, with any necessary buffer or attenuator, when not programming (which is usually all the time).

PGD on that header can be configured as RB0,
PGC as RB1.

The rails (3.3v and Gnd) are also on that header, for convenience!
I don't know how the sounder is implemented in firmware, but port pins sound like a good start.

Pity an async serial port can't be found on those chip pins...

Can anyone tell us what Geoff's plans are for a serial port in the next release?

Regards,
Bob
Bob Dalley
http://www.m0rjd.co.uk
 
rhamer
Senior Member

Joined: 06/06/2011
Location: Australia
Posts: 174
Posted: 12:40pm 15 Aug 2011
Copy link to clipboard 
Print this post

Software UART.

Regards

Rohan
Rohan Hamer
HAMFIELD Software & Hardware Solutions

Makers of the Maximite Expander.

http://www.hamfield.com.au
 
Keith @

Senior Member

Joined: 19/06/2011
Location: Australia
Posts: 167
Posted: 12:48pm 15 Aug 2011
Copy link to clipboard 
Print this post

haiqu

Bob is trying to implement the serial comms using the existing pins.

I was trying to see if anyone had any idea how to use the USB on the Maximite with an adapter to provide the serial comms.

My approach is based on the fact that the number of pins are limited and may be more useful for other uses that USB won't allow.

Keith
The more we know, the more we know we don't know !
 
haiqu

Senior Member

Joined: 30/07/2011
Location: Australia
Posts: 152
Posted: 02:59pm 15 Aug 2011
Copy link to clipboard 
Print this post

Keith,

The adapter you showed us attaches to USB on the PC end and an RS-232 port on the Maximite end. It still needs some sort of UART available to function. There's no advantage to using it unless you don't have a real COM port available on the PC.

The PIC32 is capable of acting as a limited USB host (USB-On-The-Go) but doing that is more difficult than finding a pair of UART pins available.

Rob

unzip, strip, touch, finger, grep, mount, fsck, more, yes, fsck, fsck, fsck, umount, sleep
 
haiqu

Senior Member

Joined: 30/07/2011
Location: Australia
Posts: 152
Posted: 03:12pm 15 Aug 2011
Copy link to clipboard 
Print this post

  Bob said  

I wonder if the sounder could be re-positioned onto one of the otherwise unused pins of the programming header (unused by MMBasic) so that it can be plugged in, with any necessary buffer or attenuator, when not programming (which is usually all the time).



Pin 51 (unused OC4) is the only spare candidate capable of delivering audio. I can live without it anyhow.

Rob

unzip, strip, touch, finger, grep, mount, fsck, more, yes, fsck, fsck, fsck, umount, sleep
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024