(Bug?)What happens to the processor and USBPHY if you set the bits SFTRST and CLKGATE of CTRL register at the same time?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

(Bug?)What happens to the processor and USBPHY if you set the bits SFTRST and CLKGATE of CTRL register at the same time?

Jump to solution
1,262 Views
mitterha
Senior Contributor I

Hello,

I am trying to deinitialize the USB and USBPHY peripherals after the usb cable got detached from the processor. Because I copied the code from initialization I had the following line of code to stop USBPHY (only changed from clear to set)

USBPHY->CTRL_SET = USBPHY_CTRL_SET_SFTRST_MASK | USBPHY_CTRL_SET_CLKGATE_MASK;

With this line the core shows some unexpected behaviour: IAR EWARM/Jlink SOMETIMES show the following message

pastedImage_1.png

I don't know what the processor is doing if the error happens I had to restart debugging every time.

---- "WORKAROUND"

In the above shown line it does not really make sense to set SFTRST and CLKGATE at the same time because if you set SFTRST the USBPHY clock will be gated automatically.Therefore if you use the following line instead of the line above everything works as expected.

USBPHY->CTRL_SET = USBPHY_CTRL_SET_SFTRST_MASK;

 

What happens to the processor and USBPHY if you set the bits SFTRST and CLKGATE  of USBPHY CTRL register at the same time?

Kind regards,

Stefan

Tags (2)
1 Solution
1,207 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Stefan,

Thank you for your interest in NXP Semiconductor products and
for the opportunity to serve you.
1) What happens to the processor and USBPHY if you set the bits SFTRST and CLKGATE of USBPHY CTRL register at the same time?
-- If the CLKGATE bit works in advance of FIRST, it will cause the error you encountered, as after setting the CLKGATE bit, the USB operation would become disabled and other more register operations will be illegal too.
So the developer should be careful about that.

Have a great day,
TIC

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

View solution in original post

2 Replies
1,208 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Stefan,

Thank you for your interest in NXP Semiconductor products and
for the opportunity to serve you.
1) What happens to the processor and USBPHY if you set the bits SFTRST and CLKGATE of USBPHY CTRL register at the same time?
-- If the CLKGATE bit works in advance of FIRST, it will cause the error you encountered, as after setting the CLKGATE bit, the USB operation would become disabled and other more register operations will be illegal too.
So the developer should be careful about that.

Have a great day,
TIC

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

1,207 Views
mitterha
Senior Contributor I

Hello Jeremy,

thank you for your support! I think it would be good to mention that in the reference manual

pastedImage_1.png

that setting CLKGATE and SFTRST at the same time will result in an error.

Kind regards,

Stefan