This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

RL-ARM control got stucked in

I am trying to interface RS232,CAN and Ethernet to ARM7 using RL-ARM Library. I am using MCB2300 Evaluation Board for this. I am referring EasyWeb example program for interfacing Ethernet. First I interfaced RS232 and CAN using RL-ARM to ARM7. It worked perfectly. Then I tried to interface Ethernet along with that. Here the problem rises. Below is the overall program in which I interfaced all the three serial communication drivers. Only Ethernet task is running. Control is not moving to other tasks. I tried by changing priority of all tasks. I didn't get the expected result.

#include <RTL.h>
#include <LPC23xx.h>
#include "RTX_CAN.h"
#include "LCD.h"
#include <stdio.h>
#include "Net_Config.h"
#include <stdlib.h>
#include <string.h>
#define extern

__task void task_init     (void);
__task void task_send_CAN (void);
__task void task_rece_CAN (void);
__task void task_disp     (void);
__task void task_srec     (void); //serial send
__task void task_ssend    (void); //serial receive
__task void task_ethernet (void);

U32 Tx_val = 0, Rx_val = 0;

char hex_chars[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};

typedef struct {
   U32 v;
} mboxx;

os_mbx_declare (MsgBox,4);
_declare_box (mpool,sizeof(mboxx),16);



__task void task_init (void)  {
  os_tsk_create (task_srec, 1);
  os_tsk_create (task_ssend, 1);
  os_tsk_create (task_send_CAN, 1);
  os_tsk_create (task_rece_CAN, 1);
  os_tsk_create (task_disp    , 1);
  os_tsk_create (task_ethernet, 1);
  os_tsk_delete_self();
}


__task void task_disp (void)  {
  for (;;)  {
    Out_Val ();
    os_dly_wait (10);
  }
}


__task void task_srec (void)  {
    mboxx *rptr;
  for (;;) {
    os_mbx_wait (MsgBox, (void **)&rptr, 0xffff);
    printf ("\nAD Value:%d\n",rptr->v);
    _free_box (mpool, rptr);
  }
}

__task void task_ssend (void)
{
  mboxx *mptr;
  os_mbx_init (MsgBox, sizeof(MsgBox));
  os_dly_wait (5);
  mptr = _alloc_box (mpool);
  for(;;)
  {
  mptr->v=0x05;
  os_mbx_send (MsgBox, mptr, 0xffff);
  IOSET1 = 0x10000;
  os_dly_wait (100);
  }
}

__task void task_ethernet (void)
{
  TCPLowLevelInit();
  HTTPStatus = 0;
  TCPLocalPort = TCP_PORT_HTTP;
  for(;;)
  {
   if (!(SocketStatus & SOCK_ACTIVE)) TCPPassiveOpen();
   DoNetworkStuff();
   os_tsk_prio_self(5);

  }
}

int main (void)  {
  serial_init ();
  In_Init  ();
  Out_Init ();

  _init_box (mpool, sizeof(mpool),sizeof(mboxx));
  os_sys_init (task_init);

}


void HTTPServer(void)
  {
           if (SocketStatus & SOCK_CONNECTED)
             {
                  if (SocketStatus & SOCK_DATA_AVAILABLE)
                           TCPReleaseRxBuffer();
                  if (SocketStatus & SOCK_TX_BUF_RELEASED)
                   {
                       if (!(HTTPStatus & HTTP_SEND_PAGE))
                        {
                            HTTPBytesToSend = sizeof(WebSide) - 1;
                            PWebSide = (unsigned char *)WebSide;
                        }
                       if (HTTPBytesToSend > MAX_TCP_TX_DATA_SIZE)
                        {
                          if (!(HTTPStatus & HTTP_SEND_PAGE))
                           {
                              memcpy(TCP_TX_BUF, GetResponse, sizeof(GetResponse) - 1);
                              memcpy(TCP_TX_BUF + sizeof(GetResponse) - 1, PWebSide, MAX_TCP_TX_DATA_SIZE - sizeof(GetResponse) + 1);
                              HTTPBytesToSend -= MAX_TCP_TX_DATA_SIZE - sizeof(GetResponse) + 1;
                              PWebSide += MAX_TCP_TX_DATA_SIZE - sizeof(GetResponse) + 1;
                           }
                          else
                           {
                              memcpy(TCP_TX_BUF, PWebSide, MAX_TCP_TX_DATA_SIZE);
                              HTTPBytesToSend -= MAX_TCP_TX_DATA_SIZE;
                              PWebSide += MAX_TCP_TX_DATA_SIZE;
                           }
                           TCPTxDataCount = MAX_TCP_TX_DATA_SIZE;
                           InsertDynamicValues();
                           TCPTransmitTxBuffer();}
                         else if (HTTPBytesToSend)
                         {
                           memcpy(TCP_TX_BUF, PWebSide, HTTPBytesToSend);
                           TCPTxDataCount = HTTPBytesToSend;
                           InsertDynamicValues();
                           TCPTransmitTxBuffer();
                           TCPClose();
                           HTTPBytesToSend = 0;
                         }
                         HTTPStatus |= HTTP_SEND_PAGE;
                   }
              }
              else
               HTTPStatus &= ~HTTP_SEND_PAGE;
   }

 void InsertDynamicValues(void)
  {
    unsigned char *Key;
    char NewKey[5];
    unsigned int i;
    unsigned int vv,vv1;
    if (TCPTxDataCount < 4) return;
    Key = TCP_TX_BUF;
    for (i = 0; i < (TCPTxDataCount - 3); i++)
     {
       if (*Key == 'A')
         if (*(Key + 1) == 'D')
           if (*(Key + 3) == '%')
              switch (*(Key + 2))
                {
                  case '7' :
                  {
                     vv=In_Get();
                     sprintf(NewKey, "%3u", vv);
                     memcpy(Key, NewKey, 3);
                     break;
                  }
                  case 'A' :
                  {
                         vv1=In_Get();
                         sprintf(NewKey, "%3u", vv1);
                         memcpy(Key, NewKey, 3);
                         break;
                  }
                }
       Key++;
      }
  }

Actually I am new to RTOS. I don't know where I am making mistake. Anybody please point out the mistake I made.
Note: I removed some functions and two tasks(CAN send and CAN receive). Those are working good.

Parents
  • If the tasks have different priorities, then the most prioritized thread will get all CPU time, unless it contains any function call where it hands over time to other tasks. So the code needs to contain some form of wait. Maybe wait a fixed amount of time, or wait until a signal is raised or similar.

    How do you let your ethernet task share CPU capacity with the other threads?

Reply
  • If the tasks have different priorities, then the most prioritized thread will get all CPU time, unless it contains any function call where it hands over time to other tasks. So the code needs to contain some form of wait. Maybe wait a fixed amount of time, or wait until a signal is raised or similar.

    How do you let your ethernet task share CPU capacity with the other threads?

Children
No data