This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

TM4C123GXL: Why does SysCtlDelay require initialization of FPU?

Hi experts,

Summary: Tried to run a program that uses the TI library driverlib.lib, compiled/linked with no error but found out that it requires initialization of FPU, which I disabled in the dialog already.

Here is the list of the full program:

#include <stdint.h>
#include <stdbool.h>
#include "sysctl.h"
#include "tm4c123gh6pm.h"

void PortA_Init(void){ 
    volatile unsigned long delay;
    SYSCTL_RCGC2_R |= 0x00000001;         // 1) A clock
    delay = SYSCTL_RCGC2_R;                    // delay   
    GPIO_PORTA_LOCK_R = 0x4C4F434B;     // 2) unlock PortB
    GPIO_PORTA_CR_R = 0x80;                   // allow changes to PF7-0       
    GPIO_PORTA_AMSEL_R = 0x00;             // 3) disable analog function
    GPIO_PORTA_PCTL_R = 0x00000000;   // 4) GPIO clear bit PCTL  
    GPIO_PORTA_DIR_R |= 0x80;             // 5) PB6~4 output   
    GPIO_PORTA_AFSEL_R = 0x00;          // 6) no alternate function  
    GPIO_PORTA_DEN_R |= 0x80;           // 7) enable digital pins PB7-PB0  
    GPIO_PORTA_DATA_R |= 0x80;
}

int main(void) {
    PortA_Init();
    while(1) {
        GPIO_PORTA_DATA_R |= 0x80;
        SysCtlDelay(500000);
        GPIO_PORTA_DATA_R &= ~0x80;
        SysCtlDelay(500000);
    }
    return 0;
}

I already did the following:

1 - Included the driverlib.lib file from TI;

2 - In "Options" -> "Target", put "Floating Point Hardware" to "Not Used";

3- In "Options" -> "Device", put Device as TM4C123GH6PM which is the CPU for the development board;

Results that I found out in debugging:

1 - Mixed mode debugging shows that program encounters the HardFault loop during initialization (i.e. before running any actual code), further research shows that 0xE000ED2A shows 0x08, which indicates that the program tries to access some hardware without initialization;

2 - Assembly mode debugging shows that during initialization the _fp_init is called and immediately triggers a hardfault as I did not need/plan to initialize FPU.

3 - If I comment out the two SysCtlDelay() lines, _fp_init is NOT called and everything goes fine. LED is luminated as expected;

4 - Further research did not find anything promising, excepting that in an older post one user recommended that one can recompile and build driverlib.lib without FPU. However, AFAIK, most people who uses the library never encountered this issue for such a simple program.

Final Solution:

I actually got a solution a few minutes ago, that is to compile using the "MicroLib" option turned on. However I don't really get why I have to do that. Can you please let me know if it's absolutely necessary to initialize FPU for driverlib.lib if I do not want to use MicroLib? Thanks in advance~~