A couple of notes bearing in mind that while I've researched this and implemented only the SMbus Alert Response Command using the Pico SDK, I am really a beginner at this.
It is worth noting that while SMbus is based on I squared C there are parts of it the rp2040 data sheet specifically excludes, namely:
https://github.com/raspberrypi/pico-sdk ... _i2c/i2c.c
Maybe change it to 25 microseconds for both lcnt and hcnt at 20 kHz and see. Anyway, you could optimize depending on your frequency, or is 1:1 always good at <=100 kHz? For I2C, I think yes.
Research by me:
System management bus specification , Appendix B especially
https://smbus.org/specs/smbus110.pdf
Is this accurate?
https://www.analog.com/en/resources/des ... smbus.html
This PDF is good:
https://www.ti.com/lit/pdf/slua475
The actual sink current can vary from expected, as you may know.
I don't use the pull-up function when I have external pull-ups.
What value to use depends on the speed and bus capacitance, right?
I think you do have to use the timeouts but then handle what happens when the timeout occurs in your own management of the SMbus protocol. Perhaps reset the bus in this case.
It is worth noting that while SMbus is based on I squared C there are parts of it the rp2040 data sheet specifically excludes, namely:
Perhaps your frequency issue is due to the period used when SDK sets baudrate:The I2C block does not support SMBus and PMBus protocols (for System Management and Power management).
https://github.com/raspberrypi/pico-sdk ... _i2c/i2c.c
Code:
uint i2c_set_baudrate(i2c_inst_t *i2c, uint baudrate) { invalid_params_if(HARDWARE_I2C, baudrate == 0); // I2C is synchronous design that runs from clk_sys uint freq_in = clock_get_hz(clk_sys); // TODO there are some subtleties to I2C timing which we are completely ignoring here uint period = (freq_in + baudrate / 2) / baudrate; uint lcnt = period * 3 / 5; // oof this one hurts uint hcnt = period - lcnt;
Maybe change it to 25 microseconds for both lcnt and hcnt at 20 kHz and see. Anyway, you could optimize depending on your frequency, or is 1:1 always good at <=100 kHz? For I2C, I think yes.
Research by me:
System management bus specification , Appendix B especially
https://smbus.org/specs/smbus110.pdf
Is this accurate?
https://www.analog.com/en/resources/des ... smbus.html
This PDF is good:
https://www.ti.com/lit/pdf/slua475
The actual sink current can vary from expected, as you may know.
I don't use the pull-up function when I have external pull-ups.
What value to use depends on the speed and bus capacitance, right?
I think you do have to use the timeouts but then handle what happens when the timeout occurs in your own management of the SMbus protocol. Perhaps reset the bus in this case.
Statistics: Posted by breaker — Sat Jan 11, 2025 10:46 pm