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.

BIOS hwiParams Hwi.create

Other Parts Discussed in Thread: SYSBIOS, MSP430F5529

 Hi,

 

Where can I find details about the fields in hwiParams?

 c.f.:

 

var Hwi = xdc.useModule('ti.sysbios.hal.Hwi');

var hwiParams = new Hwi.Params;

hwiParams.arg = 5;

Program.global.hwi0 = Hwi.create(id, '&hwiFunc', hwiParams);

 In the SYS/BIOS User's guide, the fields are not described and sometimes they are set to 5 or 12.

Also, it is unclear if "id" should be set to the interrupt number (e.g. interrupt 54 on MSP430F5529 for the ADC12).

Also, is Program.global.hwi0= Hwi.create needed or only Hwi.create.  Some example show the use of Program.global.

Finally, thhe hwi0 name, can this be a random name?  In some example the name matches the interrupt number.

Thanks.

Hans.

 

  • Hans,

    There is an API reference in CCS. Look at Help->Help About->SYS/BIOS <version>->API Reference (or you can open <bios_installdir>\docs\cdoc\index.html).

    The arg parameter is passed to the Hwi function ("hwiFunc" in your example).

    The id is the interrupt number (intNum in the API Reference).

    Program.global is a way of "defining" a global variable for your application. The name is up to you. For example, you could access the hwi0 variable in your 'C' code. For example, if you wanted to change the Hwi function during runtime (and you had "#include <xdc/cfg/global.h>" in your source file), you could make the following call.

    Hwi_setFunc(hwi0, myNewHwiFxn, SOMEARG);

    Using the interrupt name in the global name can make the source code easier to read, but is totally up to you.

    Todd

  • Hi Todd,

    I found the API ref.  Thanks.

    In regards to the global.h, I'm trying to start a timer at runtime.  I'm using CCSV4 with the free license. 

    Can I start a timer at runtime without buying a CCSV5 license?

    Here is my code:

     

    var timerParams_debounce = new Timer.Params();

    //timerParams_debounce.startMode = Timer.StartMode_AUTO;

    //timerParams_debounce.runMode = Timer.RunMode_CONTINUOUS;

    timerParams_debounce.startMode = Timer.StartMode_USER;

    timerParams_debounce.runMode = Timer.RunMode_ONESHOT;

    /* Timer period is 1/4 second (250,000 uSeconds) */

    timerParams_debounce.period = 250000;

    timerParams_debounce.periodType = Timer.PeriodType_MICROSECS;

    //var Button_Debounce_Timer = Timer.create(1, '&Button_Debounce_Toggle', timerParams_debounce);

    Program.global.Button_Debounce_Timer = Timer.create(Timer.ANY,

    "&Button_Debounce_Toggle", timerParams_debounce);

     

    If I use the StartMode_AUTO and RunMode_CONTINUOUS, I get the Button_Debounce_Toggle to execute.  But I'd like to be able to start the timer when I want.

    If I use the StartMode_USER and RunMode_ONESHOT, I never land in the Button_Debounce_Toggle.

     

    I thought, maybe I need to include the global.h.  But then, I get the following error:

    Severity and Description Path Resource Location Creation Time Id
    could not open source file "(0x0001):/TI/workspace/Battery_Charger_SYSBIOS/Debug/configPkg/package/cfg/task_p430X.h" Battery_Charger_SYSBIOS .xdchelp line 39 1328200110541 5100

    The file exists and seems to be generated at compile time.

    Can I use the StartMode_AUTO and RunMode_CONTINUOUS?  If so, how do I get the Button_Debounce_Toggle to execute (or timer to start).

    Why am I getting the task_p430X.h error when using global.h?

     

    Thanks.

     

    Hans.

     

     

  • Hans,

    When you set the timer to be StartMode_USER, you need to call Timer_start() during the execution of your program. Are you doing this, and if you, where?

    Todd

  • I do use it:

     

    void Start_Button_Debounce_Timer(void)
       {
        Timer_start(Button_Debounce_Timer);   <------------------<<<<<<
       }  

     

    It is called when I receive an interrupt on button P1:

    void Hwi_Port1_ISR_Button(void)
       {
        //
        // Context save interrupt flag before calling interrupt vector.
        // Reading interrupt vector generator will automatically clear IFG flag
        //
        buttonsPressed = PAIFG & BUTTON_ALL;

        switch (__even_in_range(P1IV, P1IV_P1IFG7))
        {
            // Vector  P1IV_NONE:  No Interrupt pending
            case  P1IV_NONE:
                break;

     

    (...)

            // Vector  P1IV_P1IFG7:  P1IV P1IFG.7
            case  P1IV_P1IFG7:
                if (buttonDebounce == 1)
                {
                    buttonDebounce = 2;
                    Start_Button_Debounce_Timer(); <----------<<<<<<<<<<<<<<<<<

     


    Hwi_Port1_ISR_Button is called by the Hwi monitoring the button interrupt on P1:

     
    Hwi.create(47, '&Hwi_Port1_ISR_Button');

     

    This all works with a continuous timer, but not a user triggered one.  I never get into (when triggered by user):

     

    void Button_Debounce_Toggle(void)

    which is linked to the timer with:

    Program.global.Button_Debounce_Timer = Timer.create(Timer.ANY,
    "&Button_Debounce_Toggle", timerParams_debounce);

     

    I use extern Timer_Handle Button_Debounce_Timer;

    As I mentioned earlier, if the timer is Auto and continuous, it all works.  But I'd rather start the timer when I want to reduce power.

     

    Thanks.

     

    Hans.

     

     

  • Hans,

    After the Timer_start() function is called. Can you look at ROV and confirm that status of the timer? Let the target run for a bit and halt it. What is the status of the timer in ROV now? Could you be calling Timer_start() again before it had a chance to go off?

    Todd

  • Hi Todd,

     

    I notice that the timer 26ea timer is Disabled and remains Disabled.  Anything I should do?

     

    Before the

     

    Timer_start(Button_Debounce_Timer);

     

    ,0x000026be,0,Timer0_A5,0x340,53,RunMode_CONTINUOUS,16384,12145,4239,32768,Enabled

    ,0x000026ea,1,Timer1_A3,0x380,49,RunMode_ONESHOT,8192,8192,0,0,Disabled<--------------------------------<<

    ,0x00002716,2,Timer0_B7,0x400,44,RunMode_CONTINUOUS,65535,54332,11203,65532,Enabled

     

    ,0x000026be,,,0,ti.sysbios.family.msp430.Timer.BasicView#0/configuration,StartMode_AUTO,RunMode_CONTINUOUS,16384,PeriodType_COUNTS,false,53,myTickFxn,0x00000000,32768,0x2670

    ,0x000026ea,,,1,ti.sysbios.family.msp430.Timer.BasicView#1/configuration,StartMode_USER,RunMode_ONESHOT,8192,PeriodType_COUNTS,false,49,Button_Debounce_Toggle,0x00000000,32768,0x267e

    ,0x00002716,,,2,ti.sysbios.family.msp430.Timer.BasicView#2/configuration,StartMode_USER,RunMode_CONTINUOUS,65535,PeriodType_COUNTS,false,44,ti_sysbios_family_msp430_TimestampProvider_rolloverFunc__E,0x00000000,32768,0x268c

     

    After:

     

    ,0x000026be,0,Timer0_A5,0x340,53,RunMode_CONTINUOUS,16384,12145,4239,32768,Enabled

    ,0x000026ea,1,Timer1_A3,0x380,49,RunMode_ONESHOT,8192,8192,0,0,Disabled<--------------------------------<<

    ,0x00002716,2,Timer0_B7,0x400,44,RunMode_CONTINUOUS,65535,54332,11203,65532,Enabled

     

    ,0x000026be,,,0,ti.sysbios.family.msp430.Timer.BasicView#3/configuration,StartMode_AUTO,RunMode_CONTINUOUS,16384,PeriodType_COUNTS,false,53,myTickFxn,0x00000000,32768,0x2670

    ,0x000026ea,,,1,ti.sysbios.family.msp430.Timer.BasicView#4/configuration,StartMode_USER,RunMode_ONESHOT,8192,PeriodType_COUNTS,false,49,Button_Debounce_Toggle,0x00000000,32768,0x267e

    ,0x00002716,,,2,ti.sysbios.family.msp430.Timer.BasicView#5/configuration,StartMode_USER,RunMode_CONTINUOUS,65535,PeriodType_COUNTS,false,44,ti_sysbios_family_msp430_TimestampProvider_rolloverFunc__E,0x00000000,32768,0x268c

     

     

    I haven’t done anything special for other timer…

     

    Thanks.

     

    Hans.

  • Hans,

    Nothing jumps out. Can you confirm that the address you are passing into Timer_start is 0x000026ea (e.g. Button_Debounce_Timer=0x000026ea)? I confirmed that your code works on a non-MSP430 board that was handy. I'll try it on a MSP430 next.

    Todd

  • Hans,

    I confirmed that your example works on a MSP430 that I have here. I was incorrect in my previous post about the address to check.

    Can you show my the useModule and the #include you are using. They should match. For example, here is a snippet from my .cfg file.

    var Timer = xdc.useModule('ti.sysbios.family.msp430.Timer');
    var timerParams_debounce = new Timer.Params();
    timerParams_debounce.startMode = Timer.StartMode_USER;
    timerParams_debounce.runMode = Timer.RunMode_ONESHOT;
    timerParams_debounce.period = 250000;
    timerParams_debounce.periodType = Timer.PeriodType_MICROSECS;
    Program.global.Button_Debounce_Timer = Timer.create(Timer.ANY, "&Button_Debounce_Toggle", timerParams_debounce);

    and here is the #include in the .c file

    #include <ti/sysbios/family/msp430/Timer.h>

    I expect you have this mismatched. For example, do you use the above useModule and the following include?

    #include <ti/sysbios/hal/Timer.h>

    Todd

  • Hi Todd,

     You're good. Indeed, I was using the wrong .h file.

    It works now:

    ,0x000026ea,1,Timer1_A3,0x380,49,RunMode_ONESHOT,8192,0,8192,0,Enabled

    Thanks.

     

    Hans.