cancel
Showing results for 
Search instead for 
Did you mean: 

[STUSB4500] how to take active the after register is written

vlee
Associate II

I try to update the register

ex: updated DPM_REQ_RDO3_0/1/2/3

after the register is updated, how can I take this active.

under my test. it can be work under some following condition:

  1. MCU reset
  2. write DPM_REQ_RDO3_0/1/2/3

it is OK and change to what I want.

NOT work if

  1. MCU reset
  2. do something (maybe delay 1sec)
  3. write DPM_REQ_RDO3_0/1/2/3

It is NOT OK.

vic

8 REPLIES 8
Gregory Go.
Senior II

Hello,

The DPM_REQ_RDO3 register contains the 32 bit RDO that has been negotiated with the Power Source.

This register can be read to know what are the characteristics of the RDO.

However, to have the STUSB4500 to request a new PDO from the Source, use this sequence from the STUSB45 library:

printf("Changing the PDOs ... \r\n");
Update_Valid_PDO_Number( Usb_Port, 3 );
Update_PDO(Usb_Port,1,5000,1500);
Update_PDO(Usb_Port,2,9000,1000);
Update_PDO(Usb_Port,3,20000,1000);   
Status = SW_reset_by_Reg(Usb_Port);
usb_pd_init(Usb_Port); //refresh main registers & IRQ mask init after reset

Regards

vlee
Associate II

hello

Thank you for you reply,

I get a problem because the MCU power source from STUSB4500.

and

when calling

  1. Status = SW_reset_by_Reg(Usb_Port);

STUSB4500 will reset and no voltage output, MCU also reset.

Is it normal?

Am I need to give a external power for MCU????

(P.S. the schematic mainly following STREF-SCS001V1

Regards

Vic

Gregory Go.
Senior II

Hello,

Yes this is expected behavior.

When you soft-reset the STUSB4500, it will also reset the USB-C attachment state, so the power will be lost on VBUS for around 1s.

If your application doesn't have a source of power (e.g. a battery) to keep the MCU alive when VBUS is lost, then you cannot use soft-reset register or hard-reset pin.

Gregory Go.
Senior II

Hello,

 Here is the description to change a PDO without losing VBUS.

When you perform a Hard-Reset or Soft-Reset, it puts the STUSB4500 into Error-Recovery mode where it disconnects from the Source. So VBUS is lost for about 1s (until the chip reconnect).

If your application is a VBUS powered application (i.e. no battery), do not Reset the STUSB4500 by using Hard-reset pin or by writing the Soft-Reset register.

Instead, send a PD Message to Soft-Reset the Power Source.

The functions below show how to perform a Soft-Reset without losing VBUS.

int Change_PDO_WithoutLosingVbus()
{
    int Usb_Port = 0;
    int NewPDO_Voltage = 20000;
    
    Update_Valid_PDO_Number( Usb_Port, 2 );
    Update_PDO(Usb_Port, 1, 5000, 1500);
    Update_PDO(Usb_Port, 2, NewPDO_Voltage, 1000); 
    PdMessage_SoftReset();
    
    return 0;
}
 
 
#define PD_HEADER_SOFTRESET 0x000D
 
int PdMessage_SoftReset()
{
    int status = 0;
    uint8_t UsbPort = 0;
    volatile int Timeout;
    
    //-------------------------------------
    uint16_t Data16 = PD_HEADER_SOFTRESET;
    uint8_t Data8[2];
    Data8[0] = Data16 & 0xFF;
    Data8[1] = (Data16 >> 8) & 0xFF;
    status = I2C_Write_USB_PD(STUSB45DeviceConf[UsbPort].I2cBus, STUSB45DeviceConf[UsbPort].I2cDeviceID_7bit, TX_HEADER, (uint8_t *)&Data8, 2 );
    if(status != 0) { return -1; }
    
    
    //-------------------------------------
    PostProcess_Msg_Accept = 0; //clear
    PostProcess_Msg_Reject = 0;  //clear
    Timeout = 0;  //clear
    
    
    //-------------------------------------
    uint8_t New_CMD = 0x26;
    status = I2C_Write_USB_PD(STUSB45DeviceConf[UsbPort].I2cBus, STUSB45DeviceConf[UsbPort].I2cDeviceID_7bit, STUSB_GEN1S_CMD_CTRL, &New_CMD, 1 );
    if(status != 0) { return -1; }
    
    
    //-------------------------------------
    while( (PostProcess_Msg_Accept == 0) && (PostProcess_Msg_Reject == 0) && (Timeout == 0)); //wait PD message is accepted by SOURCE
    
    
    if( PostProcess_Msg_Accept > 0)
    {
        return 0; //OK
    }
    else if( PostProcess_Msg_Reject > 0)
    {
        return -1;
    }
    else
    {
        return -2;
    }
}

Regards

vlee
Associate II

thank you so much

but may i know, when these three parameter will update??

while( (PostProcess_Msg_Accept == 0) && (PostProcess_Msg_Reject == 0) && (Timeout == 0)); //wait PD message is accepted by SOURCE

Gregory Go.
Senior II

The variables referencing the USB PD messages (Accept & Reject) are updated during Interruption routines.

You can take a look at the code here:

https://github.com/usb-c/STUSB4500/blob/master/Firmware/Project/Src/USB_PD_core.c

For Timeout event variable , you need to implement the timeout feature depending on your system.

Pjign.1
Associate

Hello ST team,

I am currently integrating stusb4500 chip to our product. All stuff are running good but we are facing following error.

Once we plug usbc source we are getting pdo3 active and this is working fine without any problem. Now our micro controller need to get pdo information from stusbc so we added I have send soft reset to stsusbc chip as suggested in function "PdMessage_SoftReset()". So expected behavior is that we should get pdo information without lossing vbus voltage but in real we are loosing vbus voltage.

Following are the sequence for register configuration

//Init register

i2cset -f -y 3 0x28 0x0c 0xfd

i2cset -f -y 3 0x28 0x70 0x02

//Soft reset

i2cset -f -y 3 0x28 0x51 0x000d w

i2cset -f -y 3 0x28 0x1a 0x26

Please help us to fix issue of this as we need do not want to loose pdo3 while getting pdo information. Also note that we have updated NVM memory as per our product requirement. So let me know if you need that information also to check this problem.

Thanks,

Jignesh Patel

try

Get_Src_Cap_Message_type = 0x07

instead of

Soft_Reset_Message_type = 0x0D

It will populate RX_DATA_OBJ with PD Source capabilities