This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM3354: USB test mode

Guru 15520 points
Part Number: AM3354


Hi,

I have a question about AM335x USB2.0.

I'm trying execute TESTMODE(Test Packet) in Host mode(I'm using AM335x GP EVM).
But it seem there are no signal from D+ and D-.
Also VBUS are always 0V.

My program is no-OS and not using any SDK from TI.
Maybe initialization of USB are long or missing something.

To execute TESTMODE, which registers need to be setup?
I set the clock module register, control module register of USB and then
followed the sequence of TESTMODE(test packet) which are written in TRM(spruh73p) page.2623.

I attached my source file.
If I'm missing any setup of register, please give me advise.

best regards,
g.f.

/*
 * main.c
 */

#define USBSS_SYSCONFIG	(volatile unsigned int*)(0x47400010)

#define USB1_CNTRL_Base 0x47401800

#define USB1_MODE		(volatile unsigned int*)(USB1_CNTRL_Base + 0xE8)

/*USB1 Core Register*/
#define USB1_Base 0x47401C00

#define USB1_PMR 		(volatile unsigned char*)(USB1_Base + 0x01)
#define USB1_TESTMODE 	(volatile unsigned char*)(USB1_Base + 0x0F)
#define USB1_HOSTCSR0 	(volatile unsigned short*)(USB1_Base + 0x12)
#define USB1_ENDPOINT0 	(volatile unsigned int*)(USB1_Base + 0x20)
#define USB1_DEVCTRL 	(volatile unsigned char*)(USB1_Base + 0x60)

#define CM_PER_USB0_CLKCTRL (volatile unsigned int*)(0x44E0001C)
#define CM_USB_CTRL1 		(volatile unsigned int*)(0x44E10628)

//static volatile unsigned int pageTable[4*1024]__attribute__((aligned(16*1024)));


#define packet_number	53

void usb1_init();
void test_packet_load();

char usb_packet[packet_number] = {
		               0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
		               0x00, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,
		               0xAA, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE,
		               0xEE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
		               0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0xBF, 0xDF,
		               0xEF, 0xF7, 0xFB, 0xFD, 0xFC, 0x7E, 0xBF, 0xDF,
		               0xEF, 0xF7, 0xFB, 0xFD, 0x7E
                      };

extern void change_mode(void);

void usb_testmode(){

/*	unsigned int index;

	 for(index = 0; index < (4*1024); index++)
	    {
	         if((index >= 0xC00 && index < 0xE00)|| (index == 0x800))
	         {
	              pageTable[index] = (index << 20) | 0x00000C1E;
	         }
	         else
	         {
	              pageTable[index] = (index << 20) | 0x00000C12;
	         }
	    }
*/
		/*Initialize USB2.0 Controller*/
		usb1_init();

		*USB1_TESTMODE |= 0x90;

		/*Start a Session*/
		*USB1_DEVCTRL |= 0x1;

		/*Load Test Packet to EndPoint0 FIFO*/
		test_packet_load();

		/*Enter Test_Packet test mode*/
		*USB1_TESTMODE |= 0x08;

		/*Set the TxPktRdy bit in the CSR0 register(D1)*/
		*USB1_HOSTCSR0 |= 0x2;

}

void test_packet_load(void){

	int i;

	for(i=0;i<packet_number;i++)
	{
		*USB1_ENDPOINT0 = usb_packet[i];
	}

}

void usb1_init(){

	int status = 0;

	*(CM_PER_USB0_CLKCTRL) |= 0x2;

	/*USB PHY Related Configuration(Control Module Register)*/
	// Clear bits 0,1,8,9,23
	*(CM_USB_CTRL1) &= ~(0x00800303); // USB_CTRL0
	// Set bits 6,7,10,13,14,17,18,19,20
	*(CM_USB_CTRL1) |= 0x00186004; // USB_CTRL0

	*(USBSS_SYSCONFIG) = 0x1;
	while(status==0x1){
		status = *(USBSS_SYSCONFIG) & 0x00000001;
	}

	*(USBSS_SYSCONFIG) = 0x00000014;

	*(volatile unsigned int*)0x47401814 |= 0x40000000;

	*(USB1_MODE) = 0x00000000;

	*USB1_PMR |= 0x30;

}


int main(void) {
	
//	change_mode();
	usb_testmode();


	while(1);

//	return 0;
}