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.

RTOS/TMDSICE3359: Adding code to EtherCAT project

Part Number: TMDSICE3359
Other Parts Discussed in Thread: AM3359

Tool/software: TI-RTOS

Hello,

I have been successful in setting up an ethercat slave full as weel as demo example from the material provided by TI. I have even tested these modules.

I am having problems with the following two things :

1) Whevener I try to add some simple piece of code like LED blinking to the Ethercat slave demo or full example, it does not debug properly. It gives us errors. How should we modify the code and what should we not touch?

2) Secondly, I want to write a PWM code to generate a few PWM signals on receiving command from the Ethercat master which is on my personal computer. I have not been able to find helpful documentation about hardware aspcts ( which port and pin to configure for PWM) and also software example or help for it ( how to write it, the APIs or also example codes about how to integrate it in the PRU ICSS stack).

Our project is seriously getting delayed because of this and we need urgent help. Can anybody please look into this matter and guide us exhaustively. I have previously tried asking for help for this but have not received enough support as I should have. Our project is seriously getting delayed and our management isconsidering migrating to other platforms.

  • The RTOS team have been notified. They will respond here.
  • Hi Keyshav,

    1) Which EtherCAT release are you working with? Can you please elaborate which error you are observing? And how does your code change look like? You may take a look at the following structure and function:

    GPIO_PinConfig gpioPinConfigs[] and void Board_setTriColorLED() in board_gpioLed.c.

    2) The pinmux tool (www.ti.com/.../PINMUXTOOL) and schematic of the AM3359 ICE v2 board (www.ti.com/.../tidr336) should help you identify which port and pin to configure for PWM. The board's default pinmux config file is in ${PDK_INSTALL_DIR}\packages\ti\starterware\tools\pinmux_config\am335x.

    To be synchronized with EtherCAT network, the PWM EPWM_SYNCIN pin need connect to EtherCAT SYNC0 signal.

    The PWM signal generation example is available from ${PDK_INSTALL_DIR}\packages\ti\board\diag\pwm

    Regards,
    Garrett
  • Hi Garrett,

    Thank you for your reply. I will share the tiesutils.c which I have modified. Is this the right place to modify? I modified it ( just added a few lines of code) because it contains the main function.

    The link for the schematic you have shared is giving me an error.

    I have been through the diag PWM example. It asks for port numbers and other details which needs to be passed to the function. I am not sure how to fill in this information.

    In order to sync the EtherCAT signal with the PWM, you suggest connecting it to the PWM pins. Can you please elaborate how this can be achieved ?

    The following are the changes I made in tiesutils.c :

    TaskP_Params_init(&taskParams);
    taskParams.priority = 8;
    taskParams.stacksize = 1152;
    taskParams.arg0 = (void *)pruIcss1Handle;
    sync0Task = TaskP_create(Sync0task, &taskParams);

    TaskP_Params_init(&taskParams);
    taskParams.priority = 8;
    taskParams.stacksize = 1152;
    taskParams.arg0 = (void *)pruIcss1Handle;
    sync1Task = TaskP_create(Sync1task, &taskParams);

    TaskP_Params_init(&taskParams);
    taskParams.priority = 4;
    taskParams.stacksize = 1512;
    ledTaskHndl = TaskP_create(LEDtask, &taskParams); 

    TaskP_Params_init(&taskParams);
    taskParams.priority = 9;
    taskParams.stacksize = 1512;
    gpioTask = TaskP_create(GPIOtask, &taskParams); // added by me 

    within task1 function I have added this :

    TaskP_Params_init(&taskParams);
    taskParams.priority = 9;
    taskParams.stacksize = 1512;
    gpioTask = TaskP_create(GPIOtask, &taskParams);

    the GPIOtask function looks like this 

    void GPIOtask(uint32_t arg0, uint32_t arg1)
    {

    uint32_t testOutput = 1;

    //GPIO initialization
    GPIO_init();

    // Set the callback function
    // GPIO_setCallback(USER_LED0, AppGpioCallbackFxn);
    // AppGpioCallbackFxn();

    // Enable GPIO interrupt on the specific gpio pin
    // GPIO_enableInt(USER_LED1);

    // Write high to gpio pin to control LED1
    GPIO_write((USER_LED0), GPIO_PIN_VAL_HIGH);
    GPIO_write((USER_LED1), GPIO_PIN_VAL_HIGH);
    // AppDelay(DELAY_VALUE);

    while(1)
    {

    gpioBaseAddr = GPIO_BASE_ADDR;
    gpioPin = GPIO_LED_PIN;

    // Trigger interrupt
    // GPIOTriggerPinInt(gpioBaseAddr, 0, gpioPin);


    GPIO_toggle(USER_LED0);

    // AppDelay(DELAY_VALUE);
    // if (testOutput)
    // {
    // UART_printStatus("\n All tests have passed \n");
    // testOutput = 0;
    // }


    GPIO_toggle(USER_LED0);
    // Osal_delay(200 * OS_TICKS_IN_MILLI_SEC );
    GPIO_write((USER_LED0), GPIO_PIN_VAL_LOW);
    // Osal_delay(200 * OS_TICKS_IN_MILLI_SEC );
    GPIO_write((USER_LED0), GPIO_PIN_VAL_HIGH);
    // Osal_delay(200 * OS_TICKS_IN_MILLI_SEC );
    GPIO_write((USER_LED0), GPIO_PIN_VAL_LOW);
    // Osal_delay(200 * OS_TICKS_IN_MILLI_SEC );
    GPIO_write((USER_LED0), GPIO_PIN_VAL_HIGH);
    // Osal_delay(200 * OS_TICKS_IN_MILLI_SEC );
    GPIO_write((USER_LED0), GPIO_PIN_VAL_LOW);
    }


    }

    within these functions, I have added my changes and added the corresponding sub task under the main task1 in tiesutils.c file. Is there something wrong from my side ? Is there something else I should toch not touch? How important are the xml files in this? Should I be adding the pins I want to use for blinking LED or PWM in the xml file? Is there some other file which is causing this problem?

    If possible, a step by step description of things to modify the EtherCAT code could be helpful. A similar code in pure RTOS program on the ICEAM3359v2 board works perfectly.

    Regards,

    Keyshav

  • Keyshav,

    Setting the GPIO task to the highest priority (9) and with a while(1) loop will prevent all other tasks running. Also GPIO_init() is called in bsp_soc_evm_init() so you should not re-initialize GPIO. Why do you not put the LED toggling function in LEDtask()?

    The pins for blinking LED should be in GPIO_PinConfig gpioPinConfigs[] and void Board_setTriColorLED() in board_gpioLed.c. It's unrelated to xml file. For details about xml file, please refer to the ESC implementation guide - www.ethercat.org/.../ETG2200_V2i0i0_SlaveImplementationGuide.pdf

    The schematic file is available from www.ti.com/.../tidr336

    For pwm generation, were you looking into pwm_test.c in C:\ti\pdk_am335x_1_0_9\packages\ti\board\diag\pwm\src? The comment in the beginning of the file may help.

    For EPWM_SYNCIN, please look into the Figure 15-9. ePWM Submodules and Critical Internal Signal Interconnects, and Table 15-12. Key Time-Base Signals: EPWMxSYNCI Time-base synchronization input - Input pulse used to synchronize the time-base counter with the counter of ePWM module earlier in the synchronization chain. An ePWM peripheral can be configured to use or ignore this signal. For example, this signal could come from a device pin for the first ePWM module (ePWM0). For subsequent ePWM modules this signal could be passed from another ePWM peripheral, such that EPWM1SYNCI is generated by the ePWM0
    peripheral, EPWM2SYNCI is generated by ePWM1, and so forth. See Section 15.1.2 for information on the
    synchronization order of a particular device.

    Regards,
    Garrett
  • Hello Garrett,

    If you notice even the LEDTask has a while(1) loop and so do other tasks like the sync0, syn1, and the PDI task. So I am not sure how my implementation is faulty. Could you elaborate more ion this particular point?

    Is my approach of adding a task to the main etherCat task right or should there be a different approach? What should be the priority of the task I add as it is a peripheral task? Does the priority system followed by TI prefer 0 as the highest or the highest number as highest prority value?

    I found the schematic file, thanks for that. That helped us modify the pinMux configuration. If the wiki page has to be believed I must rebuild the pdk in order to include the changes in the project.

    I would get baack more on the question related to pwm and ehrpwm so please don't close this thread. I ams sure this helps others as well.

    Regards,
    Keyshav
  • Keyshav,

    The other tasks either have TaskP_sleep() or PRUICSS_pruWaitEvent() which will put its task to sleep and wait for a semaphore post.

    The highest number is as the highest priority for a task. 0 is for idle which is the lowest.

    You can add a new task for peripherals but need schedule its priority carefully. The Ethercat Sync0/1 and PDI should have higher priority than others.

    You may open a new thread specific for pwm and ehrpwm so can get more attention from the experts on that.

    Regards,
    Garrett
  • Hi Garrett,

    Can I use the PRUICSS_WaitEvent in the tasks I inserted?

    What are the other files which I can/I need to modify in order to get a new functionality without affecting the functionality of the code? is tiesutils.c the only file I can or I need to modify in the EcAT stack?

    Secondly, I added the ECAT and ePWM module in the pinmux and generated 4 fles. . the h and the c files must be replaced in starterware and the pdk must be rebuilt. would these changes also appear if I recereate the ecat example projects?

    I will start the pwm thread on a separate topic once I have some of my basics cleared.
  • Keyshav,

    PRUICSS_WaitEvent internally is to pend a semaphore, if you are able to post the required semaphore, yes you can use it. The PDI, SYNC tasks have the semaphores posted from its interrupt handler PRUICSS_hwiIntHandler(). You may just add TaskP_sleep() and lower the task priority to simplify the GPIO toggling.

    Demo_Application() in tiescappl.c is another function you may interest in if you need implement your own application.

    Yes the pinmux related file changes in starterware will be reflected in ecat example project after pdk and the example project are re-built.

    Regards,
    Garrett