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.
I am trying to pass a message from one task to another and when I call os_mbx_send I am getting a HardFault_Handler error. The call stack has a lot of HAL_CM3 calls. Any ideas? Seems pretty straight forward. Also, I followed instructions on setting up a mailbox.
#define MBOX_SIZE 60
typedef struct { void *pMsg; } Object_Message;
os_mbx_declare(MBox, MBOX_SIZE); /* Declare an RTX mailbox */ _declare_box (MBox_Pool, sizeof(Object_Message), MBOX_SIZE);/* Dynamic memory pool */
__task void init_task (void) { // Init mail box(s) _init_box(MBox_Pool, sizeof(MBox_Pool), sizeof(Object_Message)); /* the membox dynamic allocation */ os_mbx_init(MBox, sizeof(MBox));
//... start tasks
Comm_Mgr_Task_ID = os_tsk_create(comm_manager_task, 4); os_tsk_delete_self (); /* STOP init task (no longer needed)*/ }
/********************************************************************* comm_manager_task *********************************************************************/ __task void comm_manager_task(void) { Object_Message *pNewMsg;
while(1) { pNewMsg = (Object_Message *)_alloc_box(MBox_Pool); /* Allocate a memory for the message */ pNewMsg->pMsg = new uint8[256]; sprintf((char *)pNewMsg->pMsg, "blah"); os_mbx_send(pNewMsg, MBox, TASK_WAIT_FOREVER); <== HardFault_Handler here os_dly_wait(SYS_MSEC_TO_TICKS(1000)); } }
/********************************************************************* main *********************************************************************/ int main(void) { SystemInit(); ADC_init(); /* ADC Initialization */
// Do display intialization Comm_Manager.pTrain_Display->APP_DISP_init();
os_sys_init(init_task); /* init and start with task 'INIT' */ }