Hi all,
I am using RL-ARM with MCB1700. I hav 10 tasks running with priorities 2 to 11. I am using file system with SD Memory.
But when I run the code it is getting stuck in the forever loop of _mutex_initialize (OS_ID *mutex) function found in RTX_lib.c as shown below.
int _mutex_initialize (OS_ID *mutex) { /* Allocate and initialize a system mutex. */ if (nr_mutex >= OS_MUTEXCNT) { /* If you are here, you need to increase the number OS_MUTEXCNT. */ for (;;); } *mutex = &std_libmutex[nr_mutex++]; mutex_init (*mutex); return (1); }
It is asked to increase the number OS_MUTEXCNT. But Iam not finding where OS_MUTEXCNT is defined.
Please suggest.
Withe thanks and Regards Lingaraju
Look in RTX_Config.c
Why did you use a thread summary about your program getting stuck in a forever loop, when your real question is where OS_MUTEXCNT is defined?
Thanks for the reply..
I have increased the OS_MUTEX_CNT to 12. Now it is not going to that forever loop.
But is going to the Hard Fault Handler.
I have debugged the location from where it is going to hard fault handler.
Inside the init_task I am crating all the tasks.
When I am creating the third task it is going to the hard fault handler.
Increased the stack size and heap size also. nothing helped.
The address and status are as given below:
The fault report shows that, it is an Bus Fault escalated to Hard Fault, Bus Fault Addess: 0xE000EDF8 Bus Fault Status: 0x04 (Impreciserr error) Hard Fault Status: 0x40000000 (Forced error
The stack used is MSP. MSP = 0x10004578 When checked the contents of the stack is seen to chaeck the PC, PC = 0x0000B368
The disaasebly code is as given below.
rt_init_stack: 0x0000B338 B530 PUSH {r4-r5,lr} 0x0000B33A 8C42 LDRH r2,[r0,#0x22] 0x0000B33C 0892 LSRS r2,r2,#2 0x0000B33E D103 BNE 0x0000B348 0x0000B340 4A10 LDR r2,[pc,#64] ; @0x0000B384 0x0000B342 6812 LDR r2,[r2,#0x00] 0x0000B344 F3C2028D UBFX r2,r2,#2,#14 0x0000B348 6A83 LDR r3,[r0,#0x28] 0x0000B34A EB030282 ADD r2,r3,r2,LSL #2 0x0000B34E 0753 LSLS r3,r2,#29 0x0000B350 D500 BPL 0x0000B354 0x0000B352 1F12 SUBS r2,r2,#4 0x0000B354 1F14 SUBS r4,r2,#4 0x0000B356 F04F7580 MOV r5,#0x1000000 0x0000B35A 6025 STR r5,[r4,#0x00] 0x0000B35C F1A20340 SUB r3,r2,#0x40 0x0000B360 F8421C08 STR r1,[r2,#-0x08] 0x0000B364 2200 MOVS r2,#0x00 0x0000B366 4614 MOV r4,r2 0x0000B368 F8434022 STR r4,[r3,r2,LSL #2] 0x0000B36C 1C52 ADDS r2,r2,#1 0x0000B36E 2A0E CMP r2,#0x0E 0x0000B370 D3FA BCC 0x0000B368
Please suggest. How can I solve this problem.
So how many tasks etc are you creating? And how many have you configured for? And how have you planned your stack/heap/... resources in relation to what your program needs?
You give us quite little information to work on.
Sorry for joining late.
As I have already discussed I have 10 tasks each with different priority.
The tasks which are using more stack are created using user stack option with seperate declared for each task.
Before I get into this I am facing problems with interrupt. What the code optimization levels do with the interrupts.
I have configured and enabled for EINT0, Timer1 and USB interrupts. For USB I am using the RTX_HID code. All other peripherals I hav initialised before I call the os_sys_init(). Whatevr the optimization level selected,The USB interrupt is not working unless I call the NVIC_enalbe_irq(USB_IRq) before I call the os_sys_init(). In this way it is working but going to hard fault with Bus fault escalation from rt_get_first function.
when optimization levels 1 or 2 is selected, The Timer1 interrupt is not working. The interrupt is coming. The control is not coming out of the IRQ handler. But with levels 0 and 3 Timer1 interrupt works properly
regards Lingaraju
There is very less timr for the deadline.Please suggest.