AnsweredAssumed Answered

BF706 GPIO interrupt issue

Question asked by Daniel2 on Jan 10, 2017
Latest reply on Jan 11, 2017 by Daniel2

I am very new in Blackin programming and enconuntered some issues when I started my first program usin BF706 EZ kit mini. My CCES vesion is 1.1.1.0

1. when i create a project, and only add-ins Startup Code/LDF(1.0.0) in my project. using default setting. 

there is only  adi_initComponents();  function in Main(); but when i debug the program, below error occured. I don't know the utility of this function, i  can only delected this funtion for my futher test.

2. I add    " printf("printf test "); "  ,of couse add  #include <stdio.h> at beginning. i supposed that the string will appear in console window when i debug it, but the string not occur.

3. I want to test GPIO interrupt, and added a breakpoint at gpioCallback function. I supposed that when i push the button, program will access callback function,but it seem not. I check the register, the PINT1_REQ has been set when i push the button, but didn't trigger interruption.

below is the code.

 

#include <services/gpio/adi_gpio.h>

#define BUTTON_INT ADI_GPIO_PIN_INTERRUPT_1

#define GPIO_MEMORY_SIZE (ADI_GPIO_CALLBACK_MEM_SIZE*1)

static uint8_t gpioMemory[GPIO_MEMORY_SIZE];

 

void gpioCallback(ADI_GPIO_PIN_INTERRUPT ePinInt, uint32_t Data, void *pCBParam)
{
 if (ePinInt==BUTTON_INT)
 {
   if (Data & ADI_GPIO_PIN_2)
          {
              //push button 1 - toggle LED
              adi_gpio_Toggle(ADI_GPIO_PORT_C, ADI_GPIO_PIN_3);
          }
 }

}

 

int main(void)

{

 uint32_t gpioMaxCallbacks;
 ADI_GPIO_RESULT result;

 result = adi_gpio_Init(
            (void*)gpioMemory,
            GPIO_MEMORY_SIZE,
            &gpioMaxCallbacks);

  //  adi_initComponents();

  result = adi_gpio_SetDirection(
    PORT_C,
    ADI_GPIO_PIN_2,
    ADI_GPIO_DIRECTION_INPUT); //Set PC02 as button input

  result = adi_gpio_SetDirection(
    PORT_C,
    ADI_GPIO_PIN_3,
    ADI_GPIO_DIRECTION_OUTPUT); //Set PC03 as LED output


  result = adi_gpio_SetPinIntEdgeSense(
      BUTTON_INT,
      ADI_GPIO_PIN_2,
      ADI_GPIO_SENSE_RISING_EDGE);

 

     result = adi_gpio_RegisterCallback(
        BUTTON_INT,
         ADI_GPIO_PIN_2,
        gpioCallback,
        (void*)0);

 

     result = adi_gpio_EnablePinInterruptMask(
        BUTTON_INT,
        ADI_GPIO_PIN_2,
           true);

     uint32_t data;
  while(1)
  {
   adi_gpio_GetData(PORT_C,&data);
   if (data & ADI_GPIO_PIN_2)
         adi_gpio_Set(PORT_C,ADI_GPIO_PIN_3);

       else
    adi_gpio_Clear(PORT_C,ADI_GPIO_PIN_3);

  }

return ;

}

Outcomes