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.

Sysbios locks for about 2 seconds after using gateAll functions

Other Parts Discussed in Thread: MSP430F5438A, SYSBIOS, CC1120

Hi,

I'm new to bios and using:

  • Bios version 6.34.2.18. 
  • IPC Version 1.25.0.04
  • XDCTools version 3.24.5.48
  • CCS V 5.3.0.00090

I am using a custom board with MSP430F5438A. 

I seem to be experiencing a lock up of the system (does not respond to interrupts and tasks do not run) when I use GateAll functions. I don't think the problem is priority inversion because I enter a gate do something that dose not:

 - call functions that enter or leave gates.

-  or pend on events or semaphores.

On the board there are 3 SPI FRAM modules. One of the tasks writes data on chip 1 every X seconds. The same task writes data on chip 2 after X minutes and data to chip 3 after X hours. My timer module uses a hardware timer interrupt which calls a Swi post function. It is very similar to the one found on page 3-68 of Bios_User_Guide (SPRUEX3J).

The data is then read every Y seconds by another task from the FRAMs and printed on a computer screen via UART. 

Before writing or reading data to the FRAMs I call a GateAll_enter and then GateAll_leave. The data is read and written correctly to FRAMs and printed via UART. The SPI and UART drivers work fine without sysbios. I have made sure that ther interrupt keyword is not used anywhere in my code.

If I use the gate functions my system locks up for about 2,5 seconds after every read or write via SPI. I have seen that the system hangs only after every task has finished execution. After 2,5 seconds everything works fine until the next gateAll function call.  If I substitute the gateAll functions with interrupt disable functions (Hwi_disable and Hwi_enable) the same thing happens.

If I do not protect the critical parts of my code with gates or by disabling/enabling interrupts everything works as it should (except for the risk of data writes being interrupted by interrupts). 

In my application the UART is working with interrupts in transmission and reception meanwhile the SPI does not use interrupts.

Any help would be really appreciated.

Thanks

Adam

  • Adam,

    How long are you locking the CPU (either via GateAll_enter() or Hwi_disable())?  How long does it take to write/read those FRAMs?

    Also, have you enabled Clock tick suppression (http://processors.wiki.ti.com/index.php/SYS/BIOS_for_the_MSP430#Clock_Tick_Suppression)?  In the SYS/BIOS release you’re using it should be disabled by default.  But I wonder if you’ve enabled it.  If some of the constraints for the DYNAMIC tick mode are violated (http://processors.wiki.ti.com/index.php/SYS/BIOS_for_the_MSP430#Important_Notes_Regarding_Clock_Tick_Suppression) then the timer interrupt may not be generated until the timer count wraps around, which is 2 seconds for a 16-bit timer running at 32KHz.  But… this wraparound condition will only affect the timer peripheral being used by the Clock module, and will not affect other timers or interrupt sources.  So it doesn’t sound like this is the issue… but your mention of “about 2 seconds” in the thread title got me wondering.  If you have enabled Clock tick suppression… can you try disabling it (http://processors.wiki.ti.com/index.php/SYS/BIOS_for_the_MSP430#Switch_Clock_module_from_using_TickMode_DYNAMIC_to_TickMode_PERIODIC) to see if that makes a difference?

    Thanks,
    Scott

  • Hi Scott,


    Thanks for your quick answer.
    I do not have clocks enabled in my project. I am using an instance of the timer module to call the interrupt function that implements the timers in my application.
    It takes about 5 ms to write on the FRAMs. My timer is set to generate an interrupt every 1 ms.

    I disabled the timer module and setup the clock module with default values, added a tick period of 1000us and created a clock instance that calls my timer function every 1ms. I made sure Clock.tickMode = Clock.TickMode_PERIODIC in my config file.

    And nothing…. Same behavior as when I used the timer module. I am now sure that the timer interrupt does not fire in those 2 seconds.
    I went back to using the timer module and disabled the clock module.

    Thanks to your advice I did a few more tests (created an Idle function that toggles a port and a HWI that also toggles a different port when an interrupt on port P1.1 occurs.

    It would seem that both the idle function and the HWI work while the device is "locked" (the ports toggle) but the timer interrupt is not called. Most of the events that are generated on my system in someway use the variables in the timer interrupt. This is why at first I thought that the system was "locking"

    I then set my Input clock source to SMCLK (I was using ACLK) compiled and everything worked perfectly! If I set it back to ACLK then the timer interrupt is not called after the gateAll fucntion calls.

    I must be doing something wrong when I setup ACLK or somewhere else... I use code that TI has used on one of the demo boards (CC1120 development kit) to startup XT1. On my custom hardware the external crystal and capacitors are on the same ports as on the demoboard and have the same values. The code works with out sysbios.

    This is the code I use to setup XT1 and I call it before calling BIOS_start()  (if I call it in a task there is no difference)...

    void hal_mcuStartXT1(void)
    {
        /* Set up XT1 Pins to analog function, and to lowest drive */
        P7SEL |= 0x03;
        UCSCTL6 |= XCAP_3 ;                       /* Set internal cap values */
     
        while(SFRIFG1 & OFIFG) {                  /* Check OFIFG fault flag  */
            while ( (SFRIFG1 & OFIFG))            /* Check OFIFG fault flag  */
            {
                /* Clear OSC fault flags  */
                UCSCTL7 &= ~(DCOFFG + XT1LFOFFG + XT1HFOFFG + XT2OFFG);
                SFRIFG1 &= ~OFIFG;                    /* Clear OFIFG fault flag  */
            }
            UCSCTL6 &= ~(XT1DRIVE1_L+XT1DRIVE0);    /* Reduce the drive strength */
        }
    }

    Grateful for any help you can give me.
    Thanks for your time
    Adam

  • Adam,

    OK, thanks for the details of your additional testing.

    I’m thinking the issue may be due to some interaction between your code to setup clocks in main(), and the clock setup code invoked by the Boot module, right after release from reset.  This default clock setup is mentioned in the description of the boot sequence (step 1a), here: http://processors.wiki.ti.com/index.php/SYS/BIOS_for_the_MSP430#Boot_sequence_with_SYS.2FBIOS

    The Boot module will by default setup MCLK=SMCLK=8MHz, and ACLK=32KHz.  The source file is included in the XDCtools install (for example, here: C:\ti\xdctools_3_24_03_33\packages\ti\catalog\msp430\init\Boot.c).  

    Since you are setting up clocks in main() yourself, can you try disabling the clock configuration by the Boot module(http://processors.wiki.ti.com/index.php/SYS/BIOS_for_the_MSP430#Turn_off_SYS.2FBIOS.E2.80.99s_frequency_boost_at_boot), and see if that resolves the issue when using ACLK?  

    Thanks,
    Scott

  • Hi Scott,

    I've been busy lately and haven't had time to read the documentation thoroughly. 

    I disabled the clock configuration by boot as you suggested: (in my .cfg file)

    Boot.configureDCO = false;

    and setup the clock frequencies:

    ClockFreqs.SMCLK = 20000000;

    ClockFreqs.ACLK = 32768;

    Guess what. Nothing... Timer interrupt fires only about 2 seconds after a gateAll call...

    Thanks for your help and time

    Adam

  • Adam,

    OK, thanks.  And sorry for the slow reply.

    I don’t know what would be causing the behavior you describe, and am not too familiar with the UCS itself.  It may be that we need some help from someone on the device or apps teams.

    Have you been able to verify that ACLK is indeed running at 32768Hz after your initialization code?

    Also, have you tried disabling your code that sets up clocks, and use just the default setup by the Boot module?

    And do you see the same behavior on multiple boards?

    Thanks,
    Scott