MQX _time_get_hwticks_per_tick() and _time_get_ticks_per_sec()

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MQX _time_get_hwticks_per_tick() and _time_get_ticks_per_sec()

Jump to solution
3,360 Views
rainer77
Contributor III

Hello

I have a problem when i use:

_time_get_hwticks_per_tick()

and directly after the function:

_time_get_ticks_per_sec()

MQX doesn't start anymore. It works well, when i omit one of the two functions. Which one is equal.

The debugger then never reaches the main task when i call both functions.

I had tried with _time_delay() between these two functions, but without any success.

I hope somone has an answer. Thanks

My configuration is:

MQX 4.2   

VYBRID VF61

IAR 7.6

Here is my minimal project file:

#include <mqx.h>

#include <bsp.h>

#include <Mutex.h>

//---------------------------------------------------------------------------------------

// Task IDs

#define MAIN_TASK   1

#define MAIN_IDLE  10

#define RS485_TASK  4

extern void Main_task(unsigned int);

extern void RS_485Task(unsigned int);

//---------------------------------------------------------------------------------------

void MyIdleTask(unsigned int temp)

//---------------------------------------------------------------------------------------

{

   while (1)

   {

      _time_delay(100);

   }

}

//---------------------------------------------------------------------------------------

const TASK_TEMPLATE_STRUCT  MQX_template_list[] =

{

   /* Task Index,   Function,      Stack,  Priority,   Name,   Attributes,          Param, Time Slice */

    { MAIN_IDLE,    MyIdleTask,     500,    13,         "MyIdle",    MQX_AUTO_START_TASK, 0,   0 },

    { MAIN_TASK,    Main_task,     5000,    10,         "main",      MQX_AUTO_START_TASK, 0,   0 },

    { RS485_TASK,   RS_485Task,    5000,     3,         "RS-485",    MQX_AUTO_START_TASK, 0,   0 },

    { 0 }

};

#define TICK_MS  (50)  // Tickintervall in ms

//---------------------------------------------------------------------------------------

void Main_task(unsigned int initial_data)

//---------------------------------------------------------------------------------------

{

   static MQX_TICK_STRUCT  tick_time_m;

   MQX_TICK_STRUCT_PTR ptr = &tick_time_m;

   uint32_t  ttt= _time_get_hwticks_per_tick();

   /*_time_delay(3000);*/

   _mqx_uint tt = _time_get_ticks_per_sec();

   /*_time_delay(3000);*/

   while(1)

   {

      _time_delay(100);

      _time_add_msec_to_ticks(ptr, 50); 

      _time_delay_until(ptr);     

   }

}

//--------------------------------------------------------------------------------------

//---------------------------------------------------------------------------------------

void RS_485Task(unsigned int temp)

//---------------------------------------------------------------------------------------

{

   while(1)

   {

      _time_delay(100);

   }

}

Labels (2)
Tags (1)
1 Solution
2,550 Views
Carlos_Musich
NXP Employee
NXP Employee

Hi Rainer,

each toolchain, specifically each linker has its own structure and syntax, but in general the linker is the one that decides where each part of the code is located in physical memory, and the linker file provides to the linker the information about memory size and its logical division. Documentation should be different for each linker and linker file

I wrote the following document explaining how Linker file works in CW with GCC toolchain for Kinetis devices.

Relocating Code and Data Using the CW GCC Linker File for Kinetis

There is another document from a colleague explaining Linker in KDS

Relocating Code and Data Using the KDS GCC Linker File for Kinetis

Here I found something related to IAR linker

IAR How do I place a group of functions or variables in a specific section?

In general, in the linker file is defined each memory region and what code/data will be placed there.

In the first document you will see that the vectors are saved in a reserved space at address 0x0. Then all code which is referenced as .text and initialized variables which are referenced and .data.

I am not familiar with IAR linker file, but in your above snippet I can notice that the vectors are referenced in different ways. Tests and investigation are required to find where the references come from.

Take a look to the documents above and if you have any question about the documents above please let me know.


Regads,
Carlos

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

0 Kudos
22 Replies
2,412 Views
karina_valencia
NXP Apps Support
NXP Apps Support

Carlos_Musich​ can you continue with the follow up?

0 Kudos
2,413 Views
Carlos_Musich
NXP Employee
NXP Employee

Hi Rainer,

can you share snapshots of the Task Aware Debugger (TAD) Task Summary window?

