2023-10-06 07:47 PM - last edited on 2023-10-09 09:00 AM by Nicolas P.
Brief:
Want to use STM32L432 MCU and FUSB302B PD controller asking voltage higher then 5V.
Question:
Where am I set wrong of the PD controller?
Is there anything else I need to consider when asking the PD source?
Hi, I'm working on a project for digital auxliary power in card size.
The puropse is using Type-C connector connect to any source, have four output voltage can be choose, they are 3.3V / 5V / 12V and 24V.
I'm using power delivery (PD) for asking voltage higher then 5V for more output wattage.
Althought I had completed the power stage for 5V input, now I want to write PD firmware to asking higher voltage.
The MCU I used is STM32F432KC, PD controller I used is ONSemi FUSB302B.
I got stuck when I want to receive power data object (PDO) from PD source, like the wall adapter.
Here is register map of FUSB302B:
And here is my register setup after FUSB302B_start_CC_communication():
The function is doing following things:
/* @brief start PD communication on CC pin
* @ param I2C_HandleTypeDef *hi2c specific i2c HAL driver
* @ param FUSB302B_t *pfusb fusb object pointer
* [USER=190411]@Return[/USER] FUSB302B_status_t status FUSB302 status
*/
FUSB302B_status_t FUSB302B_start_CC_communication(I2C_HandleTypeDef* hi2c, FUSB302B_t* pfusb){
FUSB302B_status_t status;
// update register data
FUSB302B_read_all(hi2c, pfusb);
switch(pfusb->cc_pin){
case CC_NONE:
return FUSB302B_OK;
break;
case CC_PIN1:
// connect CC1 pin to DAC
status = FUSB302B_write_reg(hi2c, pfusb, Reg_Switches0, (pfusb->reg.switches0 & ~FUSB302B_Switches0_MEAS_CC_MASK) \
| FUSB302B_Switches0_MEAS_CC1);
// connect CC1 to BMC decoder
status &= FUSB302B_write_reg(hi2c, pfusb, Reg_Switches1, (pfusb->reg.switches1 & ~FUSB302B_Switches1_TXCC_MASK) | FUSB302B_Switches1_TXCC1);
break;
case CC_PIN2:
// connect CC1 pin to DAC
status = FUSB302B_write_reg(hi2c, pfusb, Reg_Switches0, (pfusb->reg.switches0 & ~FUSB302B_Switches0_MEAS_CC_MASK) \
| FUSB302B_Switches0_MEAS_CC2 );
// connect CC1 to BMC decoder
status &= FUSB302B_write_reg(hi2c, pfusb, Reg_Switches1, (pfusb->reg.switches1 & ~FUSB302B_Switches1_TXCC_MASK) | FUSB302B_Switches1_TXCC2);
break;
default:
break;
}
// reset PD logic
// status &= FUSB302B_write_reg(hi2c, pfusb, Reg_Reset, (pfusb->reg.reset & ~FUSB302B_Reset_Reserved_MASK) | FUSB302B_Reset_PD_RESET);
FUSB302B_read_all(hi2c, pfusb);
if (status != FUSB302B_OK)
return FUSB302B_ERROR;
else
return FUSB302B_OK;
}
I think after I execute FUSB302B_start_CC_communication, bit4 of status1 (RX FIFO Full) should be set because the source should transmit some data and PD controller received it, but after I execute it many times, the bit always stay 0.
The question is:
Where am I set wrong of the PD controller?
Is there anything else I need to consider when asking the PD source?
If the code have anything to improve, please fele free to give me advice!
I reference the following materials for developmenting:
Something I guess may cause the problem is the speed of MCU is not fast enought, power converter IRQ using most of resource of CPU.
I measure the main loop period is around 1.5 second (by measureing LED5), and PD protocol defined the sink device should send RDO(request data object) to source in 500mS after Good_CRC been send.
For bypass the resource issue, I try decrease the interrupt frequency from 200kHz to 100kHz, but it still the same.
Also I try to disable AUTO_CRC and it has no effect either.
Here is my project source code and PCB design for reference:
https://github.com/HabonRoof/PD-AuxPower-Card
Thanks for the reading.