infineon4engineers Facebook

infineon@google+ Google+

infineon@linkedin linkedin

infineon4engi@twitter twitter

infineon@youtube youtube

+ Reply to Thread
Page 4 of 4 FirstFirst 1 2 3 4
Results 31 to 35 of 35

Thread: Aurix 2G Free Entry Tool Chain Interrupt on all cores

  1. #31
    New Member New Member Praktikant is on a distinguished road
    Join Date
    Jun 2018
    Posts
    17
    Points
    200
    Quote Originally Posted by HIGHTEC.henk-piet.glas View Post
    Hi,

    Based on the sample code that you listed earlier I would say no. The typedef for spinlock doesn't provide the compiler with sufficient information to know that its state may be changed by threads other than the current one. Therefore variables of type spinlock will be subject to compiler optimisations. For regular variables this is precisely what you want because it will have a positive effect on codesize and speed. For semaphores the story is a different one. Those must be explicitly written to and read from such as you code it. The way to do this is by adding the volatile keyword to your type definition. So rather than using 'typedef int spinlock' you will have to use 'typedef volatile int spinlock'.

    Another advise I want to give you is to drop STM1_Handler() from your lock() function definition. To me it makes no sense to repeatedly call it while waiting to acquire the lock. The lock() function must only be used to acquire the semaphore. Once it is in your possession you become the sole owner of the resource that you're sharing. And only at that point you call the resource. Combining both remarks, this is the preferred approach:

    Code:
       typedef volatile unsigned SEM_t;
       
       SEM_t sem;
       
       inline void P(SEM_t * const s) {
         while ( __builtin_tricore_cmpswapw(s,1,0) != 0 );
       }
    
       inline void V(SEM_t * const s) {
         *s = 0;
       }
       
       /* code snippet demonstrating use
       */
       
       P(&sem);
       STM1_Handler();
       V(&sem);
    [FONT

    [/FONT]
    Hi Glas,

    Your detailed explanation helped a lot. It is working perfectly.

    Thank you very much.

    best regards
    Prakt

  2. #32
    Advanced Advanced HIGHTEC.henk-piet.glas is on a distinguished road
    Join Date
    May 2017
    Posts
    49
    Points
    862.5
    Hi Praktikant,

    Quote Originally Posted by Praktikant View Post
    Your detailed explanation helped a lot. It is working perfectly.
    Good to hear. Am I right this means you solved the scratchpad ram posting of yours?

    Best regards,

    Henk-Piet Glas
    Principal Technical Specialist

  3. #33
    New Member New Member Praktikant is on a distinguished road
    Join Date
    Jun 2018
    Posts
    17
    Points
    200
    Quote Originally Posted by HIGHTEC.henk-piet.glas View Post



    Am I right this means you solved the scratchpad ram posting of yours?

    Hi Glas,

    Yes the scratchpad ram issue is resolved.

    Thank you

    Best regards
    Prakti

  4. #34
    Advanced Advanced HIGHTEC.henk-piet.glas is on a distinguished road
    Join Date
    May 2017
    Posts
    49
    Points
    862.5
    Quote Originally Posted by Praktikant View Post
    Yes the scratchpad ram issue is resolved.
    Brilliant. Happy developing and good luck with your project.

    Henk-Piet Glas
    Principal Technical Specialist

  5. #35
    New Member New Member Praktikant is on a distinguished road
    Join Date
    Jun 2018
    Posts
    17
    Points
    200
    Quote Originally Posted by HIGHTEC.henk-piet.glas View Post
    Brilliant. Happy developing and good luck with your project.
    Thank you very much for all the help.

    with best regards
    Prakti

+ Reply to Thread
Disclaimer

All content and materials on this site are provided “as is“. Infineon makes no warranties or representations with regard to this content and these materials of any kind, whether express or implied, including without limitation, warranties or representations of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. No license, whether express or implied, is granted by Infineon. Use of the information on this site may require a license from a third party, or a license from Infineon.


Infineon accepts no liability for the content and materials on this site being accurate, complete or up- to-date or for the contents of external links. Infineon distances itself expressly from the contents of the linked pages, over the structure of which Infineon has no control.


Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Usage Terms of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Usage Terms of this site. Infineon reserves the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.