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.


Messages - saurabh

Pages: [1]
1
NXPTM LPC2XXX and LPC17XX / Re: boot loader support in LPC2388
« on: October 15, 2009, 03:52:52 PM »
Good morning Mark,

   I have generated bootloader and applciation combined hex file and it is running properly. but after that when we are generating new z.bin using convert.exe with magic no it  is not generating and gives error . I have attach my application file please check it and give me reply what problem there. we are only wait for your reply.

Thank you

Manish Dabhi


2
NXPTM LPC2XXX and LPC17XX / Re: boot loader support in LPC2388
« on: October 15, 2009, 03:48:24 PM »
 Good morning Mark,

 we have generated hex of combining booy loader and application code and downlaod in board and after that it is running successfully, but after that when we are duming new code(z.bin developed using convert.exe) it will not generated and gives error (cant create). so I have attach my application.bin please check it and reply me if their have any problem.

3
NXPTM LPC2XXX and LPC17XX / Re: RS 485 with LPC-23xx
« on: October 07, 2009, 08:17:48 AM »
Thanks Mark!

yes it had issue UART configruation not with RS-485...

I have used config without handshake and HW flow then works well

Thanks...

4
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
    #ifdef SUPPORT_FLOW_HIGH_LOW
    tInterfaceParameters2.ucFlowHighWater = temp_pars->temp_parameters.ucFlowHigh;// set the flow control high and low water levels in %
    tInterfaceParameters2.ucFlowLowWater = temp_pars->temp_parameters.ucFlowLow;
    #endif
    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);
        #endif
    tInterfaceParameters2.Config &= ~USE_XON_OFF;
    tInterfaceParameters2.ucMessageTerminator = '\r';
    #endif
    #ifdef SERIAL_SUPPORT_DMA
  //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
    #endif
    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)
{
        fnWrite(MyPort2,transBuf,Len);
}


Then read is done by serial callback function

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

while (fnRead( MyPort2, &ucInputByte, 1) != 0)
{
           memset(TP,0,5);
           sprintf(TP,"%x,",ucInputByte);
           fnDebugMsg(TP);
// SAVE DATA TO MyBUFFER
if(EMTcnt<200)
{
Mdata[EMTcnt]= ucInputByte;
EMTcnt++;
}
}
}


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
Saurabh

5
Yes I think you are right its not worthwhile to write 128 KB flash for 8 KB of user paramaters,
What i can do is, for around 1.8 K of isolated user paramaters I can use uParametersystem
(which is working), and for other array buffers (3.5 KB) I can use uFileSystem, means using
a composite approch. When these buffers changes in memory write a complete file to flash,
and retrive values to memory from flash when necessory.

6
µTasker general / Re: Extending the parameter block with my own variables
« on: September 30, 2009, 02:45:32 PM »
Hey Mark,

I am using LPC2388 controller, with 512 KB flash.

