Using MCU_TDI as normal gpio in HAL 2.x

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Frank-Lin
Level 4
Level 4
5 solutions authored 50 sign-ins 10 questions asked

I am using CY8CKIT-062S2-43012 and add a falling edge interrupt on P6_5 (with is MCU_TDI) and facing some problem .
The debug mode is set to SWD in "device configurator"->"system"->"debug", so i think we can usd that pin as normal gpio.

But if i use HAL 2.x, interrupt tigger will fail and i can only used HAL 1.6 to let it work.
If i didn't inital that pin in my code as a gpio, it will be high not low(other pin will be low).

0 Likes
1 Solution

Hi Alen,
We found the main problem.
When we chage to P6_5, we forget to that 

cyhal_gpio_callback_data_t  cb;

been global.

After changing it to global, it works.
Thanks for your help.

View solution in original post

0 Likes
7 Replies
AlenAn14
Moderator
Moderator
Moderator
500 replies posted 100 solutions authored 250 replies posted

Hi @Frank-Lin ,

I tried out the following firmware which you shared with HAL library version 2.1.0 on the  CY8CKIT-062S2-43012 :

	const char Int_Const_Set = 'S';
	cyhal_gpio_init(_Set_Pin,  CYHAL_GPIO_DIR_INPUT,  CYHAL_GPIO_DRIVE_PULLUP, 1); // input  pull high
	cyhal_gpio_callback_data_t  cb;
	cb.callback = Int_IntCallBack;
	cb.callback_arg = (void*)&Int_Const_Set;
	cyhal_gpio_register_callback(_Set_Pin,  &cb);
	cyhal_gpio_enable_event(_Set_Pin,  CYHAL_GPIO_IRQ_FALL, 1, true);


void Int_IntCallBack(void *callback_arg, cyhal_gpio_event_t event) {
  // Toggle LED each time interrupt is detected
Cy_GPIO_Write(CYBSP_LED_RGB_RED_PORT, CYBSP_LED_RGB_RED_NUM,! Cy_GPIO_Read(CYBSP_LED_RGB_RED_PORT, CYBSP_LED_RGB_RED_NUM));
}


This is working as expected i.e. the LED toggle each time there is a fall on the GPIO pin P5_6 (this is opposite to the pin P6_5 that you have used as this pin is not available on the headers on of the eval board)

Can you please try it out with v2.1.0 of the HAL library and see if it is working?

Warm Regards
Alen

0 Likes

Hi Alen,
v2.1.0 is the version i'm using.
I also try v2.0.1, and it fail.
For now, only v1.6.0 can work.

0 Likes
lock attach
Attachments are accessible only for community members.
AlenAn14
Moderator
Moderator
Moderator
500 replies posted 100 solutions authored 250 replies posted

Hi @Frank-Lin ,

Can you please try running the attached firmware and see if you are able to toggle the LED.
Simply connect the GND pin to pin P5_6 on the  CY8CKIT-062S2-43012  development board to see if the LED toggles.

Please follow the import procedure from Project Creator while importing the attached project to your workspace to make sure that the libraries are updated correctly.

Warm Regards
Alen

0 Likes

Hi Alen,
Sorry for not being clear. If i used other pin(P7_5 or P6_2), it works.
But our team put a button on P6_5 (customer board), i 'm trying to let it work on it.

0 Likes
AlenAn14
Moderator
Moderator
Moderator
500 replies posted 100 solutions authored 250 replies posted

Hi @Frank-Lin ,

That makes more sense now but still, I believe there is some issue on your button configuration in hardware.

On the   CY8CKIT-062S2-43012  development board, the pin P6_5 is connected to the JTAG TDI pin on the J11 connector (Pin 8 of the connector).

AlenAn14_0-1656403965634.png

I used the above code and set the pin to P6_5 instead of P5_6 and when I touched a ground wire to pin 8 of J11 connector, I saw the LED toggling ( ISR executing for P6_5 ) same as it was doing when i had set it for P5_6 pin.

Meaning that the HAL library is working correctly even for P6_5 in the v2.1.0 version.

Please check the hardware configuration of your button and also try probing the button pin that connects to the pin P6_5 to see if the line is actually being toggled or not during button press.

Also, initialize the pin as pullup instead of pullupdown as you had done since you are trying to detect the falling edge on the P6_5 pin :

cyhal_gpio_init(_Set_Pin,  CYHAL_GPIO_DIR_INPUT,  CYHAL_GPIO_DRIVE_PULLUP, 1); 

 

Warm Regards
Alen

0 Likes

Hi Alen,
We found the main problem.
When we chage to P6_5, we forget to that 

cyhal_gpio_callback_data_t  cb;

been global.

After changing it to global, it works.
Thanks for your help.

0 Likes
AlenAn14
Moderator
Moderator
Moderator
500 replies posted 100 solutions authored 250 replies posted

Hi @Frank-Lin ,

Glad your issue is resolved and thank you for sharing the solution with the community!

Please feel free to post any queries or issues you may have on Infineon products in the community and we will be happy to help.

Warm Regards
Alen

0 Likes