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.

LM4f120 launchpad FaultISR issue

I have modified uart echo example for communicate with gps module . when the data recieved,mcu enters FaultISR ? what is the problem?

 

here is my code

 

#include "inc/hw_ints.h"

#include "inc/hw_memmap.h"

#include "inc/hw_types.h"

#include "driverlib/debug.h"

#include "driverlib/fpu.h"

#include "driverlib/gpio.h"

#include "driverlib/interrupt.h"

#include "driverlib/pin_map.h"

#include "driverlib/rom.h"

#include "driverlib/sysctl.h"

#include "driverlib/uart.h"

#include "string.h"

 

//*****************************************************************************

//

//! \addtogroup example_list

//! <h1>UART Echo (uart_echo)</h1>

//!

//! This example application utilizes the UART to echo text.  The first UART

//! (connected to the USB debug virtual serial port on the evaluation board)

//! will be configured in 115,200 baud, 8-n-1 mode.  All characters received on

//! the UART are transmitted back to the UART.

//

//*****************************************************************************

 

 

//*****************************************************************************

//

// The error routine that is called if the driver library encounters an error.

//

//*****************************************************************************

#ifdef DEBUG

void

__error__(char *pcFilename, unsigned long ulLine)

{

}

#endif

 

char RxBuf[128];

char TxBuf[128];

char GpsData[128];

char RxTemp;

 

unsigned long WAdr=0;

unsigned long Sayi;

 

//*****************************************************************************

//

// The UART interrupt handler.

//EXTERN  UARTIntHandler

//*****************************************************************************

void

GPSInt(void)

{

    unsigned long ulStatus,GpsStat;

 

    //

    // Get the interrrupt status.

    //

                GpsStat=ROM_UARTIntStatus(UART5_BASE, true);

                ulStatus = ROM_UARTIntStatus(UART0_BASE, true);

               

                if(GpsStat)   //int. kaynagi gps mi?

                {

                               ROM_UARTIntClear(UART5_BASE, GpsStat);

                               RxTemp=ROM_UARTCharGetNonBlocking(UART5_BASE);

                              

                               switch(WAdr){

                              

                               case 0 :

                                               if (RxTemp==0x24){

                                                               RxBuf[WAdr]=RxTemp;

                                                               WAdr++;}

                               break;

                                

                               case 1:

                                               if (RxTemp==0x47){

                                                               RxBuf[WAdr]=RxTemp;

                                                               WAdr++;}

                                               else

                                                               WAdr=0;

                               break;

                                                              

                               case 2:

                                               if (RxTemp==0x50){

                                                               RxBuf[WAdr]=RxTemp;

                                                               WAdr++;}

                                               else

                                                               WAdr=0;

                               break;

                                                                             

                               case 3:

                                               if (RxTemp==0x47){

                                                               RxBuf[WAdr]=RxTemp;

                                                               WAdr++;}

                                               else

                                                               WAdr=0;

                               break;

                                                              

                               case 4:

                                               if (RxTemp==0x47){

                                                               RxBuf[WAdr]=RxTemp;

                                                               WAdr++;}

                                               else

                                                               WAdr=0;

                               break;

                                                              

                               default :

                                               if (RxTemp==0x24){

                                                               strcpy(GpsData,RxBuf);

                                                               Sayi=WAdr-1;

                                                               WAdr=0;

                                                               GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, GPIO_PIN_2);

                                                               SysCtlDelay(SysCtlClockGet() / (1000 * 3));

                                                               GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 0);}

                                               else{                                                    

                                                               RxBuf[WAdr]=RxTemp;

                                                               WAdr=(WAdr+1)&0x7F;}

                                                               break;

                                                                              }

 

    }

}

 

//*****************************************************************************

//

// Send a string to the UART.

//

//*****************************************************************************

void

UARTSend(const unsigned char *pucBuffer, unsigned long ulCount)

{

    //

    // Loop while there are more characters to send.

    //

    while(ulCount--)

    {

        //

        // Write the next character to the UART.

        //

        ROM_UARTCharPutNonBlocking(UART0_BASE, *pucBuffer++);

    }

}

 

//*****************************************************************************

//

// This example demonstrates how to send a string of data to the UART.

//

//*****************************************************************************

int

main(void)

