HardFault with cmsis Ethernet library
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-10-11 10:45 AM
Posted on October 11, 2016 at 19:45
and it shows me the error line
and here is my fault report
why my bus makes fault? and what is my mistake?
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).
This discussion is locked. Please start a new topic to ask your question.
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-10-11 11:18 AM
Posted on October 11, 2016 at 20:18
This is not where the fault is actually occurring, you need to dig deeper and look at the registers and the assembler code immediately around the code that faults. before/after. Don't rely on the tool-chain to point to decode the stacked fault context, or understand the generated code.
Do you have an adequate stack for your local/auto allocations, call tree, and interruptions? Implement a proper Hard Fault Handler, and review the dozens of threads covering this class of failures. Observe also that sprintf() returns the length of the string it is creating.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Up vote any posts that you find helpful, it shows what's working..
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-10-11 12:07 PM
Posted on October 11, 2016 at 21:07
Thanks clive1
I'm going to correct again and I will tell you as soon as possible Thank you zillion