USBFS Peripheral Not Initializing

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

cross mob
sshersh
Level 3
Level 3
First solution authored 10 replies posted 5 questions asked

Hello, 

I designed a PCB around the CY8C614AAZI-S2F44 which uses USB to talk to a host. As far as I'm aware, this device is not yet supported by PSOC Creator so I've had to use the HAL API directly. The USBDP and USBDM pins on the type-B connector are connected to pins 14_0 and 14_1 respectively. I've hooked the PCB up to my computer to try to communicate and I have an oscilloscope probe between USBDP and ground.

To initialize the peripheral, I tried every combination of the following:

  • Enabling the USB peripheral in the device configurator in modus toolbox
  • Copying the initialization snippet in the HAL documentation
  • Just calling cyhal_usb_dev_connect() without calling cyhal_usb_dev_init()

When I call the initialization function, it returns an error code and the PSOC gets stuck in an infinite loop.  It seems that When I set the USB config in the Device Configurator and only call the cyhal_usb_dev_connect(), some fault occurs and I also get stuck in an infinite loop. In neither case do I see any activity on the USBDP line. 

What am I doing wrong? 

Best

Sam Shersher

0 Likes
3 Replies
Aashita_R
Moderator
Moderator
Moderator
50 likes received 100 solutions authored 250 replies posted

Hi @sshersh ,

Can you please share the USB trace with us? This will help us get an idea of where is it getting stuck?
Also, can you please share the screenshot of the error code which you are facing?

This will hep us get better insights of the issue.

Best Regards,

Aashita

0 Likes

Here is the code I'm calling from main (with USB not configured in the device configurator): 

 

void init_usb(cyhal_usb_dev_t *usb_dev_obj) {
	cy_rslt_t result;
	result = cyhal_usb_dev_init(usb_dev_obj, USBDP, USBDM, NULL);
	if (result != CY_RSLT_SUCCESS) {
		CY_ASSERT(0);
	}
	cyhal_usb_dev_connect(&usb_dev_obj);
}

 

Here is the call stack when the program gets stuck in the fault state:

sshersh_0-1668177735133.png

As I said earlier, there is no scope trace to show you since there's no activity on the USBDP line. 

Unfortunately, the value of result gets optimized out by the compiler so I'm not sure what it is. 

When I configure the USB in the device configurator, I comment out some of the code so it's not initialized twice:

void init_usb(cyhal_usb_dev_t *usb_dev_obj) {
	// cy_rslt_t result;
	// result = cyhal_usb_dev_init(usb_dev_obj, USBDP, USBDM, NULL);
	// if (result != CY_RSLT_SUCCESS) {
	// 	CY_ASSERT(0);
	// }
	// printf("%d", result);
	cyhal_usb_dev_connect(&usb_dev_obj);
}

And here is the call stack in that case:

sshersh_2-1668178832856.png

It seems like either way, the processor gets stuck on Cy_USBFS_Dev_Drv_Enable()

Hope this info helps.

Best, 

Sam

0 Likes

I've also tried following the steps here:

https://infineon.github.io/usbdev/usbfs_dev_api_reference_manual/html/index.html#subsection_qsg_step...

I followed all the steps exactly and the code doesn't compile! The variable USBHID_HW (which I presume is supposed to be set by one of the configuration files) is undeclared. 

It would be really nice if your code actually worked out of the box. Given the immense effort required to do simple things on PSOC6 for custom applications, and the poor documentation and sparse support, I'm heavily considering switching over to a different line of MCU's.  

0 Likes