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.

Fault ISR Instruction Bus Error IBUSERR

Other Parts Discussed in Thread: TM4C123FH6PM

Hello everyone.

I´m facing a problem with my code and I´ve tried almost everything with no success. Debugging i´ve realized the code goes to the fault ISR, and looking at the (NVIC_FAULT_STAT) register I read 0x00010000, which is an Instruction Bus Error.

Also, when i comment the line: 

USBDCDCInit(0, &g_sCDCDevice);

it works perfectly, so could anyone help me with some tips about this?

Thanks in advance.

  • Hello Akira,

    Which TM4C device are you using and can you please explain more about the setup and possibly share the code? Please note that the usb_dev_serial example already exists for all TM4C products on both DK and EK boards

    Regards

    Amit

  • Hello, I'm using the TM4C123FH6PM device, and actually I'm using the same initialization as the usb_dev_serial example, in my main code i have:

    ROM_FPULazyStackingEnable();

    ROM_SysCtlClockSet(SYSCTL_OSC_MAIN|SYSCTL_SYSDIV_2_5|SYSCTL_USE_PLL|SYSCTL_XTAL_12MHZ);

    And my USB initialization code:

    void Usb_Init(void)
    {

    ROM_GPIOPinTypeUSBAnalog(GPIO_PORTD_BASE, GPIO_PIN_5 | GPIO_PIN_4);

    g_bUSBConfigured = false;

    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART7);

    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
    ROM_GPIOPinTypeUART(GPIO_PORTE_BASE, GPIO_PIN_1);
    ROM_GPIOPinTypeUART(GPIO_PORTE_BASE, GPIO_PIN_0);

    ROM_UARTConfigSetExpClk(UART7_BASE, ROM_SysCtlClockGet(),
    DEFAULT_BIT_RATE, DEFAULT_UART_CONFIG);
    ROM_UARTFIFOLevelSet(UART7_BASE, UART_FIFO_TX1_8, UART_FIFO_RX1_8);

    ROM_UARTIntClear(UART7_BASE, ROM_UARTIntStatus(UART7_BASE, false));
    ROM_UARTIntEnable(UART7_BASE, (UART_INT_OE | UART_INT_BE | UART_INT_PE |
    UART_INT_FE | UART_INT_RT | UART_INT_TX | UART_INT_RX));

    ROM_UARTEnable(UART7_BASE);

    ROM_SysTickPeriodSet(ROM_SysCtlClockGet() / SYSTICKS_PER_SECOND);
    ROM_SysTickIntEnable();
    ROM_SysTickEnable();

    USBBufferInit(&g_sTxBuffer);
    USBBufferInit(&g_sRxBuffer);

    USBStackModeSet(0, eUSBModeForceDevice, 0);

    USBDCDCInit(0, &g_sCDCDevice);

    ROM_IntEnable(USB_UART_INT);

    }

    The ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD)  function is already written before the usb initialization because another pin of GPIOD is used as an adc pin type.

  • You repeat enabling the clock for the GPIOE

    Akira Mitsui said:
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
    ROM_GPIOPinTypeUART(GPIO_PORTE_BASE, GPIO_PIN_1);
    ROM_GPIOPinTypeUART(GPIO_PORTE_BASE, GPIO_PIN_0);

    Also, after enabling the clock you need to wait at least 3 system clock before accessing the peripheral registers, i advise using SysCtlDelay(3) after the SysCtlPeripheralEnable since you use GPIOPinTypeUART right away

  • Hello Akira,

    As Luis mentioned the back to back GPIOE Clock enable and GPIO register access may be the cause of the Fault. Please check the FAULTSTAT and FAULTADDR register to see what is the fault source.

    Also the code may still not work as the UART pins have not been configured. What is missing is GPIOPinConfigure API Call for UART-7 TX and RX pins to be configured for UART function,

    Regards

    Amit

  • Ok, thank you guys for the advices, I've tried putting the little delay after enabling the GPIOE and before accessing the registers. I deleted the double function and now there is just one. Also, I wrote the GPIOPinConfigure for Tx and Rx pins. With all the modifications, the fault still triggers and I end up in the FaultISR();

    I took a look at the datasheet where it says that the FAULTSTAT register is 0xE000ED28, when debbuging I put a breakpoint in the FaultISR() function, read the register and I got 0x00000200, which if I'm not mistaken, points an "Imprecise Data Bus Error", but I don't understand what does it mean and how to fix it?

    Thanks.

  • Hello Akira,

    To debug an Imprecise data bus error, there is a good application note for LM3S (applicable to TM4C).

    http://www.ti.com/lit/pdf/spma043

    Regards

    Amit

  • Ok I've checked the application note and realized actually that the error I'm getting is not and Imprecise Data Bus Error, but an Invalid State Usage Fault.

    Reading the datasheet for description it says: 

    "The processor has attempted to execute an instruction that makes illegal use of the EPSR register. When this bit is set, the PC value stacked for the exception return points to the instruction that attempted the illegal use of the Execution Program Status Register (EPSR) register."

    "Attempting to use an instruction set other than the Thumb instruction set, or returning to a non load-store-multiply instruction with ICI continuation."

    So, sorry for the ignorance again but I'm very new at this and don't know what the EPSR or ICI or Thumb instruction is. Also when I'm debugging and enter the infinite loop in FaultISR(), I look at the PC value as the description says to go to the instruction that causes the error, but my PC value points at the FaultISR function itself.

    Another question, how can I know the address where my SP is?or more likely how can I know if there is stack overflow or stack corruption?. I'm using IAR Embedded Workbench.

    Thanks.

  • Hello Akira,

    The SP register holds the address where the current Stack Pointer is pointing to in SRAM.

    To debug this first you need to find the piece of code which causes this. Then put a break point before the code and step debug in ASM to see what and why it is executing in a manner to cause a Fault

    Regards

    Amit

  • Hello Amit, I did what you say and find out that it goes to the FaultISR function while executing the command:

    SysCtlDelay(40000000);

    which is at the end of all my initializations and just before my main loop.

    First of all, when i run the code commenting the function USBDCDCInit(0, &g_sCDCDevice); it runs and works perfectly, but when i use that function it goes to the fault handler while been in the delay several lines after.

    So i've commented the delay line and tested and for my surprise it worked.

    I have no idea why that delay can cause a fault, having in mind that it didn't when the USBDCDCInit API was commented, but maybe you can give me an explainable reason so I can avoid it in the future. I will test it a couple days more to make sure the bug is gone, but for now I'm happy because it is working =)

    Many thanks for the help!!

    By the way, when I connect my device to the computer it recognizes as "Stellaris USB serial port (COM9)", i wonder if it is possible to change the port name or it's not editable?

  • Hi Akira,

    If you are using a Windows OS you can change the port name in the device manager (right clock "My Computer", select manage and in the window  that pops up select the "Device manager node in the left screen. in the Right pane, goto the "Ports" item, find your port, right click it and select "properties". This part varies per device, but for most devices there's a "Port Settings" tab where you can select "Advanced..." and in that dialog you can select a COM port number. Make sure you don't use a port of another plugged in device. 

    For your SysCtlDelay(...) issue: like suggested by another post, step through the assembly and see if you can find out what is causing your issue.  Perhaps SysCtlDelay() is dependent on another system component which is not initialized....hard to say. Check the registers R0, R1, R2, R12, PC, SP and LR as the document "spma043_ARM_Faults.pdf" explains. This doc is very well written IMHO and explains errors at a very basic level.

    Cheers,

    Dirk