How To Extend the Memory Space if program exceed 64K, using the M9S12NE64?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How To Extend the Memory Space if program exceed 64K, using the M9S12NE64?

8,280 Views
Malaysia
Contributor I
Hi,
 
  Currently I'm testing and learnign using the M9S12NE64 MCU and with the EVB9S12NE64. I've study how to use the function on the MCU since last time I'm using PIC18F. Currently, I want to learn how to used the Ethernet function built inside the MCU. So, I've to step by step to try the demo program download from the FreeScale Website.
 
  I've add the LCD function into the proram and compile it. But when I add the another function which to show the IP address, as highligted below, then the compiler show the bellowing error:"Out of allocation space in segment ROM_PAGE3D at address 0x3DBFD2" , So what could be the reason of  this error? Will it be when I added the extran LCD function, then the program exceed 64K? I'm using EVB9S12NE64 to learn how to use the MCU, can this board extend the size of the Flash instead of 64K?
 
 
 
void main(void)
{
 INT16 len;
 
 char Buff[32];
 
/*
*        Step 1: Intialize CRG, SCI, EMAC, and EPHY
*  Main Loop: Process Recieved Packets
*        
*       
* NOTE.- THIS EXAMPLE IS BUILD WITH THE FOLLOWING CONFIGURATIONS (see ne64config.h)*
*
*  WORD_ACCESS    1 - use word access
*  ZERO_COPY      1 - use zero copy  
*  RX_POLL_MODE   0 - use buffer interrupts
*/
 /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
 PE_low_level_init();
 /*** End of Processor Expert internal initialization.                    ***/
 /* IP address */
 localmachine.localip = *((UINT32 *)ip_address);
 /* Default gateway */
 localmachine.defgw   = *((UINT32 *)ip_gateway);
 /* Subnet mask */
 localmachine.netmask = *((UINT32 *)ip_netmask);
 /* Ethernet (MAC) address */
 localmachine.localHW[0] = hard_addr[0];
 localmachine.localHW[1] = hard_addr[1];
 localmachine.localHW[2] = hard_addr[2];
 localmachine.localHW[3] = hard_addr[3];
 localmachine.localHW[4] = hard_addr[4];
 localmachine.localHW[5] = hard_addr[5];
 /* Init system services  */   
 timer_pool_init();  
 /* Initialize all buffer descriptors */
 mBufInit ();
 /*interrupts can be enabled AFTER timer pool has been initialized */
  /* Initialize all network layers */
 EtherInit();
  __asm CLI;     /* Enable Interrupts */
 #if USE_EXTBUS
     ExternalBusCfg();
 #endif    
 arp_init();
 (void)udp_init();
 (void)tcp_init();
  /* Initialize applications */   
 (void)https_init ();
 // THIS FUNCTION IS NOT NEEDED FOR EXAMPLE 2 smtpc_init ();
 (void)udp_demo_init();

 /* Add user application init code here */
 MyAppInit();
 
 LCDInit();
 
 for (;:smileywink:  /* do forever */
 {       
#if USE_SWLED
   UseSWLedRun();
#endif
  if (gotlink) {
    LCDPuts_Line1(" Ethernet Was Connected ");
    1- sprintf(Buff,"IP = %d",ip_address);  //When Add this two line the compiler show's error...
     2- LCDPuts_Line2(Buff);  
   //LCDPuts_Line2("Please Proceed The Work!");
  
- if not add two function above, the compiler won't show error...
    
     /* Try to receive Ethernet Frame */     
    if( NETWORK_CHECK_IF_RECEIVED() == TRUE ) 
   {      
      switch( received_frame.protocol)
    {             
      case PROTOCOL_ARP:
      process_arp (&received_frame);
         break;
      case PROTOCOL_IP:
       len = process_ip_in(&received_frame);
      if(len < 0)  break;
                 switch (received_ip_packet.protocol)
      {
          case IP_ICMP:
           process_icmp_in (&received_ip_packet, len);
         break;
          case IP_UDP:
                 process_udp_in (&received_ip_packet,len);          
                 break;
         case IP_TCP:
           process_tcp_in (&received_ip_packet, len);    
           break;
          default:
         break;
       }
           break;
    default:
       break;
    }
    /* discard received frame */      
     NETWORK_RECEIVE_END();
   }
   /* Application main loops */
    /* manage arp cache tables */
    arp_manage();    
    /* TCP/IP stack Periodic tasks here... */
     (void)udp_demo_run();
   
   /* manage opened TCP connections (retransmissions, timeouts,...)*/
   tcp_poll();
   https_run ();
   // comment out this function for Example 2 smtpc_run();
  }  // if (gotlink)
   else
   {
       /* Link is DOWN - Add user application code here */
       MyAppNotLinked();
       
       LCDPuts_Line1("Ethernet Was Not Connect");
       LCDPuts_Line2("CAT 5 Cable Not Connect!");

   }   /* if (gotlink) */
 } /* Forever loop */
 
 
 
  In the current world, we would used up many of the Ethernet function in the design application, and currently I'm finding any software that can capture and sending the data to and from the devices, like we can do in the RS232 of sending and reciving the data from the devices. So, can I know where can I get this software? I've found out one which the name is "Ethereal", but it just can capture and cannot sending the data to control the devices. Thanks.
 
 
Regards
 
kahjoo
 
Message Edited by t.dowe on 2009-10-21 12:45 AM
Labels (1)
0 Kudos
7 Replies

802 Views
imajeff
Contributor III
Looks to me like the problem is to have sprintf automatically translate a single variable (4 bytes wide) to the format like "192.168.16.10"

It would be great if sprintf had a new type for that, like "%q":

sprintf(Buff,"IP = %q",ip_address);

But I don't know of one. How about define the format for printf, something like:

sprintf(Buff,"IP = %u.%u.%u.%u",
(unsigned)(ip_address/0x1000000),
(unsigned)(ip_address/0x10000) & 0xff,
(unsigned)(ip_address & 0xff) );
0 Kudos

802 Views
CrasyCat
Specialist III

Hello

I opened teh project you send over in CodeWarrior for HC12 V4.5 and I could build,it without any problem.

I did not get any error message.

I made sure the lines

   sprintf(Buff,"IP = %d",ip_address);
    LCDPuts_Line2(Buff);
   LCDPuts_Line2("Please Proceed The Work!");  

are uncommented. Am I missing something?

 

CrasyCat

0 Kudos

802 Views
Malaysia
Contributor I

Hi,

    Thanks for your reply. First things is for currently, I'm usign Codewarrior v3.1, so may be in your version it can be compile. By the way, this is not the problem. For the pass few days, I'm trying for include the LCD display at output for when select the LED bar in the webpage, then the LED will light up on the board and as well the LCD will display which LED are lighten up. This can be done with no error. However, I've try to reduce the code in the "main loop", then the LCD command that you've possed will be function.

   I've disable some pervious function that I've posted in the forum, and found out the IP value that shows in LCD are not same as defined. The value shows is, when in Hex is F233, and when I want to change to Dec value "change to %d", then the value is -3533. What can I do to display the actual value of the IP address? Did the program that I've modified have any mistake? Below are the program been modified:-

void main(void)
{
//main() variable list
 INT16 len;
 
 char Buff[32];

/*
*        Step 1: Intialize CRG, SCI, EMAC, and EPHY
*  Main Loop: Process Recieved Packets
*        
*       
* NOTE.- THIS EXAMPLE IS BUILD WITH THE FOLLOWING CONFIGURATIONS (see ne64config.h)*
*
*  WORD_ACCESS    1 - use word access
*  ZERO_COPY      1 - use zero copy  
*  RX_POLL_MODE   0 - use buffer interrupts
*/
 /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
 PE_low_level_init();
 /*** End of Processor Expert internal initialization.                    ***/

 Indication(TRUE);
 
 // Set our network information. This is for static configuration.
 /* IP address */
 localmachine.localip = *((UINT32 *)ip_address);
 /* Default gateway */
 localmachine.defgw   = *((UINT32 *)ip_gateway);
 /* Subnet mask */
 localmachine.netmask = *((UINT32 *)ip_netmask);
 /* Ethernet (MAC) address */
 localmachine.localHW[0] = hard_addr[0];
 localmachine.localHW[1] = hard_addr[1];
 localmachine.localHW[2] = hard_addr[2];
 localmachine.localHW[3] = hard_addr[3];
 localmachine.localHW[4] = hard_addr[4];
 localmachine.localHW[5] = hard_addr[5];
 /* Init system services  */   
 
 timer_pool_init();  
 /* Initialize all buffer descriptors */
 mBufInit ();
 /*interrupts can be enabled AFTER timer pool has been initialized */
  /* Initialize all network layers */
 EtherInit();
  __asm CLI;     /* Enable Interrupts */
 #if USE_EXTBUS
     ExternalBusCfg();
 #endif    
 arp_init();
   
 (void)udp_init();
 (void)tcp_init();
  /* Initialize applications */   
 (void)https_init ();
 // THIS FUNCTION IS NOT NEEDED FOR EXAMPLE 2 smtpc_init ();
 (void)udp_demo_init();
 //REMOVE FOR EXAMPLE 2 // RTI_Enable ();
 //RTI1_Init();
 /* Add user application init code here */
 MyAppInit();
 
 LCDInit();
 
  
 for (;:smileywink:  /* do forever */
 {       

#if USE_SWLED
   UseSWLedRun();
#endif
  if (gotlink) {
    LCDPuts_Line1(" Ethernet Was Connected ");
    sprintf(Buff,"IP = %X",hard_addr);
    LCDPuts_Line2(Buff);
      }  // if (gotlink)

   else
   {

       /* Link is DOWN - Add user application code here */
       MyAppNotLinked();
       
       LCDPuts_Line1("Ethernet Was Not Connect");
       //LCDPuts_Line2("CAT 5 Cable Not Connect!");


   }   /* if (gotlink) */

 } /* Forever loop */

 for(;:smileywink:{}

}

    May I know how this function are connected in the demo program:- "INT32 udp_demo_eventlistener()" link to and link from? This function can be found in udpinterface.c. And also can you also tell me this function "void porth_isr_handler(void)" link to and link from?

    However, do you have any method for testing the connection of TCP/IP where we can capture the data sedning from the MCU and also we can send the data to from PC to MCU. In this way we can control the MCU through sending the command data from PC through Internet to MCU like those application in RS-232?

   How actually to getting more understand how's the data flow and also the connection of the TCP/IP? This may help when writting the firmware in MCU.

Regards

kahjoo

0 Kudos

802 Views
CrasyCat
Specialist III

Hello

Well did I understand well that the only remaining problem is that the PC is written as a signed int and you want to get it printed differently?

If you want to get it printed as an unsigned int you have to use the modifies %u in sprintf.

If you want to print it as an hexadecimal value, use modified %X.

Now How are you retrieving the value of thy IP?

Which is its format when you get it?

CrasyCat

0 Kudos

802 Views
Alban
Senior Contributor II

Hi Cath and Malaysia,

I quickly read through the post and might say something completely stupid.
Still, as I want to say it, I jump:

Isn't it possible that because you call the function "fprintf" an additional library is compiled and this ends up being too big ?

I wonder coz I had a similar problem when I tried with floats on HC08. I know... not very clever... We all have our moments :smileyvery-happy:

Cheers,
Alban.

0 Kudos

802 Views
CrasyCat
Specialist III

Hello

Actually the message Out of allocation space in segment ROM_PAGE3D at address 0x3DBFD2 indicates that the code is too big and cannot be allocated on page 3D anymore.

In order to be able to build the application, you need to provide more space to store the code.
If you are building in BANKED memory model, you can just modify your .PRM file as follows:

Write    
   
MyConstSegPage1, DEFAULT_ROM     INTO  ROM_PAGE3C, ROAM_PAGE3D;
instead of 
   MyConstSegPage1   INTO  ROAM_PAGE3C;
   DEFAULT_ROM                   INTO  ROAM_PAGE3D;

This may help a little bit.

I am not sure though if you have enough memory available on page 3C.

Then which are the errors shown by the compiler when you add the sprintf?

Did you include stdio.h at the begining of the C source file to get a proper prototype there?

CrasyCat

0 Kudos

802 Views
Malaysia
Contributor I
Hi CrasyCat,
 
   Thanks for your reply. I've try to used your method, but the compiler shows error. I've attached the PRM file of the project, so that you can have a look with it. From your questions, I've include the stdio.h in begining of the C code, and this function was be able been used in my previous testing.
 
   The compiler getting the error when I want to used this two lines:-
    1- sprintf(Buff,"IP = %d",ip_address);  //When Add this two line the compiler show's error...
     2-
LCDPuts_Line2(Buff);  
 
    The actual program can be read from the original of my posting. I've also attached the full project file in my previous posting. The project file I've attached are download from the FreeScale website in the MC9S12NE64 directory. Currently I've tried to learn the TCP/IP from the existing example.
 
    Besides, can you also tell me "INT32 udp_demo_eventlistener()" link to and link from? This function can be found in udpinterface.c. And also can you also tell me this function "void porth_isr_handler(void)" link to and link from? I already find for few days and could not find from where the program link to the above function. Curently, I can understand the basically how's the hole program function are, and just want to know from where the above function link from, so that I can modified from there. Thanks for your information.
 
Regards
 
kahjoo

0 Kudos