Regards,

Carlos

0 Kudos
2,413 Views
Carlos_Musich
NXP Employee
NXP Employee

Hi Rainer,

I noticed that one of your tasks have priority 3. Please note that priorities 0 -7 are reserved for MQX internal usage. If user set a task to any of these priorities may impact MQX behavior. What I recommend is to set all your tasks priorities above 8. With the attached code a had no problems.


Regads,
Carlos

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
2,412 Views
rainer77
Contributor III

User_config.h is:

/*HEADER**********************************************************************

*

* Copyright 2008-2013 Freescale Semiconductor, Inc.

*

* This software is owned or controlled by Freescale Semiconductor.

* Use of this software is governed by the Freescale MQX RTOS License

* distributed with this Material.

* See the MQX_RTOS_LICENSE file distributed for more details.

*

* Brief License Summary:

* This software is provided in source form for you to use free of charge,

* but it is not open source software. You are allowed to use this software

* but you cannot redistribute it or derivative works of it in source form.

* The software may be used only in connection with a product containing

* a Freescale microprocessor, microcontroller, or digital signal processor.

* See license agreement file for full license terms including other

* restrictions.

*****************************************************************************

*

* Comments:

*

*   User configuration for MQX components

*

*

*END************************************************************************/

#ifndef __user_config_h__

#define __user_config_h__

/* mandatory CPU identification */

#define MQX_CPU                 PSP_CPU_VF65GS10_A5

/* MGCT: <generated_code> */

#define BSPCFG_HAS_SRAM_POOL                      1

#define BSPCFG_ENET_SRAM_BUF                      1

#define BSPCFG_ENABLE_IO_SUBSYSTEM                1

#define BSPCFG_ENABLE_I2C0                        0

#define BSPCFG_ENABLE_II2C0                       0

#define BSPCFG_ENABLE_I2C1                        0

#define BSPCFG_ENABLE_II2C1                       0

#define BSPCFG_ENABLE_I2C2                        0

#define BSPCFG_ENABLE_II2C2                       0

#define BSPCFG_ENABLE_I2C3                        0

#define BSPCFG_ENABLE_II2C3                       0

#define BSPCFG_ENABLE_SPI0                        0

#define BSPCFG_ENABLE_SPI1                        0

#define BSPCFG_ENABLE_SPI2                        0

#define BSPCFG_ENABLE_QUADSPI0                    1

#define BSPCFG_ENABLE_RTCDEV                      0

#define BSPCFG_ENABLE_PCFLASH                     0

#define BSPCFG_ENABLE_NANDFLASH                   0

#define BSPCFG_ENABLE_FLASHX_QUADSPI0             0

#define BSPCFG_ENABLE_ESDHC                       1

#define BSPCFG_ENABLE_IODEBUG                     0

#define BSPCFG_ENABLE_SAI                         0

#define BSPCFG_ENABLE_USB                         1

#define BSPCFG_ENABLE_CLKTREE_MGMT                0

#define BSPCFG_ENABLE_TTYA                        0

#define BSPCFG_ENABLE_ITTYA                       0

#define BSPCFG_ENABLE_TTYB                        0

#define BSPCFG_ENABLE_ITTYB                       0

#define BSPCFG_ENABLE_TTYC                        0

#define BSPCFG_ENABLE_ITTYC                       0

#define BSPCFG_ENABLE_TTYD                        0

#define BSPCFG_ENABLE_ITTYD                       0

#define BSPCFG_ENABLE_TTYE                        0

#define BSPCFG_ENABLE_ITTYE                       0

#define BSPCFG_ENABLE_TTYF                        0

#define BSPCFG_ENABLE_ITTYF                       0

#define BSP_DEFAULT_MAX_MSGPOOLS                  4

#define MQX_HAS_TIME_SLICE                        1

#define MQX_USE_IDLE_TASK                         1

#define MQX_ENABLE_LOW_POWER                      0

#define MQX_USE_MEM                               1

#define MQX_USE_UNCACHED_MEM                      1

#define MQX_SPARSE_ISR_TABLE                      0

#define MQX_TASK_DESTRUCTION                      1

#define MQXCFG_ENABLE_FP                          1

#define MQX_INCLUDE_FLOATING_POINT_IO             1

#define MQX_IS_MULTI_PROCESSOR                    1

#define MQX_USE_IPC                               1

