/var/www/restricted/ssh/stm32/www/stm32circle/ STM CircleOS forum / How to put a function in a custom handler?

Username:     
Password:     
             

Forum
  • Index
  •  » circleOS
  •  » How to put a function in a custom handler?

# 1   2013-10-31 03:51:20 How to put a function in a custom handler?

beckywen
New member
Registered: 2013-09-26
Posts: 9

How to put a function in a custom handler?

I'm try building a usart program.

I copied the example code "Simple-USART-Example-0.8" ,it works fine when testing on computer,with human typing input.
But when directly connect to another board,it lost some charter,only display 1st char of a sentence.
I think it's because:
The Tx board is sending data continuously(much faster than human type).
When our RX board sense 1 char,program go to store and display data,this process may take 1ms
But Tx board is still sending data with in this 1ms,when pointer is  storing data and displaying,so following Tx data is missed.

Solve:
1.decrease storing time,increasing application handler_frequency,store data in a fast time before next tx data come.
or
2.put the storing data function in other handler,which is called very frequent.

1 is  not good,when change system freq usart baud rate will get kind of mass up.
so if any one know how to put a function in a custom handler,
sort of this format:

custom handler()
{
   USART_GetStringBuffer();
}

what is the format and where to put it?
or I got totally wrong?
Im using open4stm32f107 and circleos-4.61.
thanks in advance.

Offline

 

# 2   2013-10-31 04:02:01 How to put a function in a custom handler?

beckywen
New member
Registered: 2013-09-26
Posts: 9

Re: How to put a function in a custom handler?

My baud rate is 115200,the Tx board works fine with computer,too.

Offline

 

# 3   2013-10-31 06:53:06 How to put a function in a custom handler?

yrt
Administrator
From: Grenoble-France
Registered: 2008-06-11
Posts: 520
Website

Re: How to put a function in a custom handler?

You can add your own handler into the handler table of the CircleOS.
Add your custom_handler function name at the end of "SchHandler" table, and add the corresponding divider you need the at the end of the "SchHandlerDivider" table, in scheduler.c source file.
Then your handler will be periodically called by the scheduler (managed during Systick_handler).

Offline

 

# 4   2013-11-01 03:55:09 How to put a function in a custom handler?

beckywen
New member
Registered: 2013-09-26
Posts: 9

Re: How to put a function in a custom handler?

I've changed my mind, make usart priority higher should solve this problem,still trying...

Offline

 

# 5   2013-11-07 03:30:43 How to put a function in a custom handler?

beckywen
New member
Registered: 2013-09-26
Posts: 9

Re: How to put a function in a custom handler?

if I put a while(1) inside application_handler,the usart2 will totally receive nothing,as USART_IRQhandler weaker than application_handler.
I notice the setting of usart2 priority is following code:

    NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);
 
    NVIC_InitTypeDef NVIC_InitStructure;
    NVIC_InitStructure.NVIC_IRQChannel = MyUSART_IRQn;
    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority  = 0;
    NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
    NVIC_Init(&NVIC_InitStructure);

lower the number,higher the priority.A link describes it:http://micromouseusa.com/?p=279
I've tune it a bit, if it's too high,it'll freeze the os.
Too low, can not fight against application_handler.
So any one know how to set it just higher than application_handler and won't freeze the system.
the detailed value of
NVIC_PriorityGroup,
NVIC_IRQChannelPreemptionPriority,
NVIC_InitStructure.NVIC_IRQChannelSubPriority
is how much?thanks in advance

Offline

 

  • Index
  •  » circleOS
  •  » How to put a function in a custom handler?

Board footer