Author Topic: How to use NUMBER_EXTERNAL_SERIAL  (Read 11401 times)

Offline mhoneywill

  • Full Member
  • ***
  • Posts: 173
    • View Profile
How to use NUMBER_EXTERNAL_SERIAL
« on: August 16, 2010, 03:28:21 PM »
Hi Mark,

I have an application where I need more Uarts that are on my chip, I'm using an LM3S1968 processor which has 3 Uarts and I need 4.

I notice that you may have dealt with this same problem youself because the Simulator has the define NUMBER_EXTERNAL_SERIAL which seems to allow the simulator to handle another 4 Com channels. I notice that these is no target code presumably because there are many ways of adding extra Uarts.

I have two options,

1. To bitbang a UART using GPIO and a couple of timers, possibly basing code on AN01270-01 from http://www.luminarymicro.com/home/app_notes.html

2. To use an external SPI or IIC uart like the MAX3107 http://www.maxim-ic.com/datasheet/index.mvp/id/6463

Which ever solution I use I want to hook in to uTasker so the application interface is the same, I presume I would need to do the following.

1. Extend fnConfigSCI to handle configuring my extra Uarts
2. Handle filling up RX buffers from my own, interupt routines.
3. Handle emptying TX buffers, and transmitting characters.

Am I correct im my assumptions and do you have any pointers?

Thanks

MArtin

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: How to use NUMBER_EXTERNAL_SERIAL
« Reply #1 on: August 16, 2010, 04:01:28 PM »
Hi Martin

I have heard about the Luminary application note about using bit-banging for UARTs but I never tried it due to the fact that it is a bit of a special solution (using a DMA based timer and port capture would certainly make for a reliable solution but not all chips have these and other methods may suffer from jitter and the corresponding operational problem that it could bring with it).

What I have done is used the SC16IS7xx via SPI as expansion for a further 4 UARTs (including HW control lines and extra ports if required). This is included in the SAM7X project since that is where it has been used. The driver is nevertheless generic since it just uses simple SPI communication mode and an IRQ interrupt.

The simulator can handle extra UARTs as you have seen and also simulates the chip in WinSim.c - search for EXT_UART_SC16IS7XX.

I have sent you a file called spi_sc16IS7xx.h (available in the SAM7X project only at the moment but should be generic once the HW macros to configure, read and write are adapted. Then you can see what it looks like and think about whether to use this chip or adapt the driver for a different type, if you don't go for the bit-banged solution (the file is an include to the processor file - in your case LM3Sxxxx.c).

To your specific questions:
1) This is how the fnConfigSCI() was adapted when a channel larger than internal channels is requested:

        fnConfigExtSCI((QUEUE_HANDLE)(Channel - NUMBER_SERIAL), pars);   // pass on to external UART driver
        #ifdef SUPPORT_HW_FLOW
        if (pars->Config & RTS_CTS) {                                     // HW flow control defined so configure RTS/CTS pins
            fnControlLine(Channel, (CONFIG_RTS_PIN | CONFIG_CTS_PIN), 0);
        }
        #endif


2) and 3) The file that I have sent handles the interrupt line and then gets/puts from/to buffers in a standard manner. It is included in the processor code and should be highly compatible once the SPI macros have been adapted where needed.

Regards

Mark



Offline phomann

  • Newbie
  • *
  • Posts: 47
    • View Profile
    • Homann Designs
Re: How to use NUMBER_EXTERNAL_SERIAL
« Reply #2 on: October 26, 2010, 04:52:32 AM »
Hi Mark, Martin,

I'm looking at adding a couple of more UARTS via SPI through the SC16IS7xx chips.

What is it that I need to do to uTasker to get this going? Are there additional header files or code modules that I need?

Cheers,

Peter.

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: How to use NUMBER_EXTERNAL_SERIAL
« Reply #3 on: October 26, 2010, 11:01:39 PM »
Hi Peter

I have sent you the new driver by email together with some instructions as to integrating it.

Regards

Mark

Offline mhoneywill

  • Full Member
  • ***
  • Posts: 173
    • View Profile
Re: How to use NUMBER_EXTERNAL_SERIAL
« Reply #4 on: October 27, 2010, 07:47:38 AM »
Hi Peter,

Couple of recommendations, I'm using the SC16IS750, and communicating using MODBUS RTU at 115200 baud. (Mark may have already included these changes)

1) Run the SPI as fast as you can, 4Mbs for SC16IS750 15mbs for SC16IS760.

2) Disbale the FIFO's in the UART as this messed up the timing and detection of the Modbus RTU end of massage gap. (3.5 message periods)

Good Luck

Martin