#define MQXCFG_MEM_COPY                           1

/* DS-5 memcpy is bugged so we have to use MQX implementation */

#define MQXCFG_MEM_COPY_NEON                      1

#define MQX_USE_MEM_ZERO                          1

#define FTPDCFG_USES_MFS                          1

#define TELNETDCFG_NOWAIT                         FALSE

/* MGCT: </generated_code> */

#define ENETCFG_SUPPORT_PTP             0

/*

** include common settings

*/

//------------------------------------------------

//FIT overwrite default settings:

#define MQX_USE_SEMAPHORES                  1

#define MQX_KERNEL_LOGGING                  1

#define MQX_EXTRA_TASK_STACK_ENABLE         0

#define MQX_USE_TIMER                       1

#define MQX_USE_SW_WATCHDOGS                1

#define BSPCFG_ENABLE_DCU4                  0

//------------------------------------------------

/* use the rest of defaults from small-RAM-device profile */

#include "small_ram_config.h"

/* and enable verification checks in kernel */

#include "verif_enabled_config.h"

#endif /* __user_config_h__ */

0 Kudos
2,412 Views
Carlos_Musich
NXP Employee
NXP Employee

Hi rainer,

sorry for my delay. Did you used the files I sent?

I tested with different targets as I don't have now VYBRID VF61 now but I am getting one to run tests. Please note with other targets the files I sent worked without problems. I made some simple modifications.

I will let you know my tests findings.

Regards,

Carlos

2,412 Views
rainer77
Contributor III

Hi Carlos

Thanks for Answering. Yes, first I tried it with Priority above 8. The result was the same fault, the whole system is hanging.

Then I used your file with the same effect, the system never reach any task.

Regards,

Rainer

0 Kudos
2,412 Views
Carlos_Musich
NXP Employee
NXP Employee

Hi Rainer,

is MQX running in M4 or A5 core?

0 Kudos
2,413 Views
rainer77
Contributor III

Hi Carlos

MQX is running on the A5 Core...

0 Kudos
2,413 Views
Carlos_Musich
NXP Employee
NXP Employee

Hi Rainer,

I ran tests with TWR-VF65GS10 board loading the code attached in previous post on A5 core. Everything worked fine.

My configuration is:

MQX 4.2 with all patches

TWR-VF65GS10 Rev H (VYBRID VF61)

IAR 7.7

My user_config.h file is attached for your reference.

Please take a look and let me know  any difference in or configurations.


Regards,
Carlos

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
2,413 Views
rainer77
Contributor III

Hi carlos

Thank you for answering.

At a first glance, i see some differnce:

First section without RTCS, that you did defined and me not:

Your config +:

#define BSPCFG_ENABLE_ASRC                   1
#define BSPCFG_ENABLE_ESAI_TX0               1
#define BSPCFG_ENABLE_ESAI_RX0               1
#define BSP_DEFAULT_IO_CHANNEL         "ttyc:"

#define BSP_DEFAULT_IO_CHANNEL_DEFINED

#define BSPCFG_ENABLE_IO_EXPANDER_MAX7310    1
#define BSPCFG_ENABLE_FTM1_QD                1
#define BSPCFG_ENABLE_FTM2_QD                1

Secound section without RTCS, that we have definded and it lacks in your user_config.h:

#define MQX_KERNEL_LOGGING              1
#define MQX_EXTRA_TASK_STACK_ENABLE     0
#define MQX_USE_TIMER                   1
#define MQX_USE_SW_WATCHDOGS            1
#define BSPCFG_ENABLE_DCU4              0
#define BSPCFG_ENABLE_NANDFLASH               0

And the last section is different to your user_config.h (values are taken from my user_config.h):

#define MQX_INCLUDE_FLOATING_POINT_IO         1
#define BSPCFG_ENABLE_TTYC                    0
#define BSPCFG_ENABLE_CLKTREE_MGMT            0
#define BSPCFG_ENABLE_SAI                     0
#define BSPCFG_ENABLE_SPI0                    0
#define BSPCFG_ENABLE_I2C3                    0
#define BSPCFG_ENABLE_I2C1                    0
#define BSPCFG_ENABLE_I2C0                    0
0 Kudos
2,413 Views
Carlos_Musich
NXP Employee
NXP Employee

Sorry for the delay Rainer,

