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.

MSP430F5310 Can't start the one-shot timer

Other Parts Discussed in Thread: SYSBIOS

I am trying to set up a one-shot timer on timer 1, and can't get it to work.  I am using timer 0 as a PWM output, and timer 2 as the Clock_tick timer.  Both of these work well.  I would like to create a one-shot timer that I can set with various time-outs, start, and get an interrupt from upon time-out.  To test the timers software, I created a static, periodic timer that started automatically.  That worked well, so I changed it to an auto starting one-shot, and that worked.  When I set the timer to be USER started with a call to Timer_start(..), however, I don't get the interrupt.

  • Marc,

    Can you please post your application .cfg file, or at least the script code relating to configuring and creating the timers?

    And also the C code snippet showing the timer handle declaration and the call to Timer_start()?

    Thanks,
    Scott

  • Yes.

    .cfg file:

    var Defaults = xdc.useModule('xdc.runtime.Defaults');
    var Diags = xdc.useModule('xdc.runtime.Diags');
    var Error = xdc.useModule('xdc.runtime.Error');
    var Log = xdc.useModule('xdc.runtime.Log');
    var LoggerBuf = xdc.useModule('xdc.runtime.LoggerBuf');
    var Main = xdc.useModule('xdc.runtime.Main');
    var Memory = xdc.useModule('xdc.runtime.Memory');
    var SysMin = xdc.useModule('xdc.runtime.SysMin');
    var System = xdc.useModule('xdc.runtime.System');
    var Text = xdc.useModule('xdc.runtime.Text');
    var BIOS = xdc.useModule('ti.sysbios.BIOS');
    var Task = xdc.useModule('ti.sysbios.knl.Task');
    var Timer = xdc.useModule('ti.sysbios.family.msp430.Timer');
    var Semaphore = xdc.useModule('ti.sysbios.knl.Semaphore');
    var ti_sysbios_BIOS = xdc.useModule('ti.sysbios.BIOS');
    var Swi = xdc.useModule('ti.sysbios.knl.Swi');
    var ti_sysbios_hal_Timer = xdc.useModule('ti.sysbios.hal.Timer');
    var Clock = xdc.useModule('ti.sysbios.knl.Clock');
    var Hwi = xdc.useModule('ti.sysbios.hal.Hwi');
    Text.isLoaded = false;
    Defaults.common$.namedModule = false;
    BIOS.libType = BIOS.LibType_Custom;
    BIOS.logsEnabled = false;
    BIOS.clockEnabled = true;
    BIOS.swiEnabled = true;
    BIOS.heapSize = 0;
    BIOS.cpuFreq.lo = 25000000;
    BIOS.assertsEnabled = false;
    Program.stack = 0x200;
    Task.idleTaskStackSize = 200;
    Task.defaultStackSize = 200;
    var task0Params = new Task.Params();
    task0Params.instance.name = "Oled";
    task0Params.stackSize = 300;
    Program.global.Oled = Task.create("&UpdateOledTask", task0Params);
    Clock.timerId = 2;
    Clock.tickMode = Clock.TickMode_PERIODIC;
    var monthermParams = new Task.Params();
    monthermParams.instance.name = "montherm";
    monthermParams.stackSize = 320;
    monthermParams.priority = 3;
    Program.global.montherm = Task.create("&monitorThermTask", monthermParams);
    var updateADCParams = new Task.Params();
    updateADCParams.instance.name = "updateADC";
    updateADCParams.stackSize = 300;
    updateADCParams.priority = 2;
    Program.global.updateADC = Task.create("&updateADCTask", updateADCParams);
    var monRFIDParams = new Task.Params();
    monRFIDParams.instance.name = "monRFID";
    monRFIDParams.stackSize = 300;
    Program.global.monRFID = Task.create("&monitorRFIDTask", monRFIDParams);
    var RFIDsemParams = new Semaphore.Params();
    RFIDsemParams.instance.name = "RFIDsem";
    RFIDsemParams.mode = Semaphore.Mode_BINARY;
    Program.global.RFIDsem = Semaphore.create(0, RFIDsemParams);
    var hwi0Params = new Hwi.Params();
    hwi0Params.instance.name = "RFIDISR";
    hwi0Params.enableInt = false;
    Program.global.RFIDISR = Hwi.create(47, "&handleRFIDISR", hwi0Params);
    var HostI2CParams = new Hwi.Params();
    HostI2CParams.instance.name = "HostI2C";
    Program.global.HostI2C = Hwi.create(null, "&hostISR", HostI2CParams);
    var rfidtimerParams = new Timer.Params();
    rfidtimerParams.instance.name = "rfidtimer";
    rfidtimerParams.runMode = xdc.module("ti.sysbios.interfaces.ITimer").RunMode_ONESHOT;
    rfidtimerParams.startMode = xdc.module("ti.sysbios.interfaces.ITimer").StartMode_USER;
    rfidtimerParams.period = 200000;
    Program.global.rfidtimer = Timer.create(1, "&rfidtickfcn", rfidtimerParams);
    Timer.keepAwake = true;

    ====================================

    Code used to start the timer after the call to         BIOS_start();       

    extern Timer_Handle rfidtimer;


    void monitorRFID()
    {
        OSRFtimeStart(30000);
        for (;;)
        {
    //        OSRFtimeStart(30000);

            OSTask_Sleep(500);
        }
    }

    void OSRFtimeStart(unsigned short time)
    {
    //    Timer_setPeriod(rfidtimer, time);
        Timer_start(rfidtimer);
    }







  • Marc,

    Thanks.

    I did some experimentation with StartMode_USER and cannot find any issues.

    Are you sure that the “monitorRFID()” function is actually being called to start the timer?  It looks like this is intended to be a Task function, but the Task creation specifies "&monitorRFIDTask”.

    That is the only thing I can think of at the moment.

    There are a couple other things of note in the .cfg file:

    There is an unnecessary “xdc.useModule('ti.sysbios.hal.Timer');”.  This should be removed because there is already a “xdc.useModule('ti.sysbios.family.msp430.Timer');” - which is needed since you are using the MSP430-specific Timer.keepAwake.

    Also, the Hwi creation for the HostI2C specifies “null” instead of a proper interrupt ID.  I don’t think this would be causing a Timer issue, but this must be corrected to get any I2C interrupts.

    Scott

  • Scott

    Thank you.  So what I'm doing should work.  That's good to know. 

    I haven't had a chance to test the I2C so you just saved me some big time!

    I am actually calling the function monitorRFID from monitorRFIDTask so yup, it's being called.  Could the unnecessary xdc.useModule('ti.sysbios.hal.Timer'); in the .cfg file be causing this issue?  I am using timer 2 as the Cock timer so that I can have the Task_sleep() command, and I also want the one-shot.  If I delete xdc.useModule('ti.sysbios.hal.Timer'); will it kill my Task_sleep()?

    Will give it a go anyway.

  • Marc,

    I don’t think the extra useModule would be causing an issue like you describe.  I tried adding it to my test and didn’t see any change - the test still worked.  I’m not clear if there may be some subtle issues by having it there though, so I recommended removing it.

    Scott

  • Scott,

    I re-visited my explanation of the problem, and realized that I had left out something that might be helpful.  When the timer isn't running, I break the program (pause), and look at the timers through ROV.  The timer that is having the problem shows up as "disabled".

    I deleted the xdc...hal.Timer line from the .cfg file, and still no timer 1 interrupt.  I have been able to generate a work around using Task_sleep, but I'm pushing the spec. with this, so if I can get the timer 1 working, I'll use that.

  • Marc,

    ROV will show the timer as “disabled” if it is not started.  For example, before calling Timer_start():

     

    And just after:

     

    This test I’m showing is on a 5438A, not a 5310 since I don’t have one handy.  

    Can you try setting a breakpoint on your Timer_start() call, and then on the instruction after it, and see if ROV shows that it starts?

    Thanks,
    Scott

  • Bummer.  I didn't get a start.

  • Marc,

    This is very odd! 

    If I understand it right… this Timer 1 works fine for you when you configure it to be StartMode_AUTO and RunMode_CONTINUOUS, and StartMode_AUTO and RunMode_ONESHOT, but when you configure StartMode_USER and RunMode_ONESHOT it is not starting?

    Is it possible there is some other code poking this timer too?  Maybe you can disable the PWM you’ve got configured for Timer 0, and Clock for Timer 2, and see if Timer 1 will start?

    Or maybe switch to Timer 1 for Clock and Timer 2 for the one shot?

    Can you please try these two tests?

    Also, a screenshot of the timer registers (base 0x380) before and after the Timer_start() call?

    Thanks,
    Scott

  • Scott,

    I just ran one of the tests you suggested, and saw two interesting things: There is a funny 0x10001 address being accessed, and Timer 1 is not touched during the CALL to Timer_Start.

    ... and after

  • Scott,

    For some reason my screen shots are not pasting or uploading.  (*.png)  Too big?

  • I'll try JPEG

    and after ...

  • I'm not sure what the cause of your download issue is.  But if you can't make it work you should ask here:

    http://e2e.ti.com/group/helpcentral/f/301.aspx

    Dave

  • Scott,

    What the screen shot would have shown is that the Timer 1 registers are untouched after the CALL.  I'm looking at Timer1_A3: TA1CTL = 0x0100.  The rest are zero.

  • Marc,

    OK, thanks.  I don’t know what is going on with uploading the images.  

    I’m most curious about your comment about access to 0x10001.  Is it possible for you to send me your project?  I think you can do this by hovering over my name and then adding me as a friend.  I think you can then send me the files directly.

    I can then post any findings back to this forum thread for other members.  Does this work?

    Thanks,
    Scott

  • Scott,

    I just added you as a friend.  What is the complete set of files that you need?  Also, I have a work around running now so the timer1 code will seem useless.

    Marc

  • Marc,

    I just accepted the friend request.  

    If you can zip up the whole CCS project that would be best.  And please add those screenshots too.

    Thanks,
    Scott

  • I understand that Scott is continuing to work this issue, so I will keep this thread open.

    Dave