Other Parts Discussed in Thread: HALCOGEN
Hello,
I have a board with a debug LED in ECLK pin. I configured it as GPIO, and I configured it properly in HALCoGen. I did it properly because I read other threads in the forum and if I set the default value to 0 or 1 and recompile, the LED is ON or OFF, so it seems the GPIO functionality is ok.
My problem is that system resets when I try to modify the pin logic level within the code.
I tried to use gioSetBit(systemPORT, 0, xxx), as states in the HAL, but it failed. I then tried to directly access to systemREG1->SYSPC4 as HAL does in systemInit, and it failed again.
Is there any configuration I am doing wrong? Is there anything else I should take into account?
<MY CODE>
void setDebugLed(uint8_t led, uint32_t on)
{
if(led == 1)
{
gioSetBit(LED_DEBUGOUT1_PORT, LED_DEBUGOUT1_PIN, on);
}
else if(led == 2)
{
if(on != 0)
gioSetBit(systemPORT, 0, 1);
else
gioSetBit(systemPORT, 0, 0);
}
}
</MY CODE>
<CODE GENERATED BY HAL>
/* USER CODE BEGIN (24) */
/* USER CODE END */
/** - set ECLK pins functional mode */
systemREG1->SYSPC1 = 0U;
/** - set ECLK pins default output value */
systemREG1->SYSPC4 = 1U;
/** - set ECLK pins output direction */
systemREG1->SYSPC2 = 0U;
/** - set ECLK pins open drain enable */
systemREG1->SYSPC7 = 0U;
/** - set ECLK pins pullup/pulldown enable */
systemREG1->SYSPC8 = 1U;
/** - set ECLK pins pullup/pulldown select */
systemREG1->SYSPC9 = 0U;
/** - Setup ECLK */
systemREG1->ECPCNTL = (uint32)((uint32)0U << 24U)
| (uint32)((uint32)1U << 23U)
| (uint32)((uint32)(8U - 1U) & 0xFFFFU);
/* USER CODE BEGIN (25) */
/* USER CODE END */
</CODE GENERATED BY HAL>