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.

How to blink a LED with SYSBIOS and Hwi

Hi everyone!

I just bought a Tiva C launchpad and i intend to use it with TI-RTOS.

I've started from an empty project and i'm trying to run the blink example using a hwi but  it is not working.

CODE:

/*
 * Copyright (c) 2013, Texas Instruments Incorporated
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * *  Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * *  Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * *  Neither the name of Texas Instruments Incorporated nor the names of
 *    its contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

/*
 *  ======== empty.c ========
 */
/* XDCtools Header files */
#include <xdc/std.h>
#include <xdc/cfg/global.h>
#include <xdc/runtime/System.h>

/* BIOS Header files */
#include <ti/sysbios/BIOS.h>

#define RED_LED   GPIO_PIN_1
#define BLUE_LED  GPIO_PIN_2
#define GREEN_LED GPIO_PIN_3

#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_types.h"
#include "inc/hw_memmap.h"
#include "driverlib/sysctl.h"
#include "driverlib/timer.h"
/* TI-RTOS Header files */
// #include <ti/drivers/GPIO.h>
// #include <ti/drivers/SPI.h>
// #include <ti/drivers/UART.h>
// #include <ti/drivers/Watchdog.h>
// #include <ti/drivers/WiFi.h>

/* Example/Board Header files */
#include "Board.h"

/*
 *  ======== main ========
 */
void isrBlink(void)
{
    GPIOPinWrite(GPIO_PORTF_BASE, RED_LED|BLUE_LED|GREEN_LED, RED_LED);
}
Int main(Void)
{
    /* Call board init functions */
    Board_initGeneral();

    System_printf("Starting the example\nSystem provider is set to SysMin. "
                  "Halt the target and use ROV to view output.\n");
    /* SysMin will only print to the console when you call flush or exit */
    System_flush();
    //config GPIO
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);

    GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, RED_LED|BLUE_LED|GREEN_LED);


    TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC);
    TimerLoadSet(TIMER0_BASE, TIMER_A, SysCtlClockGet());
    TimerEnable(TIMER0_BASE, TIMER_A);
/*    GPIOPinWrite(GPIO_PORTF_BASE, RED_LED, 0xff);
    //
    // Delay for a bit
    //
    SysCtlDelay(20000000);

    //
    // Turn on the LED
    //
    GPIOPinWrite(GPIO_PORTF_BASE, BLUE_LED, 0xff);

    //
    // Delay for a bit
    //
    SysCtlDelay(20000000);
    //
    // Turn on the LED
    //
    GPIOPinWrite(GPIO_PORTF_BASE, GREEN_LED, 0xff);*/
    /* Start BIOS */
    GPIOPinWrite(GPIO_PORTF_BASE, RED_LED|BLUE_LED|GREEN_LED, GREEN_LED);
    BIOS_start();

    return (0);
}
1256.empty.cfg 

Thanks

  • First observation:  In the isrBlink, you are not changing the value of what you write to the LED GPIO.  You initialize in the main routine with the Green LED, and then in the isrBlink, you turn off the Green LED and enable the Red LED. You will need to modify your code to toggle or alter the LED based on what your application needs for it to do.  Otherwise, there will be no visible indication that anything has happened.

    Second, in the config file, you are configuring the HWI with eventID 108 (which maps to Timer 5B ... eventID is Interrupt - 1).  But in the Hwi.create call, you are referencing interrupt number 25 (which is PWM0 fault).  These two values should match, but the important one is in Hwi.create.  Also, in your code, you are configuring Timer0A, so the value should be 35 in the function call, and 34 in the eventID (but you should not have to specify the eventID).

    Hope this helps.

    --Bobby