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.

PCM2707C: Change descriptor data through SPI

Part Number: PCM2707C

Hello,

I would like to change the USB descriptor data with SPI.

What am i doing wrong here? 

First line is CS, than the data and as a third the clock.

Both PSEL and host lines are high. D+ line is pulled low.

Thanks! 

  • The device descriptor can be modified  through the SPI port (PCM2705C/7C); this descriptor programming function is only available when PSEL and HOST are high as you did. More functional details can be found in  section 9.5.1 USB Interface

    Please check the note# 4 (page 35 of datasheet):  MS must be high until the PCM2707C power supply is ready and the SPI host (the DSP) is ready to send data. Also, the SPI host must handle the D+ pullup if the descriptor is programmed through the SPI. D+ pullup must not be activated (high = 3.3 V) before programming of the PCM2707C through the SPI is complete.

  • Thanks for the reply but this did not resolve my issue.

    In the meantime i have been able to change the descriptor name, but it does not work as expected.

    Some strange things to make it work:

    • Add an extra write at the end (I added a 0x00)
    • The first byte of the product string is not used as part of the product string. I should change it everytime i wont to change the descriptor. (it seem to work like an ID or something)

    So i am able to change the descriptor but i would like to know how to do it without these weird adjustments 

    This is the 'working' code:

    static void usb_spiWriteDescriptor()
    {
    	uint8_t dataToSend[58] = {0xBB, 0x08, 0x04, 0x27,
    			0x02, 0x41, 0x75, 0x64, 0x61, 0x63, 0x20, 0x2D, 0x20, 0x44, 0x57, 0x50, 0x33, 0x34, 0x35, 0x20,		// To change this text, the first number needs to be changed
    			0x20, 0x20, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x20, 0x61,
    			0x72, 0x65, 0x20, 0x70, 0x6C, 0x61, 0x63, 0x65, 0x64, 0x20, 0x68, 0x65, 0x72, 0x65, 0x2E, 0x20,
    			0x80,
    			0x7D,
    			0x0A, 0x93, 0x01, 0x00
    		};
    
    	uint8_t wordToSend[2] = {0x02, 0x00};
    	spi_DMA_write(0, 0, 2, &wordToSend[0], &usbSPiHandle, GPIO_USBCS);
    
    
    	/* Reverse the bit order */
    	for(uint8_t n = 0; n < 58; n++)
    	{
    		dataToSend[n] = (dataToSend[n] & 0xF0) >> 4 | (dataToSend[n] & 0x0F) << 4;
    		dataToSend[n] = (dataToSend[n] & 0xCC) >> 2 | (dataToSend[n] & 0x33) << 2;
    		dataToSend[n] = (dataToSend[n] & 0xAA) >> 1 | (dataToSend[n] & 0x55) << 1;
    
    		wordToSend[1] = dataToSend[n];
    		wordToSend[0] = 0x08;
    
    		spi_DMA_write(0, 0, 2, &wordToSend[0], &usbSPiHandle, GPIO_USBCS);
    	}
    }

  • I can try to  take a look at your script  but I use  I2C Master type gui , in which  I simply write the instruction for  each register straight in to it  and not familiar with this coding so I might not be able to catch the issue. I will give it a shot though.

    Regards,

    Arash

  • I looked at the program and compared it to the example of datasheet .  Datasheet clearly indicates 57 bytes so I think the fact you are adding an additional byte and  then it seems to be  working, might point to that your first byte is not being  read. Can you plot SPI Write Operation so you can see the full detail of operation ( refer to fig 29)

    from data sheet: "The data must be stored from address 0x00 and must consist of 57 bytes, according to these listed parameters: • Vendor ID (2 bytes) • Product ID (2 bytes) • Product string (16 bytes in ANSI ASCII code) • Vendor string (32 bytes in ANSI ASCII code) • Power attribute (1 byte) • Max power (1 byte) • Auxiliary HID usage ID in report descriptor (3 bytes)"

    External ROM data (sample set)

    0xBB, 0x08, 0x04, 0x27,  Vendor ID: 0x08BB, Product ID: 0x2704  

    0x50, 0x72, 0x6F, 0x64, 0x75, 0x63, 0x74, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6E, 0x67, 0x73, 0x2E,    Product string: Product strings (16 bytes) 

    0x56, 0x65, 0x6E, 0x64, 0x6F, 0x72, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6E, 0x67, 0x73, 0x20, 0x61,

    0x72, 0x65, 0x20, 0x70, 0x6C, 0x61, 0x63, 0x65, 0x64, 0x20, 0x68, 0x65, 0x72, 0x65, 0x2E, 0x20,  Vendor string: Vendor strings are placed here (32 bytes, 31 visible characters are followed by 1 space)

    0x80,       Power attribute (bmAttribute): 0x80 (bus-powered)

    0x7D,       Max power (maxPower): 0x7D 

    0x0A, 0x93, 0x01     Auxiliary HID usage ID: 0x0A, 0x93, 0x01 (AL A/V capture)

    Explanation Data are stored beginning at address 0x00

    Note that the data bits must be sent from LSB to MSB on the I 2C bus. Therefore, each data byte must be stored with its bits in reverse order.