AnsweredAssumed Answered

HardFault with cmsis Ethernet library

Question asked by mohamadi.parisa on Oct 11, 2016
Latest reply on Oct 11, 2016 by mohamadi.parisa
Hello
I send and receive data from Ethernet with cmsis library

I send my data with send function each 100ms(with each timer interrupt)

void send(void){
    unsigned char i;
    unsigned long int checksum;
    char msg[200];
 
     
            if(tcp_check_send(socket))
            {       
checksum=data1+data2+data3+data4+data5+data6+data7+data8+data9+data10;
 
                 
sprintf(msg,"%06ld%06ld%06ld%06ld%06ld%06ld%06ld%06ld%02hhd%02hhd\n\r",data1,data2,data3,data4,data5,data6,data7,data8,data9,data10,checksum);
             
                    for(i=0;i<200;i++)
                    {
                        if(msg[i]=='\0')
                        {
                        break;
                        }
                    }
                 
        sendbuf = tcp_get_buf (i);
        memcpy (sendbuf, msg, i);
        tcp_send (socket, sendbuf,i);   
        memset(msg, '\0', sizeof(msg));                   
 
}



and receive data with call back function

uint32_t tcp_callback (int32_t soc, tcpEvent event, const uint8_t *buf, uint32_t len){
 
  switch (event) {
    case tcpEventConnect:return (1);
    case tcpEventAbort:tcp_close(socket);break;
    case tcpEventEstablished:break;
    case tcpEventClosed:break;
    case tcpEventACK:break;
    case tcpEventData:
        flag=1;
        memset(&pcstr[0], '\0', sizeof(pcstr));
        memcpy (pcstr,buf, len);
        break;
  }
  return (0);
     
}

and here is my main settings

int main (void)
{
    net_initialize();
 
    socket = tcp_get_socket (TCP_TYPE_SERVER | TCP_TYPE_KEEP_ALIVE, 0, 10,tcp_callback);
    if(socket!=0){
    tcp_listen (socket, 5000);
    }
        while (1)
        {       
            //somecode
        }
}



my code works fine and send and receive data and unfortunately it hangs after for several seconds.As I debug my MCU I see that  net_initialize() make it hangs(but I call it only once).
5.PNG
and it shows me the error line
6.PNG
and here is my fault report
4.PNG

why my bus makes fault? and what is my mistake?

Outcomes