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.

GIO Library

Hello,

I would like to use the GIO library function [ gioToggleBit ] to toggle the LED's 10 and 11 of the DRV8301-RM48-Kit.

But I can't identify the GIO terminals capable of generating an interrupt.

I would like to know if this is possible.

Here is my function:

/** @fn void gioToggleBit(gioPORT_t *port, uint32_t bit)
*   @brief Write Bit
*   @param[in] port pointer to GIO port:
*              - gioPORTA: PortA pointer
*              - gioPORTB: PortB pointer
*   @param[in] bit number 0-7 that specifies the bit to be written to.
*              - 0: LSB
*              - 7: MSB
*
*   Toggle a value to the specified pin of the given GIO port
*/
void gioToggleBit(gioPORT_t *port, uint32_t bit)
{
/* USER CODE BEGIN (10) */
/* USER CODE END */

    if ((port->DIN & (1 << bit)) != 0)
    {
        port->DCLR = 1 << bit;
    }
    else
    {
        port->DSET = 1 << bit;
    }
}

Kind Regards

  • Hi Ah,

    LED10 is connected to GIOA5 and LED11 is connected GIOA0. So you will do something like

    /* release GIO from reset */
    gioREG->GCR0 = 1U;
    /* Set GIO port pin direction output for GIO portA bit 0 and 5 */
    gioSetDirection(gioPORTA, 0x21);

    gioToggleBit(gioPORTA,0); // Toggle GIOA[0];
    gioToggleBit(gioPORTA,5); // Toggle GIOA[5];
  • Hi Charles,

    Thank you very much for your answer.
    If I want to use the Start and Stop buttons to turn the LED's ON and OFF, how can I do that?

    Best Regards,
  • Hi Ah,

     The START is connected to NHET1[14] and STOP is connected to GIOA[7] per schematic. For GIOA[7] you can generate a GIO interrupt upon a detection of your specified edge. Once you are in the GIO ISR you can toggle the LED. See the schematic that the STOP is first connected to a mux/demux device that selects between either GIOA[7] or NHET1[18]. To select the GIOA[7] you will need to set GIOB[0]=1 to select the GIOA[7].  See schematic below.

      It will be a bit more complicated for the START. The START is connected to NHET1[14]. It is possible to also generate an NHET interrupt upon detection of your specified edge on NHET1[14] pin but you will need to write a NHET program to do so. 

  • Hi Charles,

    I did that in my Program, but when I start debugging (with Code Composer Studio) both LED's are always OFF. Do I need to configure something ?

    Kind Regards
  • HI Ah,

    Not sure what happens.

    Can you check if the JP2 on the EVM board is connected?

    Place a breakpoint at gioToggleBit(gioPORTA,0);. Go to the register window, under gioA module can you check if the DOut register changes states each time you come to the breakpoint? is the direction set to output?

    Can you also try the following to set the GIOA[0] instead of toggle. I wonder if you are in a tight loop and trying to call the gioToggleBit() too quickly before LED is able to light up.

    gioSetBit(gioPORTA, 0, 1); // Set bit-0 to '1'
  • Hi Carles,

    I checked the JP2 and it's already connected.

    I wrote it in the main function of the sys_main.c ,, is it ok or should I write it somewhere else?

    here is also a screenshot of my Registers window:

  • Ah,
    Something is weird. You call gioSetDirection(gioPORTA, 0x21) and this is supposed to set bit0 and bit5 but in your register window it shows 0x00000010 which means that bit4 is set instead. Same problem for gioSetBit().

    First of all, is the register window values you capture for gioA right after you call gioSetDirection(gioPORTA, 0x21)?

    Is it possible somewhere else in your code also write to the GIO module without you knowing? Can you create a watchpoint and watch for any write to 0xFFF7BC34 which is the address for GIODIR. If there is somewhere else that also write to this address then you will know.
  • Hi Charles,

    Thank you very much. now it's working and the LED's are toggled properly.

    But each time I have to set them manually by hand from the Resgisters' window, is it possible to do so automatically after running my program ?

    Could you also please send me the schematic of the pins designation?

    Best Regards
  • Hi Ah,

     It is good to hear that it is somehow working. Are you saying you can only set LED by manually setting the DIR and DOUT in the register window? You should be able to do the same in your code. This is why I asked if you have somewhere else in your code that might have overwritten your intended values. Please use watchpoint to watch any unexpected write to the DIR and DOUT registers.

      Below are the schematic which should already be in your installation directory. 

    5444.MotorWare EVM board 515502~1.PDF

    1425.TMS570LS31x_CNCD_SchematicRevB.pdf