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.

about GPT GPIO in C5505 EVM

i configure all the interrupt in DSP/BIOS, i use timer to generate a sync signal output at gpio 11, so it  works and the gpio output a sync signal which is 10 ms 1 and 990 ms 0 until i stop it. i set gpio 10 as a input pin and let it trigerred a interrupt when it encount a rising edge. inside the interrupt routine i let variant count increas 1 when gpio is triggered.however, the gpio only trigger once then the gpio 11 stop to send any sync signal.

Can somebody help me.

 

Best regards

 

reynold

  • Reynold,

    Did you clear the GPIO interrupt flag? You need to clear Interrupt Flag bit for the GPIO10 at 0x1C10 (I/O space) in order to get next interrupt.  

    Regards,

    Peter

  • yes, i  did, with this sentence  CSL_FINSR(hGpio->baseAddr->IOINTFLG1,CSL_GPIO_PIN10,CSL_GPIO_PIN10,CSL_GPIO_BIT_SET);

    but the problem is not about GPIO, because i found out that timer stop to give interrupt when gpio get first interrupt.

     

    Regards

    Renhao

  • Renhao,

    OK. In case you need furhter assistance, please provide details about the problem.  How they are related each other (timer and GPIO pins)? Please help me understand your system, software, and the problem.

    Best Regards,

    Peter Chung

     

  • i use CCS 3.3, i use  my timer to give every 10 ms a interrupt, if this is the first  interrupt from timer, then i will write gpio 11 a high lever, if this is the second interrupt, then i will write gpio a low lever and i will count this interrupt, when this interrupt number reach 100 then i will set it back to 0.so this gpio pin output a synchronized signal with 1s period. and  now i want to use gpio 10 to receive this signal from gpio 11 and count how many times the gpio 11 have high rising edge. because i want to order some rotary sensor which send the pulses to represent how many degree of angle it turns. that is why i want to prepare the software program for it. my code is as following:

    #include <log.h>
    #include <std.h>
    #include <mbx.h>
    #include <sem.h>
    #include <tsk.h>
    #include <math.h>
    //#include <rtdx.h>
    #include <stdlib.h>
    #include <stdio.h>
    #include "csl_gpio.h"
    #include "csl_intc.h"
    #include "csl_gpt.h"
    #include "csl_dma.h"





    #define CSL_TEST_FAILED    (-1)
    #define CSL_TEST_PASSED    (0)
    #define bit8          (0x8)
    #define HIGHMASK                 (0xFFFF)
    /* Global Structure Declaration */
    CSL_GpioObj     GpioObj;
    CSL_GpioObj     *hGpio;
    ioport  volatile Uint16 *iafrReg;


    extern char      buffer2[];
    extern char      buffer3[];
    extern char      *ptr;
    unsigned int count=1;
    unsigned int pulsen=0;
    Uint16 readVal=0;
    extern SWI_Obj writeSDbufferswi;


    /**
     *  \brief  GPT Interrupt Service Routine
     *
     *  \param  none
     *
     *  \return none
     */
    //interrupt void gpt0Isr(void);
    void gpt0Isr(void);

    /**
     *  \brief  Function to use the functionality of GPIO as output pin
     *
     *
     *  \param  none
     *
     *  \return result
     */
    int gpio_output_pin11(void)
    {
        CSL_Status           status;
        CSL_GpioPinConfig    config;

       

        /* Pin muxing for 11 Pin */
     
         CSL_FINST(CSL_SYSCTRL_REGS->EBSR,SYS_EBSR_SP1MODE,MODE2);
         CSL_FINST(CSL_SYSCTRL_REGS->EBSR,SYS_EBSR_PPMODE,MODE1);

        /* Open GPIO module */
        hGpio = GPIO_open(&GpioObj,&status);
        if((NULL == hGpio) || (CSL_SOK != status))
        {
            printf("GPIO_open failed\n");
            return(CSL_TEST_FAILED);
        }
        else
        {
            printf("GPIO_open Successful\n");
        }

        /* Reset the GPIO module */
        GPIO_reset(hGpio);

     

        /** Use GPIO_config API to make PIN11 as output pin */
        config.pinNum    = CSL_GPIO_PIN11;
        config.direction = CSL_GPIO_DIR_OUTPUT;
        config.trigger   = CSL_GPIO_TRIG_CLEAR_EDGE;
        status = GPIO_configBit(hGpio,&config);
        if(CSL_SOK != status)
        {
            printf("test failed - GPIO_configBit\n");
            return(CSL_TEST_FAILED);
        }
        else
        {
            printf("GPIO PIN11 is configured as Output Pin\n");
        }


     /** test GPIO_config API to make PIN10 as input pin */
        config.pinNum    = CSL_GPIO_PIN10;
        config.direction = CSL_GPIO_DIR_INPUT;
        config.trigger   = CSL_GPIO_TRIG_RISING_EDGE;
        status = GPIO_configBit(hGpio,&config);
        if(CSL_SOK != status)
        {
            printf("test failed - GPIO_configBit\n");
            return(CSL_TEST_FAILED);
        }
        else
        {
            printf("GPIO PIN11 is configured as Input Pin\n");
        }

        status = GPIO_enableInt(hGpio,CSL_GPIO_PIN10);
        if(CSL_SOK != status)
        {
            printf("test failed- GPIO_enableInt\n");
            return(CSL_TEST_FAILED);
        }
        /* Clear any pending Interrupt */
       // IRQ_clear(GPIO_EVENT);

     

         /* Enabling Interrupt */
        IRQ_enable(GPIO_EVENT);
      
    return(CSL_TEST_PASSED);
    }

     /* GPT Interrupt Service Routine when timer give every 10 ms a interrupt */
    void gpt0Isr(void)

       
     static unsigned int trigger = 0;

       
        if (trigger==0)
        {           if (count<=14)               
            CSL_FINSR (hGpio->baseAddr->IOOUTDATA1,CSL_GPIO_PIN11,CSL_GPIO_PIN11,1);                                                        
         }    
        else if(trigger==1)
        {
            CSL_FINSR (hGpio->baseAddr->IOOUTDATA1,CSL_GPIO_PIN11,CSL_GPIO_PIN11,0);
        }
     
         trigger++;

        if (trigger>=100)
        {
        trigger=0;
        if (count>=3&&count<=14)
        /* Post a softwrawe interrupt to write the last second sensor data to SD card */
        SWI_post(&writeSDbufferswi);
       
        if (count%2==0)
        ptr = buffer2;
        else
        ptr = buffer3;
        count++;
         }

    /*     iafrReg = (ioport  volatile Uint16 *)CSL_IAFR_REGS;                */
    /*        (*iafrReg) = CSL_IAFR_TIMER_FLAG_0_RESETVAL;                   */
    /*      IRQ_clear(TINT_EVENT);                                         */
         
    }
                                
    void GPIOrotaryencoder(void)
    {
    pulsen++; 
    //CSL_FINSR (hGpio->baseAddr->IOINDATA1,CSL_GPIO_PIN10,CSL_GPIO_PIN10,0);

        /* IRQ_enable(TINT_EVENT);                                              */
      /*     iafrReg = (ioport  volatile Uint16 *)CSL_IAFR_REGS;                  */
    /*          (*iafrReg) = CSL_IAFR_TIMER_FLAG_0_RESETVAL;                     */                      
    /*      IRQ_clear(TINT_EVENT);                                              */
    //IRQ_clear(TINT_EVENT);
       
    //GPIO_clearInt(hGpio,CSL_GPIO_PIN10);
    CSL_FINSR(hGpio->baseAddr->IOINTFLG1,CSL_GPIO_PIN10,CSL_GPIO_PIN10,CSL_GPIO_BIT_SET);
       
       


        /* Enable CPU Interrupts */
    /*     IRQ_globalEnable();        */
    /*                             */
    /*                             */
    /*     IRQ_enable(TINT_EVENT);       */
    }

  • Renhao,

    Thanks for your input. Could you please zip up your entire project and send it to me? I will check it with the C5515EVM. 

    Regards,

    Peter Chung



  • Hey Peter,

    Thanks, i already solve the problem, i forgot to specify the HWI dispatch in DSPBIOS configuration tool. but i think i will still encount problem later, because i want to get the data from three different kinds of  sensors for every second,  2 acceleroemter, one rotary and one gyroscope, so when i encount any further problem and can not sovle it. then i will still need your help.

    Best regards

    Renhao

  • Hey Peter,

    there is one new problem, i use gpio 11 to output a 1s period sync signal for my accelerometer, and use gpio 10 to get the TTL signal from Rotary encoder,  when i get the interrupt from gpio 10, i want to record the exact time of the interrupt inside this second, then i have to use some function to get the number from count down register. The normal function name is listed as follow:

     @n@b GPT_getCnt
     *
     *   @b Description
     *   @n This function is to get condown value from countdown register

    however, i have to use DSP/BIOS, so i configured the timer in the configuration tool, and i tried to use DSP/BIOS API function "period = CLK_getprd()", however, this is not the right one. Do you have any good idea to keep the time record?

     

    Best regards

    Renhao

  • Renhao,

     

    I am sorry for late response. I have been on business trip + vacaion, and come back today.  The C5505 has RTC registers. I think you can read those registers in the GPIO isr to measure the current time, or you can use RTC interrupt to maintain a separate counter, which you can read in the gpio isr. Do you think it is going to work?

    Here is the link for the RTC User's Guide.

    http://focus.ti.com/lit/ug/sprufx2/sprufx2.pdf

     

    Regards,

    Peter Chung

     

  • Hey Peter

    No problem, i was also in 10 days vacation trip,read the register wont be the solution for my case, because i configure the timer in DSP/BIOS, but other timer can be use for the time measurement.

    Thanks for your response

    Regards

     

    Renhao

  • hey Peter,

    i encounter some new problem, i will repeat the whole mechanism here.   i fixed accelerometer and rotary encoder on some rotating arm, the accelerometer already programmed by some other guy, i only need to connect it with UART interface on C5505, it will send 792 byte per second through interrupt model to the FIFO buffer of  UART, the fifo buffer's trigger lever is 14 bytes. because this accelerometer need a sync signal around 1 s, so i use gpio 11 to send the sync to the accelerometer with the time period which is configured in DSP/BIOS through period function . when the arm moves, the rotary encoder will generate quadratic wave through channel a and channel b, i used gpio pin 6 and gpio pin 10 to get those quadratic wave through interrupt mode when i get those data, i will use RTC to put current time stamp for it.  The tik tak buffer (buffer 1 and buffer 2) are used to in turns storage the current data within one second. when i storage this current data in buffer 1 in this second, then i will send the previous data which is in buffer 2 through DMA controller to SD card. i normally record 24 second data and storage it as binary file in SD card.   however, this program not always work. when i run the program, it may work 1 to 2 times, it will stop send sync signal to acceleroemter within 24 second in other failure case.

    thanks for your kind reply

    Best reagrds

     

    Renhao

     

     

     

     

     

  • Renhao,

    Do you clear GPIO interrupt flags and DMA interrupt flasg properly at every time? You don't need to clear the flags in IFR register but you have to clear the flags in DMA interrupt flag register (at 0x1C30 I/O space) and GPIO interrupt flag register (at 0x1C10 and 0x1C11, I/O space).

    Thanks,

    Peter Chung

  • Hey Peter,

     

    i cleared the GPIO flags,  using  CSL_FINSR(hGpio->baseAddr->IOINTFLG1,CSL_GPIO_PIN10,CSL_GPIO_PIN10,1);  CSL_FINSR(hGpio->baseAddr->IOINTFLG1,CSL_GPIO_PIN9,CSL_GPIO_PIN9,1);

    CSL_FINSR(hGpio->baseAddr->IOINTFLG1,CSL_GPIO_PIN6,CSL_GPIO_PIN6,1);

    now i also correct DMA interrupt flags,

        CSL_FINST(CSL_SYSCTRL_REGS->DMAIFR, SYS_DMAIFR_DMA0CH0IF, SET);
        CSL_FINST(CSL_SYSCTRL_REGS->DMAIFR, SYS_DMAIFR_DMA1CH0IF, SET);

    but it still not always work. i dont think that it is because of the flags, because it sometimes worked (20 percent), othertimes it just stop there.

     

     

    Best regards

     

    Renhao

  • Hey Peter

     

    i think its somehow related to the UART reception, because, when i pluged out the interface of the accelerometer, that means no data is receiving from UART, then this program always running till end. but i can not find where is the problem.

     

    Best regards

     

    Renhao

  • One more thing, i set the FIFO buffer 1 byte triggered at the very beginning, it always running till end, however, when the rotary encoder rotates more quickly, that means the rotary encoder will give more interrupt at each 1 second, then the data from accelerometer can not be completely received by DSP, however, it always runs till end. then i changed this trigger lever to 14 byte, no matter how quick i rotate the rotary encoder, i always can get the data completely from accelerometer, but the new problem is coming out that the program can not always runs to the end.