{

    //

    // Enable lazy stacking for interrupt handlers.  This allows floating-point

    // instructions to be used within interrupt handlers, but at the expense of

    // extra stack usage.

    //

    ROM_FPUEnable();

    ROM_FPULazyStackingEnable();

 

    ROM_SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |

                       SYSCTL_XTAL_16MHZ);

 

    //

    // Enable the GPIO port that is used for the on-board LED.

    //

    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);

 

    //

    // Enable the GPIO pins for the LED (PF2). 

    //

    ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2);

 

    //

    // Enable the peripherals used by this example.

    //

    //ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);

                               ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1);

                              

    //ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);

                               ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);

 

 

 

    //

    // Set GPIO A0 and A1 as UART pins.

    //

    //GPIOPinConfigure(GPIO_PA0_U0RX);

    //GPIOPinConfigure(GPIO_PA1_U0TX);

    //ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);

                              

                               GPIOPinConfigure(GPIO_PB0_U1RX);

    GPIOPinConfigure(GPIO_PB1_U1TX);

    ROM_GPIOPinTypeUART(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1);

 

    //

    // Configure the UART for 115,200, 8-N-1 operation.

    //

    //ROM_UARTConfigSetExpClk(UART0_BASE, ROM_SysCtlClockGet(), 921600,

                            //(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |

                            // UART_CONFIG_PAR_NONE));

                              

                               ROM_UARTConfigSetExpClk(UART1_BASE, ROM_SysCtlClockGet(), 9600,

                           (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |

                             UART_CONFIG_PAR_NONE));

 

    //

    // Enable the UART interrupt.

    //

    //ROM_IntEnable(INT_UART0);

                               ROM_IntEnable(INT_UART1);

    //ROM_UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT);

                               ROM_UARTIntEnable(UART1_BASE, UART_INT_RX);

    //

    // Enable processor interrupts.

    //

    ROM_IntMasterEnable();

    //

    // Prompt for text to be entered.

    //

    //UARTSend((unsigned char *)"OK\r\n", 4);

 

    //

    // Loop forever echoing data through the UART.

    //

    while(1)

    {

    }

}

 

  • Hi,

    It seems you are not decided which UART to use - you play with UART0, UART1, UART5! (see this line:  ROM_UARTIntClear(UART5_BASE, GpsStat);). Take care - you must place (change) the vector interrupt in startup_xxx.c file (did you made the change?).

    Petrei 

  • i found the problem;

    ulStatus = ROM_UARTIntStatus(UART0_BASE, true);

    this can't be in USART1ISR . now it's working fine. thanks for your help.

  • Now,i can't get the whole string properly. i can get only first 26 char of string.

    #include "inc/hw_ints.h"
    #include "inc/hw_memmap.h"
    #include "inc/hw_types.h"
    #include "driverlib/debug.h"
    #include "driverlib/fpu.h"
    #include "driverlib/gpio.h"
    #include "driverlib/interrupt.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/rom.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/uart.h"
    #include "string.h"

    #ifdef DEBUG
    void
    __error__(char *pcFilename, unsigned long ulLine)
    {
    }
    #endif

    char RxBuf[128];
    char TxBuf[128];
    char GpsData[128];
    char RxTemp;

    unsigned long WAdr=0,RAdr=0,GpsReady=0;
    unsigned long Num;


    void GPSInt(void)
    {
        unsigned long GpsStat;

        GpsStat=ROM_UARTIntStatus(UART1_BASE, true);
        
        if(GpsStat)   //int. kaynagi gps mi?
        {
            ROM_UARTIntClear(UART1_BASE, GpsStat);
            RxTemp=ROM_UARTCharGetNonBlocking(UART1_BASE);
            
            switch(WAdr){
            
            case 0 :
                if (RxTemp==0x24){
                    RxBuf[WAdr]=RxTemp;
                    WAdr++;}
            break;
            
            case 1:
                if (RxTemp==0x47){
                    RxBuf[WAdr]=RxTemp;
                    WAdr++;}
                else
                    WAdr=0;
            break;
                    
            case 2:
                if (RxTemp==0x50){
                    RxBuf[WAdr]=RxTemp;
                    WAdr++;}
                else
                    WAdr=0;
            break;
                        
            case 3:
                if (RxTemp==0x47){
                    RxBuf[WAdr]=RxTemp;
                    WAdr++;}
                else
                    WAdr=0;
            break;
                    
            case 4:
                if (RxTemp==0x47){
                    RxBuf[WAdr]=RxTemp;
                    WAdr++;}
                else
                    WAdr=0;
            break;
                    
            default :
                if (RxTemp==0x24){
                    strcpy(GpsData,RxBuf);
                    Num=WAdr-1;
                    WAdr=0;
                    GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, GPIO_PIN_2);
                    SysCtlDelay(SysCtlClockGet() / (1000 * 3));
                    GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 0);
                  GpsReady=1;}
                else{                
                    RxBuf[WAdr]=RxTemp;
                    WAdr=(WAdr+1)&0x7F;}
                    break;
                        }

        }
    }



    void UARTSend(const unsigned char *pucBuffer, unsigned long ulCount)
    {

        while(ulCount--)
        {

            ROM_UARTCharPutNonBlocking(UART0_BASE, *pucBuffer++);
        }
    }


    int main(void)
    {

        ROM_FPUEnable();
        ROM_FPULazyStackingEnable();
        ROM_SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
                           SYSCTL_XTAL_16MHZ);

        ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
        ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2);
        ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
            ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1);
        ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
            ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
        GPIOPinConfigure(GPIO_PA0_U0RX);
        GPIOPinConfigure(GPIO_PA1_U0TX);
        ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
            GPIOPinConfigure(GPIO_PB0_U1RX);
        GPIOPinConfigure(GPIO_PB1_U1TX);
        ROM_GPIOPinTypeUART(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1);
        ROM_UARTConfigSetExpClk(UART0_BASE, ROM_SysCtlClockGet(), 921600,
                                (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
                                UART_CONFIG_PAR_NONE));
            
            ROM_UARTConfigSetExpClk(UART1_BASE, ROM_SysCtlClockGet(), 9600,
                               (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
                                 UART_CONFIG_PAR_NONE));
        ROM_IntEnable(INT_UART0);
            ROM_IntEnable(INT_UART1);
        ROM_UARTIntEnable(UART0_BASE, UART_INT_RT);
            ROM_UARTIntEnable(UART1_BASE, UART_INT_RX);
        ROM_IntMasterEnable();
        UARTSend((unsigned char *)"OK\r\n", 4);
            
            
        while(1)
        {
                if(GpsReady)
                {
                    UARTSend((unsigned char *)GpsData,Num);
                    GpsReady=0;}
        }
    }

  • Hi,

    Maybe it is your code: 

    default :
                if (RxTemp==0x24){
                    strcpy(GpsData,RxBuf);
                    Num=WAdr-1;
                    WAdr=0;
                    GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, GPIO_PIN_2);
                    SysCtlDelay(SysCtlClockGet() / (1000 * 3));
                    GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 0);
                  GpsReady=1;}

    Anyway, some of your intents should be shown to be sure of this. Maybe the code does not implement your real intent - seems the 0x24, 0x47, ox50 to be some markings and in this case should be treated in other way - if I am guessing well).

    Petrei

  • Switch case part is using for parse nmea messages and it works fine. When i debug,i can see correct values of gps message . My problem is transmiting these values by uart0.

    For example;

      Actual message transmited by gps module: $GPGGA,192253.00,4013.62240,N,02850.95544,E,1,04,5.54,99&2,M,38.2,M,,*6B

      Recieved message from mcu also same but at the PC side message is :$GPGGA,192253.00,4013.62240. When i decrease the baud rate of PC communication(by uart0),recieved message is getting shorter.

  • berat kaya1 said:
    void UARTSend(const unsigned char *pucBuffer, unsigned long ulCount)
    {

        while(ulCount--)
        {

            ROM_UARTCharPutNonBlocking(UART0_BASE, *pucBuffer++);
        }
    }

    The description of the ROM_UARTCharPutNonBlocking function is:

    Writes the character ucData to the transmit FIFO for the specified port. This function does not block, so if there is no space available, then a false is returned, and the application must retry the function later.

    The UARTSend function doesn't check the result from ROM_UARTCharPutNonBlocking; if the UART FIFO becomes full then the UARTSend will discard the trailing part of the pucBuffer.

  • How can I check FIFO full or empty?

  • berat kaya said:
    How can I check FIFO full or empty?

    For transmit the ROM_UARTSpaceAvail function returns true if there is space available in the transmit FIFO or false if there is no space available in the transmit FIFO.

    For receive the ROM_UARTCharsAvail function returns true if there is data in the receive FIFO or false if there is no data in the receive FIFO.

  • Don't call the non-blocking version of the function.  Why are you calling it instead of the regular function that should be called in almost all cases?

    Over and over I see posts from people that are bitten by calling the non-blocking functions and not checking the return value.  In every case I've seen the poster would have been better off calling the regular function instead.