This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

_get_CPSR not defined in halcogen example.

Other Parts Discussed in Thread: HALCOGEN, TMS570LS3137

Hello,

I was trying to run the HalGoGen 3.0 example : example_freeRTOSBlinky using a RM48 HDK.

I've followed the screens on HalCoGen help. AJusted the Include and compiler settings on my IAR and I got the following error :

"Error[Li005]: no definition for "_get_CPSR" [referenced from C:\Hercules\IAR\HCG_FREERTOS_BLINKY\Debug\Obj\os_port.o] "

I've tried to do a workaround.

I've added this code to the os_portasm.asm

-----------------------

;Get CPSR register

       public vPortYield _get_CPSR

       

_get_CPSR

          mrs r1,cpsr

          bx lr

---------------------------

I also created a os_portasm.h and added the function stub:

#ifndef __OS_PORTASM__

#define __OS_PORTASM__

unsigned int _get_CPSR(void);

#endif

and included it on the os_port.c

There is any thing I'm missing ? is there some HalCoGen config that I've uset/not used that is messing up with the code.

Thanks,

Cristiano

/** @example example_freeRTOSBlinky.c*   This is an example which descibes the steps to create an example application which *   toggles the High End Timer (HET) pin 17 (LED in USB & HDK) based on the FreeRTOS timer tick of one second.**   @b Step @b 1:**   Create a new project.**   Navigate: -> File -> New -> Project**   @image html example_createProject.jpg "Figure: Create a new Project"**   @b Step @b 2:**   Configure driver code generation: *   - Enable GIO driver*   - Disable others**   Navigate: -> TMS570LS3137/RM48L950ZWT_FREERTOS -> Driver Enable**   @image html example_freeRTOSBlinky_enableDrivers_TMS570LS3x-RMx.jpg "Figure: Driver Configuration"**   @b Step @b 3:**   Configure Cortex-R4F IRQ handling: *   - Disable IRQ handling via VIC contoller*het*   Navigate: -> TMS570LS3137/RM48L950ZWT_FREERTOS -> Cortex-R4F**   @image html example_freeRTOSBlinky_cortexR4F.jpg "Figure: Cortex-R4F Configuration"**   @b Step @b 4:**   Configure Interrupt handling: *   - Enable SVC*   - Enter FreeRTOS SVC handler name 'vPortYieldProcessor'*   - Select IRQ dispatcher mode*   - Enter FreeRTOS IRQ handler name '_IsrStub'**   Navigate: -> TMS570LS3137/RM48L950ZWT_FREERTOS -> Interrupts**   @image html example_freeRTOSBlinky_interrupts.jpg "Figure: Interrupt Configuration"**   @b Step @b 5:**   Configure VIM RAM: *   - Enter FreeRTOS Timer Tick handler name 'vPreemptiveTick' at offset 0x0000000C**   Navigate: -> TMS570LS3137/RM48L950ZWT_FREERTOS -> VIM RAM**   @image html example_freeRTOSBlinky_VimRam.jpg "Figure: VIM RAM Configuration"**   @b Step @b 6:**   Configure Vectored Interrupt Module Channels: *   - Enable VIM Channel 2*   - Map VIM Channel 2 to IRQ**   Navigate: -> TMS570LS3137/RM48L950ZWT_FREERTOS -> VIM Channel 0-31**   @image html example_freeRTOSBlinky_vimChannelView.jpg "Figure: VIM Channel Configuration"**   @b Step @b 7:**   Configure OS timer tick to 1 ms: *   - Enter Tick Rate of 1000**   Navigate: -> OS -> General**   @image html example_freeRTOSBlinky_osGeneral.jpg "Figure: OS General Configuration"**   @b Step @b 8:**   Generate code**   Navigate: -> File -> Generate Code**   @image html example_freeRTOS_generateCode.jpg "Figure: Generate Code"**   @b Step @b 9:**   Copy source code below into your application.**   The example file example_freeRTOSBlinky.c can also be found in the examples folder: ../HALCoGen/examples**   @note HALCoGen generates an enpty main function in sys_main.c, *         please make sure that you link in the right main function or copy the source into the user code sections of this file.**/
/* Include common header file - types, definitions and function declarations for all drivers */#include "sys_common.h"
/* Include system header file - types, definitions and function declarations for system driver */#include "system.h"
/* Include FreeRTOS scheduler files */#include "FreeRTOS.h"#include "os_task.h"
/* Include HET header file - types, definitions and function declarations for system driver */#include "het.h"#include "esm.h"
/* Define Task Handles */xTaskHandle xTask1Handle;
/* Task1 */void vTask1(void *pvParameters){    for(;;)    {        /* Taggle HET[1] with timer tick */        gioSetBit(hetPORT1, 17, gioGetBit(hetPORT1, 17) ^ 1);        vTaskDelay(100);    }   }
/* ESM interrupt notification (Not used but must be provided) */void esmGroup1Notification(unsigned channel){}void esmGroup2Notification(unsigned channel){}
/* GIO interrupt notification (Not used but must be provided) */void gioNotification(int bit){    return;}

/* USER CODE END */

/** @fn void main(void)*   @brief Application main function*   @note This function is empty by default.**   This function is called after startup.*   The user can use this function to implement the application.*/
/* USER CODE BEGIN (2) *//* USER CODE END */
void main(void){/* USER CODE BEGIN (3) */        /* Set high end timer GIO port hetPort pin direction to all output */    gioSetDirection(hetPORT1, 0xFFFFFFFF);

    /* Create Task 1 */    if (xTaskCreate(vTask1, (const signed char *)"Task1", configMINIMAL_STACK_SIZE, NULL, 1, &xTask1Handle) != pdTRUE)    {        /* Task could not be created */        while(1);    }
    /* Start Scheduler */    vTaskStartScheduler();
    /* Run forever */    while(1);/* USER CODE END */}

/* USER CODE BEGIN (4) */
/* USER CODE END */
  • Hi

    You are correct the CCS compiler will replace the "_get_CPSR" with "mrs r1,cpsr" which IAR tool do not.
    I have passed this comments to the HALCoGen team and will get it fixed in the upcoming releases.

    You have done what ever necessary to make the FreeRTOS port work on IAR, you should be able to use it with the change you made.

    Best Regards
    Prathap

  • Hello Prathap,

    thanks for yout attention,

    Althrough doing that, the Linker didn´t finded the _get_CPSR asm function, so I´ve done a litle workaround inserting the asm code inside the .h and removing it from the .asm,

    so my os_portasm.h is :


    #ifndef __OS_PORTASM__
    #define __OS_PORTASM__

    unsigned int _get_CPSR(void)
    {
    asm("mrs r1,cpsr \n");
    }

    #endif
    
    
    this compiled, but its not working yet, the startup code runs, but when it calls _cmain(), it jumps ( after executing some asm ) in the 0x04 address and stays in loop. 
    I think it is something with the linker, but is unrelated with this topic.
    
    
    Thanks for your help,
    
    
    Cristiano W. Araújo
  • Hi Christiano

    The return should always be on register "R0". I think if you change R1 to R0 it should work.
    My IAR licenese expired so could not give you a sample code, give me a day or two I will get back with a sample code.

    Best Regards
    Prathap