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.

Halcogen 3.05 io pin toggle: gioToggleBit

Other Parts Discussed in Thread: HALCOGEN

Hi,

From gio.c generated by HalcoGen:

void gioToggleBit(gioPORT_t *port, uint32 bit)
{
/* USER CODE BEGIN (10) */
/* USER CODE END */

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

I believe the comparison line should test  port->DOUT  instead port->DIN toggling the data written to the port latch. Reading the pin state can fail the function since the actual pin state can be different form the latch depending on pin configuration and the load.

Regards, Dmitri.  

  • Dmitri,

    The DOUT, DSET and DCLR registers read the last value written to these registers. The DIN register always reflects the state of the input pins. This function generated by HCG does not assume any load condition. It just reads the state of the input pin and tries to drive it to the opposite state.

    Regards, Sunil

  • Hi Sunil,

    Now if the output is configured as open drain the function may stuck in one state if the pin is driven too low. No toggling at all.

    Dmitri.   

  • Hi Dmitri,

    Even for an open-drain output, there will be an external pull-up that will pull the terminal High. This will allow the DIN to read the High level.

    In general, the API functions provided by HALCoGen are assuming "typical" use conditions. Specific applications may have requirements that could make these functions not very useful.

    Regards, Sunil