The differences you see are not important in this matter. Have you made any other modification in BSP or PSP? Please note that I have a brand new MQX installation with all patches. So, if you have modified your installation and you are to sure what the changes are I think the easiest and faster way to solve it is to reinstall MQX, rather that tracking any change.

Regads,
Carlos

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
2,412 Views
rainer77
Contributor III

Hi Carlos

Thank you for replying. I tryed with newest patch, but sadly without succes.

Release of MQX is running well, but the debug version blocks like it is described above.Screen.png

Here is a screen-shot by mentioned unhandled interrupt 0x0041. I have also attached the files from our MQX, that are changed.

0 Kudos
2,413 Views
Carlos_Musich
NXP Employee
NXP Employee

Hi Rainer,

did you reinstalled MQX?

Carlos

0 Kudos
2,413 Views
rainer77
Contributor III

Forget to mention, that i have still the same problem...

0 Kudos
2,413 Views
Carlos_Musich
NXP Employee
NXP Employee

Hi Rainer,

In general there are 4 points that can be the problem.

- Source code

- Project Settings

- MQX settings

- Hardware

I don't think hardware is the problem. So, please open the following example and replace the code with the main.c file that I attached previously. C:\Freescale\Freescale_MQX_4_2\mqx\examples\hello\build\iar\hello_svf522revb_a5

If the problem persits please try the same in a different computer with a new MQX installation.

0 Kudos
2,410 Views
rainer77
Contributor III

Hi carlos

I have changed the linker config file, because i see that one in the example is not same than mine.

changing the rows:

define block VECTOR_TBL with alignment = 32 { section .vector_tbl };

place in ROM_region { first block head { section STARTUP }, readonly, block VECTOR_TBL };

place in RAM_region { readwrite, block SYS_STACK, block FIQ_STACK, block UND_STACK, block ABT_STACK, last block KERNEL_DATA };

to:

define block VECTOR_ROM with alignment = 32 { section vector_rom }; //mod

define block VECTOR_RAM with alignment = 32 { section vector_ram }; //new

place in ROM_region { first block head { section STARTUP }, readonly, block VECTOR_ROM };//mod

place in RAM_region { block VECTOR_RAM, readwrite, block SYS_STACK, block FIQ_STACK, block UND_STACK, block ABT_STACK, last block KERNEL_DATA };//mod

Now the application seemt to be working, MQX braking at main function. But i'm not sure, what i have done.

Can you tell me, where i can read more about the linker config file or what these sections mean...

Thanks al lot

Rainer

0 Kudos
2,551 Views
Carlos_Musich
NXP Employee
NXP Employee

Hi Rainer,

each toolchain, specifically each linker has its own structure and syntax, but in general the linker is the one that decides where each part of the code is located in physical memory, and the linker file provides to the linker the information about memory size and its logical division. Documentation should be different for each linker and linker file

I wrote the following document explaining how Linker file works in CW with GCC toolchain for Kinetis devices.

Relocating Code and Data Using the CW GCC Linker File for Kinetis

There is another document from a colleague explaining Linker in KDS

Relocating Code and Data Using the KDS GCC Linker File for Kinetis

Here I found something related to IAR linker

IAR How do I place a group of functions or variables in a specific section?

In general, in the linker file is defined each memory region and what code/data will be placed there.

In the first document you will see that the vectors are saved in a reserved space at address 0x0. Then all code which is referenced as .text and initialized variables which are referenced and .data.

I am not familiar with IAR linker file, but in your above snippet I can notice that the vectors are referenced in different ways. Tests and investigation are required to find where the references come from.

Take a look to the documents above and if you have any question about the documents above please let me know.


Regads,
Carlos

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
2,409 Views
rainer77
Contributor III

Hi Carlos

Thank you very much.

I think we can close the ticket...

best Regards

Rainer

0 Kudos
2,413 Views
rainer77
Contributor III

Hi Carlos

I used the source from the patch, which means i change the source files to my project, where i only use

bsp and psp. Then i builded MQX new (bsp and psp). I saw, there is no changing for Vybrid processors in

bsp...

My testapplication is about 500 MB with MQX. Should i attach this in a Zip folder?

0 Kudos
2,413 Views
rainer77
Contributor III

Hi Carlos

Sorry, i have still the same problem. The whole application don't start, no task is running after start.

So it could be, that MQX is't proper configured?

Regards,

Rainer

0 Kudos