We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
my problem is how to use malloc or free function in interrupt function,because the function like malloc() or free() is non_reentrant.But i have to do it in interrupt function to save memory. what shall i do? please help me! i use timer0 to free the memory when memeory is no applied,but after three times,the timero is closed auto. the warning is: multi call to a segment free() or malloc(); i describe my algorithm as below: 1)i make the data to link list firstly; 2)in timer0, i will write the node of the link list to CAN bus buffer, after it ,i will free the node.but the timer0 just work 3 times,when it gets the fourth ,the timer0 is closed auto, what shall i do?? regards!! thanks !!
See the following pseudo codes...
void *MyMalloc (size_t s) { void *p; DisableISR; p=malloc(s); EnableISR; retrun p; } void MyFree (void *p) { DisableISR; free(p); EnableISR; } int main (void) { p=MyMalloc(x);//malloc(). ... MyFree(p);//free(). } void ISRxx (void) { p=malloc(x); ... free(p); }
or look at the DISABLE pragma - see the Manual