infineon4engi@twitter twitter

infineon4engineers Facebook

infineon@linkedin linkedin

infineon@youtube youtube


+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Beginner Beginner muratrazi is on a distinguished road
    Join Date
    Aug 2019
    Posts
    18
    Points
    185

    XMC 1100 H bridge kit 2 go delay function problem in DAVE

    Hello,

    I want to use delay function in dave to blink a led periodically. My code is below but I dont know why it not working.
    I think we have a problem with the initial configurations. Any help would be appreciated. This code below should toggle the led. But the led is always high.

    Kind regards,
    Ozkan.

    #include <DAVE.h>
    #define TIMER_DELAY_MUL_FACTOR 100000U // Converts micro seconds to milli seconds with multiplication factor for
    // TIMER_GetInterruptStatus().


    void TIMER_Delay(uint32_t);
    int main(void)
    {
    DAVE_STATUS_t init_status;
    TIMER_STATUS_t status;
    uint32_t delay_val; // delay value in terms milli seconds

    init_status = DAVE_Init(); // TIMER_Init(&TIMER_0) will be called from DAVE_Init()

    TIMER_ClearEvent(&TIMER_0);

    if(init_status == DAVE_STATUS_SUCCESS)
    {
    delay_val = 1000; // 1000 milli seconds

    TIMER_Delay(delay_val);
    }

    while(1)
    {
    TIMER_Delay(1000);
    DIGITAL_IO_ToggleOutput(&LED1);
    }
    return 1;
    }

    void TIMER_Delay(uint32_t delay_val)
    {
    uint32_t delay_cnt;

    delay_cnt = delay_val * TIMER_DELAY_MUL_FACTOR;

    TIMER_SetTimeInterval(&TIMER_0,delay_cnt);

    TIMER_Start(&TIMER_0);

    while(!TIMER_GetInterruptStatus(&TIMER_0));

    TIMER_Stop(&TIMER_0);
    }

  2. #2
    New Member New Member ozkntbk is on a distinguished road
    Join Date
    Sep 2019
    Posts
    1
    Points
    40

    Delay Function

    Greetings. If you use the code as I have edited, you can get the result you want. All you need to do after the while loop

    /*
    void Timetick_Handler(void)
    {
    TIMER_ClearEvent(&TIMER_0);
    }
    */

    will add the function and run the code.
    We can say that this function is a cleanup function that we use for each event we create.
    Note: You need to add the interrupt app and configure the signal with the timer.

    The following illustrations show how the configurations should be.
    Best regards.

    Click image for larger version

Name:	app_dependency.jpg
Views:	1
Size:	60.1 KB
ID:	4245 Click image for larger version

Name:	app_dependency_tree.jpg
Views:	0
Size:	32.1 KB
ID:	4246

    Click image for larger version

Name:	hw_signal.jpg
Views:	0
Size:	75.9 KB
ID:	4247 Click image for larger version

Name:	hwsignal.jpg
Views:	0
Size:	74.9 KB
ID:	4248

    Click image for larger version

Name:	interrupt_app.jpg
Views:	0
Size:	29.1 KB
ID:	4249 Click image for larger version

Name:	timer_app.jpg
Views:	0
Size:	15.6 KB
ID:	4250

    Click image for larger version

Name:	timer_signal.jpg
Views:	0
Size:	75.9 KB
ID:	4251 Click image for larger version

Name:	timerapp.jpg
Views:	0
Size:	24.4 KB
ID:	4252
    Last edited by ozkntbk; Oct 25th, 2019 at 02:07 AM.

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.