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.

How to Initialize and enable external interrupts and read data from GPIO



HI All,

Hardware: DRV8312base board, F2805X controller card

I am trying to create an external interrupt and  read data from GPIO. Then trigger motor to run with different config.

But I ran into a problem where I cannot read data from GPIO correctly. Always reading 0x00 from GPIO, (I sent 0x08)  

I am afraid that I did something wrong with initialization of external interrupts.

I modified proj_lab01.c--void main(void) as followings:

void main(void)
{
  // Only used if running from FLASH
  // Note that the variable FLASH is defined by the project
#ifdef FLASH
  // Copy time critical code and Flash setup code to RAM
  // The RamfuncsLoadStart, RamfuncsLoadEnd, and RamfuncsRunStart
  // symbols are created by the linker. Refer to the linker files.
  memCopy((uint16_t *)&RamfuncsLoadStart,(uint16_t *)&RamfuncsLoadEnd,(uint16_t *)&RamfuncsRunStart);
#endif

  // initialize the hardware abstraction layer
  halHandle = HAL_init(&hal,sizeof(hal));

  // set the hardware abstraction layer parameters
  HAL_setParams(halHandle,&gUserParams);

  // initialize the interrupt vector table
  HAL_initIntVectorTable(halHandle);

  // enable the EXT interrupts
  HAL_enableExtInts(halHandle);

  // enable global interrupts
  HAL_enableGlobalInts(halHandle);

  // enable debug interrupts
  HAL_enableDebugInt(halHandle);

The interrupt comes in as followings:

interrupt void writeSignalISR(void)
{
static int32_t temp;

HAL_Obj *obj = (HAL_Obj *)halHandle;

if(GPIO_getData(obj->gpioHandle, GPIO_Number_10) == 0)
{
if(ReceiveCommandFlag == 1)
{
HAL_setGpiodirection(halHandle, GPIO_Direction_Input);
temp = GPIO_getPortData(obj->gpioHandle, GPIO_Port_A);
temp &= 0x000000FF;
Command = temp;
DataCounter = 0;
if(Command == 0x08)//FW version
{ //PROD_VER_STUB 0x7E
TransmitData[0] = 0xFF;
TransmitData[1] = 0x80; //0xFE or 0xF4
TransmitData[2] = 0xFF;
GPIO_setPortData(obj->gpioHandle, GPIO_Port_A, TransmitData[DataCounter]);
while(GPIO_getData(obj->gpioHandle, GPIO_Number_8) == 0);//wait for WR=1
HAL_setGpiodirection(halHandle, GPIO_Direction_Output); //GPIO as output
}
else if(Command == 0)//ProductId
{.....................}
// acknowledge the XINT1 interrupt
HAL_acqExtInt(halHandle);

return;
} // end of writeSignalISR() function

I added break point after:

		  HAL_setGpiodirection(halHandle, GPIO_Direction_Input);
		  temp = GPIO_getPortData(obj->gpioHandle, GPIO_Port_A);
		  temp &= 0x000000FF;
		  Command = temp;

Temp always reading 0, it reads 128 sometimes at the beginning, then always read 0 afterward.  I used oscilloscope to check the hardware signals , there is definitely a WRITE signal coming from GPIO. But I am not able to read it correctly from debugged mode.

There are the initIntVectorTable:

//! \brief      Initializes the interrupt vector table
//! \details    Points the ISR to the function mainISR.
//! \param[in]  handle  The hardware abstraction layer (HAL) handle
static inline void HAL_initIntVectorTable(HAL_Handle handle)
 {
  HAL_Obj *obj = (HAL_Obj *)handle;
  PIE_Obj *pie = (PIE_Obj *)obj->pieHandle;


  ENABLE_PROTECTED_REGISTER_WRITE_MODE;

  pie->XINT1 = &writeSignalISR;
  pie->XINT2 = &readSignalISR;

  pie->SCIRXINTA = &sciarxISR;
  pie->SCIRXINTB = &scibrxISR;
  pie->SCIRXINTC = &scicrxISR;

  DISABLE_PROTECTED_REGISTER_WRITE_MODE;

  return;
 } // end of HAL_initIntVectorTable() function

Does anyone know how to fix this problem?