I have extended structure PARS block with my application parameters , and size of total PARS   now goes to 2016 bytes,
and size of TEMPPARS(which also contains object of PARS goes to  2040 bytes.

I am making use of existing functions
Code: [Select]
fnSaveNewPars,

It works parameters blocks size upto some 2046 bytes,

If I am adding more parameters after this, it is not working and I m getting garbage values for newly added parameters.

To accommodate more parameters (my req. is 5 KB of NV Variables to store at flash)
I have made following changes in various Macros values

I changed

#define uFILE_START  (FLASH_START_ADDRESS + FLASH_SECTOR_15_OFFSET)  
                               (old was 17th sector, my code will take at most upto 13th sector)


#define FILE_SYSTEM_SIZE (3*FLASH_GRANULARITY_LARGE)
                               (old was 5*FLASH_GRANULARITY_LARGE) + (4*FLASH_GRANULARITY_SMALL)


#define PARAMETER_BLOCK_GRANULARITY     (FLASH_GRANULARITY_LARGE)
                                (old was FLASH_GRANULARITY_SMALL)
                

#define PARAMETER_BLOCK_START   FLASH_SECTOR_18_OFFSET
                                (old was FLASH_SECTOR_26_OFFSET)

#define PAR_BLOCK_SIZE  (4*PARAMETER_BLOCK_SIZE)

i keep set
   #define USE_PARAMETER_BLOCK                                
    #define USE_PAR_SWAP_BLOCK




I tried to understand why 32 KB of flash sector only allow to store parameters values upto 2040 bytes?! .

I could find in the flash file system document that

"If a device doesn’t support “accumulative writes” it is necessary to use one FLASH
word (size of word depends on device) per variable byte. An example of this is the
M9S12NE64, which uses 16 bit FLASH words and cannot perform accumulative
writes. When a block of user parameters is saved, each of the bytes in the block of
variables is saved in an individual word. A parameter block of 512 bytes (the FLASH
granularity in the NE64) can therefore save (512 – 4)/2 bytes [254] of user data."

I could understand (if so!) that with LPC2388 it can save ((32*1024) - 2(16))/16 , 2046 Bytes
of data due to flash word length is 16. isn't it?


But sill I increase PAR_BLOCK_SIZE  to (4*PARAMETER_BLOCK_SIZE) then it should work
for (2046*2)=4092 Bytes.... :-[  but it is still stores only 2046 bytes


Will you pls tell me how can I accomplish storage of bigger data (parameters upto 5K) with uParameter System.

-
Thanks
Saurabh

7

Thanks mark,

Acutally I able to locate why it was disconnected ..
(It was disconnected due to improper handling of partial Ack case, and event regen case)

I saw when some partail ACK case comes, then such 3-5 paritla ACK, regrenrate case get
executed and then connection get aborted.

I modified listner as below... and working well since morning..:)

Infact with my function DecodeTcpQuery() , I kept validation but for simplicity I had not shown
last time...

Though Now its working, Is below my code all right?
(As per performance and reliabilty conserns)

----------------------------------------------------------------------------------

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:                                       
    case TCP_EVENT_CONNECTED: break;
      if(ucEvent==TCP_EVENT_CONNECTED)
         {
         fnDebugMsg("\r\n####Socket Connected........#####");
         sprintf(TP,"\r\nConn-SockID=%d",Socket);
         fnDebugMsg(TP);
         }
            break;
    case TCP_EVENT_ACK: break;
    case TCP_EVENT_ARP_RESOLUTION_FAILED:break;
    case TCP_EVENT_PARTIAL_ACK:
                return APP_REQUEST_CLOSE;

    case TCP_EVENT_REGENERATE:
                          // SEND OLD Know valid data Call_My_Fun(); followed by fnTcpSend(...)
                         return APP_SENT_DATA;
    case TCP_EVENT_DATA:

                          if(DecodeTCPQuery(ucIp_Data))                        // My Function
                          {     
                                if (fnSendTCP(Socket, ResponceData, ResponceLen, TCP_FLAG_PUSH) > 0)   
                                 {
                                  return APP_SENT_DATA;
                                  }
                           }
           
                            break;

    case TCP_EVENT_ABORT:
        if(ucEvent==TCP_EVENT_ABORT)
        {
           fnDebugMsg("\r\n########## Aborted........##########");
          sprintf(TP,"\r\nAbrt-SockID=%d",Socket);
         fnDebugMsg(TP);
        }
    case TCP_EVENT_CLOSED:
      if(ucEvent==TCP_EVENT_CONNECTED)
      {   
         fnDebugMsg("\r\n########## CLOSED........##########");
         sprintf(TP,"\r\nClose-SockID=%d",Socket);
         fnDebugMsg(TP);
      }
       
      fnTCP_Listen(Socket, usTestPort, 0);                 
        break;
    }
    return APP_ACCEPT;
}

8
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
-------------------------------------------
   myTask
   {
   -------------
    ------------
      if(!Init)   // Init once
      {
          --------------
          --------------
          fnUserTcp();
          -------------
          -------------
           
          Init=1;
      }
      else            // run time
      {
                    -----------------
                    ----------------
                    ----------------
      }




   }
--------------------------------------------------

#define TEST_BUFFER_LENGTH 100
typedef struct stTCP_MESSAGE
{
    TCP_HEADER     tTCP_Header;     // reserve header space
    unsigned char   ucTCP_Message[TEST_BUFFER_LENGTH];
} TCP_MESSAGE;
----------------------------------------------------------

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:                                             
    case TCP_EVENT_CONNECTED:
      if(ucEvent==TCP_EVENT_CONNECTED)
         {
         fnDebugMsg("\r\n####Socket Connected........#####");
         sprintf(TP,"\r\nConn-SockID=%d",Socket);
         fnDebugMsg(TP);
         }
    case TCP_EVENT_CLOSE:
    case TCP_EVENT_ACK:
    case TCP_EVENT_ARP_RESOLUTION_FAILED:
    case TCP_EVENT_PARTIAL_ACK:
        break;
    case TCP_EVENT_REGENERATE:
    case TCP_EVENT_DATA:
         
                         
      
                                DecodeTCPQuery(ucIp_Data);                        // My Function
                               
                                if (fnSendTCP(Socket, ResponceData, ResponceLen, TCP_FLAG_PUSH) > 0)    
                                 {
                return APP_SENT_DATA;
                    }
            
      break;
    case TCP_EVENT_ABORT:
        if(ucEvent==TCP_EVENT_ABORT)
        {
           fnDebugMsg("\r\n########## Aborted........##########");
          sprintf(TP,"\r\nAbrt-SockID=%d",Socket);
         fnDebugMsg(TP);
        }
    case TCP_EVENT_CLOSED:
      if(ucEvent==TCP_EVENT_CONNECTED)
      {   
         fnDebugMsg("\r\n########## CLOSED........##########");
         sprintf(TP,"\r\nClose-SockID=%d",Socket);
         fnDebugMsg(TP);
      }
       
      fnTCP_Listen(Socket, usTestPort, 0);                    // go back to listening state on next port number
        break;
    }
    return APP_ACCEPT;
}   


9
NXPTM LPC2XXX and LPC17XX / Re: My customized hardware
« on: September 25, 2009, 01:02:02 PM »
Thanks mark, Actually there was mismatch of fast and slow port. done well with fast ports.



10
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
working.

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
uTasker.


-Thanks
Saurabh   


 














Pages: [1]