Saturday, December 16th 2017, 7:27pm UTC+1

You are not logged in.

  • Login
  • Register

Dear visitor, welcome to SEGGER Forum. If this is your first visit here, please read the Help. It explains how this page works. You must be registered before you can use all the page's features. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

gaugan

Beginner

Date of registration: Sep 4th 2017

Posts: 8

Location: Bangalore

1

Wednesday, September 13th 2017, 11:39am

Code getting stuck in OS_InitKern_STD

Hi,

We're using embOS v4.22. I observed that sometimes ie 1-2/10 times the code gets stuck in OS_InitKern_STD; precisely in:
OS_Delay called after OS_InitKern_STD. The portion of the attachment behaves like a recursive code forever. Can you help me understanding why this happens?

My Main looks like this:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
void main(void)
{
	sysinit();

	OS_IncDI();				    	// Initially disable interrupts 
	OS_InitKern();					// Initialize OS  - Gets stuck here once in a while in OS_Delay
	OS_InitHW();					// Initialize Hardware for OS

	Start_main_task();

	while(1);
}


Regards,
Gautam
gaugan has attached the following image:
  • Capture.PNG

SEGGER - Til

Super Moderator

Date of registration: Nov 14th 2007

Posts: 261

2

Wednesday, September 13th 2017, 11:54am

Hi Gautam,

do you have an embOS license or are you working with an embOS trial version?
You can also contact our embOS support directly per email.
Please find the email address in the embOS manual in chapter "Support".

OS_InitKern() does not call OS_Delay() at all.
I don't see your call to OS_Delay() in your code snippet.

Please be aware OS_Delay() can only work after the hardware timer was initialized and interrupts are enabled.
This is usually done in OS_InitHW().
If you call OS_Delay() in main() after OS_InitHW() with disabled interrupts you will reach OS_Error(OS_ERR_INTERRUPT_DISABLED).
You should enable interrupts before using OS_Delay().
You could e.g. simply remove the OS_IncDI() at the beginning of main().

Does this solves your issue?

Best regards,
Til

gaugan

Beginner

Date of registration: Sep 4th 2017

Posts: 8

Location: Bangalore

3

Wednesday, September 13th 2017, 12:07pm

Hi Til,

Thanks for the quick reply. That's exactly what I'm testing, by removing : OS_IncDI();
I don't call the OS_Delay routine. It seems to be an internal call. Yes, ours is a full licensed copy - object code license and hence I was unable to dig deeper.

*Edit: Even after removing OS_IncDI(); the issue persists.

Regards,
Gautam

This post has been edited 1 times, last edit by "gaugan" (Sep 13th 2017, 12:13pm)


gaugan

Beginner

Date of registration: Sep 4th 2017

Posts: 8

Location: Bangalore

4

Wednesday, September 13th 2017, 12:50pm

I tried enabling interrupts at start OS_DecRI(); and even that didn't help. Anything else that I can try?

Edit: If I check the disassembler, here's the sequence

1. OS_TerminateError
2. OS_InitKern_STD
3. OS_Delay ------ The code gets stuck here seems like a while(1) loop
4. OS_SetTaskContextExtension
5. OS_WaitEventTimed

This post has been edited 3 times, last edit by "gaugan" (Sep 13th 2017, 12:58pm)


SEGGER - Til

Super Moderator

Date of registration: Nov 14th 2007

Posts: 261

5

Wednesday, September 13th 2017, 1:18pm

Hi Gautam,

I got your email, so we can continue the discussion there.

Best regards,
Til

gaugan

Beginner

Date of registration: Sep 4th 2017

Posts: 8

Location: Bangalore

6

Wednesday, September 13th 2017, 1:19pm

Perfect!