mindentropy wrote:
BenLunt wrote:
Did you clear bit 20? The hardware may or may not end the reset state until you acknowledge the finish of the reset by writing a '1' to bit 20.
I was not very clear there. PORT1 is the active port that has a USB stick attached. PORT2 is not used and also I don't have a connector to it.
I have
not cleared BIT20 the PRSC bit by writing a 1. In the code pasted I have commented it out. If I
don't set the PRSC bit the values will be
Code:
PORT1: 0x00100103
Correct.
Bit 20 = 1 = Port reset is complete
Bit 8 = 1 = Port has power
Bit 1 = 1 = Port is enabled
Bit 0 = 1 = Device attached
You need to clear bit 20 by writing a 1 to it. However, if you write 0x00100103 to the port, you are now writing a one to bit 0, disabling the port. You must first read the port, mask off the R/O bits and other bits you wish to preserve, then write your value back.
mindentropy wrote:
I am assuming that the BIT2 the PES (Port Enable Status) bit should be set before I continue any further operations.
If I acknowledge the reset by writing a 1 to BIT20 then the status becomes:
Code:
PORT1: 0x00000101
BIT2 (PES) gets cleared for some reason and I am assuming it is wrong. Am I right in my understanding?
Again, what do you write to the port. If you write a 1 to bit 0, you disable the port.
Read of Port 0: 0x00100103
Write to Port 0: 0x00100102
Read of Port 0: 0x00000103
If you write a 1 to bit 0, this tells the controller to disable the port, clearing the enable bit.
You need to read the specifications (or get a
good book, hint, hint) that tells you what each bit in the port register is intended for. A read of a bit does one thing while a write to that bit can have a complete different meaning.
For example, reading bit 9 tells you if you have a Low Speed device attached. However, if you write to this bit (bit 9), you disable power to this port (power switching aside).
Ben