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.

CCS/SW-EK-TM4C129EXL: Auto Start Tiva With out press Reset Button ?

Part Number: SW-EK-TM4C129EXL
Other Parts Discussed in Thread: EK-TM4C129EXL, STRIKE

Tool/software: Code Composer Studio

Hi,

I am using TM4C129EXL kit and CCS 7.0.

I have modified enet_lwip.c for sending serial data ( string characters) through Ethernet. It is working fine.

My program starts with initializing the main clock, peripherals for ethernet, uart, gpio, spi communicaiton, enabling interrupts and few UARTprintf statements and goes to an infinite while loop. Whenever data 

is sent through ethernet, an interrupt occurs and it breaks the infinite while loop and goes to the interrupts subroutine and reads the data, prints them and returns back to the infinite while loop.

I power the board through the USB port of my laptop. 

The problem is: If I unplug the power going through a USB cable and reconnect it, the program does not start from the beginning. I can't even know where the program control is.

However, if I press the reset button, the program starts from the beginning and works fine. Do I need to enable power-on reset in the controller?

I feel like, Pressing the reset button and Power On reset has a different effect on the controller. 

Thank You.

 

  • Plugging in the USB cable will apply power to the device and it will start executing from reset. Try programming the example:
    "C:\ti\TivaWare_C_Series-2.1.4.178\examples\boards\ek-tm4c129exl\blinky" into your EK-TM4C129EXL launchpad and verify that you get a blinking LED.
  • Thanks Bob.

    I tried with the blink LED example. As you mentioned, it works fine even after unplugging and replugging the controller's power. But my program is a little bit complicated.

    I have attached part of my code below (main function). It has lots of peripheral initializations, interrupts initialization, etc.

    It has a function call named EthernetInit(); through which I'll try to establish a TCP connection between my PC and board using STATIC IP. 

    It also involves SPI communications, UART communication and SystemTick initialisation.

    After all these initializations, it goes into an infinite while loop and just blinks an LED.

    I feel like the Power on Reset fails because of all these communications. Can anyone tell exactly which part of the code hinders the Power On Reset?

    Are there any other loopholes like doing a Software programmed Reset only when the power goes off and comes back?

    My code:

    int main(void)
    {

      uint32_t ui32User0, ui32User1;
        uint8_t pui8MACArray[8];
    
    
        //
        // Make sure the main oscillator is enabled because this is required by
        // the PHY.  The system must have a 25MHz crystal attached to the OSC
        // pins. The SYSCTL_MOSC_HIGHFREQ parameter is used when the crystal
        // frequency is 10MHz or higher.
        //
    
        SysCtlMOSCConfigSet(SYSCTL_MOSC_HIGHFREQ);
    
        //
        // Run from the PLL at 120 MHz.
        //
        g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
                                                 SYSCTL_OSC_MAIN |
                                                 SYSCTL_USE_PLL |
                                                 SYSCTL_CFG_VCO_480), 120000000);
    
        //*************************************************************************************
    
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);  // For SSI1 CLK At PB5
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);   //  For SSI1 DATA0 At PE4
        SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI1);
    
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION); // UART Check LED
    
        SysCtlPeripheralReset(SYSCTL_PERIPH_GPIOB);
        SysCtlPeripheralReset(SYSCTL_PERIPH_GPIOE);
        SysCtlPeripheralReset(SYSCTL_PERIPH_SSI1);
    
        GPIOPinConfigure(GPIO_PB5_SSI1CLK);
        GPIOPinConfigure(GPIO_PE4_SSI1XDAT0);
        GPIOPinConfigure(GPIO_PE5_SSI1XDAT1);
    
        GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, GPIO_PIN_4);
    
    
    
        GPIOPinTypeSSI(GPIO_PORTB_BASE, GPIO_PIN_5);
        GPIOPinTypeSSI(GPIO_PORTE_BASE, GPIO_PIN_4 | GPIO_PIN_5);
        SSIClockSourceSet(SSI1_BASE, SSI_CLOCK_SYSTEM);
        SSIConfigSetExpClk(SSI1_BASE, g_ui32SysClock, SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, g_ui32SysClock/40, 8);
        SSIAdvModeSet(SSI1_BASE,SSI_ADV_MODE_READ_WRITE);
        SSIIntRegister(SSI1_BASE, SSI1IntHandler);
        SSIIntEnable(SSI1_BASE ,SSI_RXTO| SSI_RXOR);
        SSIEnable(SSI1_BASE);
    
    
        IntMasterEnable();
    
        //
        // Configure the device pins.
        //
        PinoutSet(true, false);
    
        //
        // Configure UART.
        //
        UARTStdioConfig(0, 115200, g_ui32SysClock);
        IntEnable(INT_UART0);
        UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT);
    
        SysCtlPeripheralEnable(SYSCTL_PERIPH_EEPROM0);
    
            SysCtlPeripheralReset(SYSCTL_PERIPH_EEPROM0);
            //
            // Wait for the EEPROM module to be ready.
            //
            while(!SysCtlPeripheralReady(SYSCTL_PERIPH_EEPROM0))
            {
            }
            uint32_t ui32EEPROMInit;
    
            ui32EEPROMInit = EEPROMInit();
    
            //ROM_EEPROMProgram((uint32_t *)&data, E2PROM_TEST_ADRES, sizeof(data));
            //
            // Check if the EEPROM Initialization returned an error
            // and inform the application
            //
    
        //
        // Clear the terminal and print banner.
        //
        UARTprintf("\033[2J\033[H");
        UARTprintf("Ethernet lwIP example\n\n");
    
        if(ui32EEPROMInit != EEPROM_INIT_OK)
           {
               UARTprintf("EEPROM NOT INITALISED\n");
           }
           else
           {
               UARTprintf("EEPROM INITALISED\n");
           }
    
    
    
        //
        // Configure Port N1 for as an output for the animation LED.
        //
        MAP_GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_1);
    
    
        //
        // Initialize LED to OFF (0)
        //
        MAP_GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_1, ~GPIO_PIN_1);
    
        //
        // Configure SysTick for a periodic interrupt.
        //
        MAP_SysTickPeriodSet(g_ui32SysClock / SYSTICKHZ);
        MAP_SysTickEnable();
        MAP_SysTickIntEnable();
    
        //
        // Configure the hardware MAC address for Ethernet Controller filtering of
        // incoming packets.  The MAC address will be stored in the non-volatile
        // USER0 and USER1 registers.
        //
        MAP_FlashUserGet(&ui32User0, &ui32User1);
        if((ui32User0 == 0xffffffff) || (ui32User1 == 0xffffffff))
        {
            //
            // We should never get here.  This is an error if the MAC address has
            // not been programmed into the device.  Exit the program.
            // Let the user know there is no MAC address
            //
            UARTprintf("No MAC programmed!\n");
            while(1)
            {
            }
        }
    
        //
        // Tell the user what we are doing just now.
        //
        UARTprintf("Waiting for IP.\n");
    
        //
        // Convert the 24/24 split MAC address from NV ram into a 32/16 split MAC
        // address needed to program the hardware registers, then program the MAC
        // address into the Ethernet Controller registers.
        //
        pui8MACArray[0] = ((ui32User0 >>  0) & 0xff);
        pui8MACArray[1] = ((ui32User0 >>  8) & 0xff);
        pui8MACArray[2] = ((ui32User0 >> 16) & 0xff);
        pui8MACArray[3] = ((ui32User1 >>  0) & 0xff);
        pui8MACArray[4] = ((ui32User1 >>  8) & 0xff);
        pui8MACArray[5] = ((ui32User1 >> 16) & 0xff);
    
        //
        // Initialize the lwIP library, using DHCP.
        //
        lwIPInit(g_ui32SysClock, pui8MACArray, 3232236043, 4294967040, 0, IPADDR_USE_STATIC);
    
        //
        // Setup the device locator service.
        //
        //LocatorInit();
        //LocatorMACAddrSet(pui8MACArray);
        //LocatorAppTitleSet("EK-TM4C1294XL enet_io");
    
        //
        // Initialize a sample httpd server.
        //
        init_default();
        init_channels();
    
    
        Ethernet_Init();
        //httpd_init();
    
        //
        // Set the interrupt priorities.  We set the SysTick interrupt to a higher
        // priority than the Ethernet interrupt to ensure that the file system
        // tick is processed if SysTick occurs while the Ethernet handler is being
        // processed.  This is very likely since all the TCP/IP and HTTP work is
        // done in the context of the Ethernet interrupt.
        //
        MAP_IntPrioritySet(INT_EMAC0, ETHERNET_INT_PRIORITY);
        MAP_IntPrioritySet(FAULT_SYSTICK, SYSTICK_INT_PRIORITY);
    
        //
        // Loop forever, processing the LED blinking.  All the work is done in
        // interrupt handlers.
        //
        while(1)
        {
            //
            // Wait till the SysTick Interrupt indicates to change the state of the
            // LED.
            //
            while(g_bLED == false)
            {
            }
    
            //
            // Clear the flag.
            //
            g_bLED = false;
    
            //
            // Toggle the LED.
            //
            MAP_GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_1,
                             (MAP_GPIOPinRead(GPIO_PORTN_BASE, GPIO_PIN_1) ^
                              GPIO_PIN_1));
        }
    }

  • On occasion - my small Tech firm has observed, 'Just the effect you (now) note!'  

    Vendor Bob's suggestion of (the KISS-based) simple, 'Blinky Program' establishes your board's  'HW adequacy'  to achieve 'POR.'     However - such should be tested 'multiple times' - to properly confirm.

    The 'fastest & simplest' checks involve hardware - I'll list these first.    (Passing the 'Blinky' test (almost) exonerates HW - but NOT always!)

    Follows our firm's insight & guidance:

    • Do repeat such testing upon:
      • different USB Ports w/in that (same) PC
      • different PCs

    This is offered as 'improper Power Delivery' may cause 'Failure/Distress' of the expected, 'Power On Reset.'

    • Change to a different USB Cable - several cables at that
    • Shorten the length of the USB Cable (added cable inductance has been noted to 'distress POR.')
    • Power your board with a proper +5V external supply - applied to the proper board pins.    Pay close attention to the 'setting' of your board's power switch!    It is preferred that  you insure that NO USB connection exists - while  testing via this External Supply.    (it may be that the +5V power delivery - provided by the USB Cable - must be 'broken' - when external power is being supplied/tested.)
    • you yourself note (many) peripheral connections to your board.    The tests suggested here should be made without any  external connections.   (other than power)

    Should your board (properly) perform (POR) after switch to the external supply - the "Power Delivery via USB Port" - has been confirmed as suspect!

    • should the PC Port issue 'prove the case' - the lowered value of  'pull-up R' - to the MCU's Reset Line - has resolved (similar) such POR Issues...   (insure such pull-up IS present!)

    Should (all) of these 'HW' methods (fail to correct) - it proves likely that your, 'Start-Up File and/or (very) early Code' proves suspect.

    Give good note to 'Blinky's' early program code"    (I list it below - there is a combination of  'SAFE, CONSERVATIVE, & BEST PRACTICE'  employed!)

    main(void)
    {
    volatile uint32_t ui32Loop;

    // Enable the GPIO port that is used for the on-board LED.
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);

    // Check if the peripheral access is enabled.
    //
    while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOG))   //    This is a 'SAFE' early function - as the code 'provides the MCU' a (somewhat) 'forgiving' environment - from which to START!   
    {
    }

    Now your code - starts 'immediately' with: 'SysCtlMOSCConfigSet()' - and that followed  by: 'g_ui32SysClock = MAP_SysCtlClockFreqSet().'      That's BRUTAL (in contrast) - is it not?

    Are not (both) of those functions highly demanding & challenging - upon the 'just Powered' MCU?     I believe that - to 'prove the case.'

    There IS a (very) quick/easy means for you to test my theory - simply add those two functions (yours) - and ONLY those two)  (atop (i.e. BEFORE the blinky code ) - exactly as you have them in your (existing) code!     (along w/the minimum of supporting (.h files) - which may be required.)    Do NOT add your entire code - simply those two functions - ONLY!   Should this (modified) 'Blinky'  PASS - then your code (likely) introduces (other) issues - yet I'd 'bet heavily' - on POR  (still) FAILING - w/this code addition.   (i.e.  such code proves too challenging for the 'just powered MCU.')

    I believe this to occur due to the (likely) 'Increased speed of VDD build-up - as felt @ MCU's RESET'  when you 'activate then release the Reset switch.'     When you instead, 'Plug-In the USB Cable' - the  entire board  must charge from '0V' - which  (likely adds an excessive dV/dT slope) to the  MCU's RESET!      Blinky survives & accepts this - due to the defensive & conservative 'first code executed.'     The code you've deployed (pardon) - proves  neither defensive nor conservative - and your MCU hangs!

    In either case - 'Scope-Caps' of the MCU's Reset Line should be captured & presented here (during Reset Switch AND POR) - should further diagnosis be required!

    In the *unexpected' event that you've (really) followed such direction - and (still) POR hangs - the following is presented.

    • Carefully review (i.e. contrast/compare) the Start-Up file of 'Blinky' (which has worked) to your (unique) Start-Up file.
    • Avoid any/all 'interrupt-based' code - from appearing 'early' w/in your program.    
    • A 'cascade' of  'ASM based NOPs' - as the (very) first code to be executed - serves to 'assist' the 'POR' to assert and/or 'take hold.'
    • It WILL (w/out doubt)  prove useful to, 'Append your code to Blinky!'      Ideally - one function at a time - systematically & gradually  (that's KISS) testing for the 'ONSET' of POR Failure!     (Be sure to modify the Start-Up file of 'Blinky' similarly - reflecting your broader usage - yet (still) 'One function at a time.'

  • Thank You for well explained and detailed in-depth answer.

    Like you said, the problem was with my code. It had some heavy processing code lines at the beginning. 

    I tried with adding the two functions from my code to the beginning of the blinky example and the  POR works perfectly even after adding.

    Then, in my code at the beginning, I added the following line of code just to blink an onboard led. 

    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION);

    while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPION))
    { }

    GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_0);

    GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_0, GPIO_PIN_0);

    SysCtlDelay(40000*1000);  //  1 sec delay

    GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_0, 0x00);

     

    After blinking the LED, I continued with my heavy processing code lines. And it worked perfectly and resolved my issue on POR.

    Like you said, starting immediately with SysCtlMOSCConfigSet()'  and  followed  by 'g_ui32SysClock = MAP_SysCtlClockFreqSet() was brutal. And that caused the POR problem.

    After adding the blink led code at the beginning, my problem is resolved.

    However, when I tried to start the program with just a simple delay SysCtlDelay(40000*1000), instead of blinking an LED, the POR problem continues. 

    Anyhow, my problem is resolved now.

    Thank you once again..

     

  • RAGHUL N M said:
    Thank You for well explained and detailed in-depth answer.

    And may I thank you - as well - for 'YOUR  EQUALLY'  well explained, detailed & in-depth report confirming 'my theory.'     (thanks as well for the 'award.')

    MCUs undergo a reasonably 'intense' Start-Up Procedure - and when (burdened) with an overly aggressive, "FIRST EXECUTING CODE BLOCK" - issues such as 'POR' are 'heightened!'    

    Your 'modification of my suggested (Blinky.c code) as preamble' - to code (more) 'directed' to your APP - proved clever.    AND effective (as it retained the 'Defensive/Gentle' MCU Start-Up) - pity that (so few) here - have,  'made such connection!'

    Now that your 'POR' issue (appears) resolved - you  may consider: Finding, Reading, Understanding & then Deploying 'gpio-jtag.c' (or similar) - as the (very) NEXT 'code block' -  your programs - ARE ALWAYS to RUN! 

    Along w/resolving 'POR' (and other issues firm/I have discovered)  this will enable you to 'Recover your MCU's JTAG Commo' - should (most any) 'misfortune' strike.    Our firm employs a very similar 'Protective Coding Mechanism' - in ALL of our programs (this vendor's ARM as well as that of multiple others) - with highly satisfactory results...

    Prevention indeed ... trumps (any) cure!     And SO MANY here - suffer the indignity & frustration - of  AVOIDABLE:  'JTAG LOCK-OUT!'

    You are to be applauded for:

    • accepting guidance
    • testing - then 'proving/confirming' its effectiveness
    • and then 'fine-tuning' (to your specific need) - while (retaining) the strategic 'ESSENCE.'

    Well done!