Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Topics - saurabh

Pages: [1]
NXPTM LPC2XXX and LPC17XX / RS 485 with LPC-23xx
« on: October 05, 2009, 07:25:52 PM »
Dear All,

I am losing RS-485 based UART communication after transffering few hundred bytes...

I have RS-485 IC with my board (LPC2388) on UART -2 , Which is half duplex.
Direction selection is auto (as when we trasmit) Tx get automatically enabled, and
RX is selected as default. (Its is two line interface RX and TX only).

Rightnow I am trying to use RS485 communication driver (Port opening and send receive)
like other Rs232 based UART drivers (other UARTs (0,1,3) seemsworking well),

but i am facing issue with Rs-485 , I am losing Rs-485 communication after few Query-Responce
to/from external the 485-Device. (Baud rate I am using is 9600). Losing communication means
Only not able to transmit further but I can get bytes from RS485 network then. That is the issue.

Should i need to use the existing UART open and read write routines with any additiional
parmaters for make it work for RS-485. My curent Uart open,write,read codes are as below.

Code: [Select]
extern QUEUE_HANDLE fnOpenUART2(unsigned char ucDriverMode)
//TTYTABLE tInterfaceParameters;                                       // table for passing information to driver
    tInterfaceParameters2.Channel = 2;                            // set UART channel for serial use
    tInterfaceParameters2.ucSpeed = SERIAL_BAUD_9600;
    tInterfaceParameters2.Rx_tx_sizes.RxQueueSize = RTU_RX_BUFFER_SIZE;       // input buffer size
    tInterfaceParameters2.Rx_tx_sizes.TxQueueSize = RTU_TX_BUFFER_SIZE;       // output buffer size
    tInterfaceParameters2.Task_to_wake = TASK_RS485_CALLBACK;                        // wake self when messages have been received
    tInterfaceParameters2.ucFlowHighWater = temp_pars->temp_parameters.ucFlowHigh;// set the flow control high and low water levels in %
    tInterfaceParameters2.ucFlowLowWater = temp_pars->temp_parameters.ucFlowLow;
    tInterfaceParameters2.Config = temp_pars->temp_parameters.usSerialMode; // {43}
    #ifdef TEST_MSG_MODE
    tInterfaceParameters2.Config |= (MSG_MODE);
        #if defined (TEST_MSG_CNT_MODE) && defined (SUPPORT_MSG_CNT)
    tInterfaceParameters2.Config |= (MSG_MODE_RX_CNT);
    tInterfaceParameters2.Config &= ~USE_XON_OFF;
    tInterfaceParameters2.ucMessageTerminator = '\r';
  //tInterfaceParameters.ucDMAConfig = 0;                                // disable DMA
    tInterfaceParameters2.ucDMAConfig = UART_TX_DMA;                      // activate DMA on transmission
  //tInterfaceParameters.ucDMAConfig |= (UART_RX_DMA | UART_RX_DMA_HALF_BUFFER); // test half buffer DMA reception
    if ((SerialPortID2 = fnOpen( TYPE_TTY, ucDriverMode, &tInterfaceParameters2 )) != 0) { // open or change the channel with defined configurations (initially inactive)
        fnDriver( SerialPortID2, ( TX_ON | RX_ON ), 0 );                  // enable rx and tx
        if (tInterfaceParameters2.Config & RTS_CTS) {                     // {8}
            fnDriver( SerialPortID2, (MODIFY_INTERRUPT | ENABLE_CTS_CHANGE), 0 ); // activate CTS interrupt when working with HW flow control (this returns also the present control line states)
            fnDriver( SerialPortID2, (MODIFY_CONTROL | SET_RTS), 0 );     // activate RTS line when working with HW flow control
    return SerialPortID2;

I am writing data (Query) to rs-485 as below

Code: [Select]
My_Write_Func(unsigned char *transBuf,Len)

Then read is done by serial callback function

Code: [Select]
extern void fnCallBackSerialRS485(TTASKTABLE *ptrTaskTable)
unsigned char ucInputByte,TP[5];

while (fnRead( MyPort2, &ucInputByte, 1) != 0)
Mdata[EMTcnt]= ucInputByte;

I have attached the image of my Rs-485 section which used UART2 of LPC2388.

What I observed is that , when I lose RS-485 communication only TX get fail, I can
still have RX line working and I am geting bytes thru the serial callback function.

I dont know why this is hapapning , as RS-485 section was working with my Old code.
I made send/recive level changes like i am using now fnWrite function to send bytes rather then
my SendChar(PortNo,Byte) function, and rather then
my old UART ISR RS485UART2 __irq ISR , rightnow I am using callnback function (as provided in demo) to get bytes form UART2. (Shown in code above).

Can anybudy help me how to get this ractify?

-Thanks in advance

NXPTM LPC2XXX and LPC17XX / TCP connection get terminated after 20 minuts
« on: September 25, 2009, 03:59:27 PM »
Dear all,

I have made TCP listner on port 502,  my PC based TCP client is sending/getting data at each 1.5 sec,
interval, it works well initially, but after some 20 minuts (modscan32)PC client lost TCP connection with
board, and then it can get modscan32(tcp client) connected to my TCP server only after manually making
connection again.

What should I  do to keep my socket alive 24x7?
I learnt from docs and threads that if socket timeout set to 0xffff then it can be made keep alive alltime but
somehow i am still losing connectivity.
Am I missing something?

I have made Max user TCP connections to 10
I have disabled modbus TCP , (As i am using my Modbus routines)
Code of my app as below
      if(!Init)   // Init once
      else            // run time


typedef struct stTCP_MESSAGE
    TCP_HEADER     tTCP_Header;     // reserve header space
    unsigned char   ucTCP_Message[TEST_BUFFER_LENGTH];

static int fnTestListener(USOCKET Socket, unsigned char ucEvent, unsigned char *ucIp_Data, unsigned short usPortLen);
static unsigned short usTestPort = 502;
static USOCKET test_socket= -1,test_socket1= -1,test_socket2 = -1;


extern void fnUserTcp(void)
                               // declare a static socket variable (the value could also be fixed)

    test_socket = fnGetTCP_Socket(TOS_MAXIMISE_RELIABILITY, 0xffff, fnTestListener);    
    fnTCP_Listen(test_socket, usTestPort, 0);

static int fnTestListener(USOCKET Socket, unsigned char ucEvent, unsigned char *ucIp_Data, unsigned short usPortLen)
   int n,i;
   unsigned char TP[30];
   TCP_MESSAGE test_message;

    switch (ucEvent)
    case TCP_EVENT_CONREQ:                                             
         fnDebugMsg("\r\n####Socket Connected........#####");
    case TCP_EVENT_ACK:
    case TCP_EVENT_DATA:
                                DecodeTCPQuery(ucIp_Data);                        // My Function
                                if (fnSendTCP(Socket, ResponceData, ResponceLen, TCP_FLAG_PUSH) > 0)    
                return APP_SENT_DATA;
           fnDebugMsg("\r\n########## Aborted........##########");
         fnDebugMsg("\r\n########## CLOSED........##########");
      fnTCP_Listen(Socket, usTestPort, 0);                    // go back to listening state on next port number
    return APP_ACCEPT;

NXPTM LPC2XXX and LPC17XX / My customized hardware
« on: September 21, 2009, 03:35:16 PM »
Dear all,

I have my hardware derived by MCB2300 ,
What I did before migrate to uTasker , I interfaced external
ADC, EEPROM, and RTC all (bit banged protocols) with
GPIO lines (I have not used internals SPI controllers)!

ADC :  p0.12  p0.23  p3.23  p3.25     (Bit banged SPI)
          SDI     SDO   CS      SCLK

RTC:          p0.6,   p0.7 ,   p0.8     (Bit banged SPI)
                SCLK    BIO      EB     

EEPROM:    p0.27  p0.28                (Bit banged I2C)
                SDA0   SCL0

Now , what we used with this (already developed) bit banged typed
method was software delays (for timing management) , I know this
was not the proper method, but now I want this to work with uTasker.

What I observed when I call old (working) routines for init and read write, it is
not working with uTasker (I am making call to this old drivers within new created task).

I checked PINSELECT and port directions. But i sense that I am missing something.
Should i need to do something with config.h/ app_hw_lpc23xx.h or any other file
for like disabling SPI/I2c from there Port setting from there to make my old drivers

Also one more thing that I am worrying about is that , I was using nichelite OS ,
in they provided function TK_SLEEP(mili_sec) , we made heavy use of this function
(this function delivers control to other tasks and hold execution of current task for
specified time).

How can I compensate this task sleep in uTasker, as there is no task sleep in



Pages: [1]