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.

CCS/TMS570LS1224: timer (het driver)

Expert 1660 points
Part Number: TMS570LS1224
Other Parts Discussed in Thread: HALCOGEN

Tool/software: Code Composer Studio

hello all i have a simple question i don't have oscilloscope to check the delay.

if anyone could help me i want to toggle the led port B bit1 with a delay of 37ms .

i am working with TMS570LS1224 development kit.

i enabled het1 driver , 

het driver configurations are as below:

1)pwm(0-7) :period is 10 us, Duty 50%

2)pwm interrupts : enable pwm 0 end of period interrupt low level

3)in VIM enable line 24 (HET LOW)

here is my project

4401.blink.rar

  • Hello B.M

    Are you using TI HDK or TI Launchpad? 

    LS1224 Lunchpad: GIOB1 and GIOB2 are used for 2 user LEDs. I will show you step by step the timer configuration and GIO pin toggling.

    1. Open HALCoGen, File->New->Project  We use "test" as the project name, and code is save to "c:\...\workplace_v10

    2. Configure driver code generation:   

    • Enable RTI driver
    • Enable GIO driver
    • Disable all others

    3. Configure the VIM to enable RTI timer compare 0 interrupt

    4. Configure RTI compare 0 period to 37ms

    5. Save project and generate code

    5. Open CCS, create a new CCS project to use the files generated by the HALCOGen the above configuration

        Use the same project name "test" as used in HALCOGen

    6. open sys_main.c in source folder, then add code to blinky the LED

  • /* Include Files */
    #include "sys_common.h"
    #include "system.h"
    /* USER CODE BEGIN (1) */
    #include "rti.h"
    #include "het.h"
    #include "gio.h"
    /* USER CODE END */
    /* USER CODE BEGIN (2) */
    /* USER CODE END */
    void main(void)
    {
    /* USER CODE BEGIN (3) */
    /* Initialize RTI driver */
    /* Set high end timer GIO port hetPort pin direction to all output */
    /* Enable RTI Compare 0 interrupt notification */
    /* Enable IRQ - Clear I flag in CPS register */
    /* Note: This is usually done by the OS or in an svc dispatcher */
    _enable_IRQ();
    /* Start RTI Counter Block 0 */
    /* Run forever */
    while(1);
    /* USER CODE END */
    }
    /* USER CODE BEGIN (4) */
    /* Note-You need to remove rtiNotification from notification.c to avoid redefinition */
    void rtiNotification(uint32 notification)
    {
    /* enter user code between the USER CODE BEGIN and USER CODE END. */
    /* Toggle GIOB[1] */
    gioSetPort(gioPORTBgioGetPort(gioPORTB) ^ 0x00000002);
    }
    /* USER CODE END */
  • Thanks that’s really help

    But i have a question  about the above code

    Which function call the 37ms

    Like in my code

    delay(37ms);

    Is there any mistake in my code?

    I know it’s more easier to use RTI time

    But also i wanna check my method of timer

  • Hello,

    Using RTI is the easiest way.

    In this configuration, the PLL=160MHz, the RTI clock 80MHz. 

    There are two counter blocks in RTI module: counter block 0 and counter block 1. The two counter blocks provide the same basic functionality. Step #4 shows that we use counter 0 for compare 0.

    Each counter block consists of 2 32-bit counters: up counter (RTIUC), and free running counter (RTIFRC). RTIUC counter is driven by RTI clock and counts up until the compare value in the compare up register (RTICPUC) is reached. When compare match (RTIUC = RTPCPUC), the free running register (RTIFRC) is incremented and RTIUC is reset to 0. So the frequency of the free running counter is: RTI clock freq divided by (RTICPUC+1). In this example code, the RTICPUC0=7, so the frequency of the free running counter is: 80/(7+1)=10 MHz.

    RTI module has 4 compare register to generate interrupt to VIM. When free running counter (RTIFRC) matches the value in compare register, an interrupt is generated. Since the frequency of FRC is 10MHz, to generate a interrupt for every 37ms, 370000 should be write to compare register (step #4 picture).

    So rtiNotification(uint32 notification) will be called very 37ms.

    Your method can also generate 37ms delay, but it is as accurate as the 1st RTI method. One modification should be added to pwm notification function:

    if (notification == pwmEND_OF_PERIOD)

       counter++;

  • i followed your steps in using rti but the led wasn't blinking

    3058.rti_blinking.rar

  • Hi,

    If you use TI HDK for your test, the code should work. The LED connected to NHET[0] shpuld blinky.

    If you use TI Launchpad for your test, please modify your code as:

    /* Set high end timer GIO port hetPort pin direction to all output */
    gioSetDirection(hetPORT1, 0xFFFFFFFF);        ---> gioSetDirection(gioPORTB, 0xFF);  

    void rtiNotification(uint32 notification)
    {
    /* enter user code between the USER CODE BEGIN and USER CODE END. */
    /* Toggle HET pin 0 */
       gioSetPort(hetPORT1, gioGetPort(hetPORT1) ^ 0x00000001);      ---> gioSetPort(gioPORTB, gioGetPort(gioPORTB) ^ 0x00000001)


    }

  • hello 

    i edited the code but still the leds are not blinking 

    here is my code project id you please could have a quick look

    4527.rti_blinking.rar

  • Hi B.M.

    Sorry, if you use TI launchpad for you test, in RTI ISR, please toggle GIOB[1] or GIOB[2] rather than GIOB[0]

    gioSetPort(gioPORTB, gioGetPort(gioPORTB) ^ 0x00000002)