Quantcast
Channel: Processors forum - Recent Threads
Viewing all articles
Browse latest Browse all 17527

C6748 LCDK GPIO Interrupt service routine

$
0
0

Hello.

I possess C6748 LCDK board, CCS5v3 and bios_c6sdk_02_00_00_00.

I don ´t have much experiences with LCDK and c.

I modifyed gpio example to connect LEDs with switches. It works.

Now I wish to connect a led with a pushbutton.

My goal is: when I push button for first time, the led is off.

When I push it for second time, the led is on and so on.

I initialize GPIO and wrote this code for led D4 and pushbutton S3:

while(1){

x=GPIOPinRead(SOC_GPIO_0_REGS,38);
        if (x==GPIO_PIN_LOW){
            y++;
            if(y==1){
            GPIOPinWrite(SOC_GPIO_0_REGS, 110, GPIO_PIN_LOW);
            }
            if (y==2){
            GPIOPinWrite(SOC_GPIO_0_REGS, 110, GPIO_PIN_HIGH);
            y=0;
            }

}

It works, but sometimes the button doesn´ t react on pushing.

I thought, that, it could be solved by interrupt routine:

  interrupt void Button_S3_interrupt(void){
      if(GPIOPinIntStatus(SOC_GPIO_0_REGS, 6)==GPIO_INT_PEND){
          GPIOPinIntClear(SOC_GPIO_0_REGS, 6);
          y++;
            if(y==1){
                      GPIOPinWrite(SOC_GPIO_0_REGS, 110, GPIO_PIN_LOW);
                      }
            if(y==2){
                      GPIOPinWrite(SOC_GPIO_0_REGS, 110, GPIO_PIN_HIGH);
                      y=0;
                      }


      }


  }

But D4 is always off.

I don´t exactly know, how should Interrupt service routine for C6748 look like and where to specify the interrupt number. Could you write for me the head of typical interrupt service routine and what should be general done in its body?

Thank you.

Petr Duga


Viewing all articles
Browse latest Browse all 17527

Trending Articles