User avatar
Hove
Posts: 1205
Joined: Sun Oct 21, 2012 6:55 pm
Location: Cotswolds, UK
Contact: Website

Jessie: I2C baudrate & RPi.GPIO

Wed Sep 30, 2015 7:19 am

In the process of upgrading from scratch one of my Quadcopter to Jessie. 2 questions:
  • GPIO.wait_for_event() blocks, whereas my custom version which splits it into init, wait, term correctly reacts to a rising edge. Any ideas why? - scratch that - typo in my test
  • How do I confirm in software (i.e. not just by checking config.txt) that I2C is running at 400kbps as I've set in the dtparms? I had problems with wheezy device tree setting the 400kbps baudrate, and I think that's still the case.

TIA

Hove
www.pistuffing.co.uk - Raspberry Pi and other stuffing!

User avatar
joan
Posts: 14960
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Jessie: I2C baudrate & RPi.GPIO

Wed Sep 30, 2015 8:23 am

Start pigpiod with a 2 µs sampling rate.

sudo pigpiod -s 2

Run piscope.

Do an i2cdetect.

i2cdetect -y 1
i2c_400kbps.png
i2c_400kbps.png (45.64 KiB) Viewed 1593 times
i2c_400kbps-2.png
i2c_400kbps-2.png (45.28 KiB) Viewed 1592 times

User avatar
Hove
Posts: 1205
Joined: Sun Oct 21, 2012 6:55 pm
Location: Cotswolds, UK
Contact: Website

Re: Jessie: I2C baudrate & RPi.GPIO

Wed Sep 30, 2015 9:22 am

As always Joan, you are a saviour. I'll post the results once I have pigpio installed.
www.pistuffing.co.uk - Raspberry Pi and other stuffing!

User avatar
Hove
Posts: 1205
Joined: Sun Oct 21, 2012 6:55 pm
Location: Cotswolds, UK
Contact: Website

Re: Jessie: I2C baudrate & RPi.GPIO

Wed Sep 30, 2015 10:00 am

Thanks - that confirmed I am getting 400kbps, 28us pulse width.

Just out of interest, there's a 14 bit pulse lasting 28us = 2us per bit or 16us per byte neither of which add up to 400000 kbps or kBps?
www.pistuffing.co.uk - Raspberry Pi and other stuffing!

User avatar
joan
Posts: 14960
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Jessie: I2C baudrate & RPi.GPIO

Wed Sep 30, 2015 10:20 am

Hove wrote:Thanks - that confirmed I am getting 400kbps, 28us pulse width.

Just out of interest, there's a 14 bit pulse lasting 28us = 2us per bit or 16us per byte neither of which add up to 400000 kbps or kBps?
It is bits per second, so 400 kbps. The clock will change twice per bit so at best each clock edge will be 1.25 µs long. Sampling at 2 µs will not catch them all as you can see from the clock signal. I should have sampled at 1µs.

User avatar
Hove
Posts: 1205
Joined: Sun Oct 21, 2012 6:55 pm
Location: Cotswolds, UK
Contact: Website

Re: Jessie: I2C baudrate & RPi.GPIO

Wed Sep 30, 2015 11:39 am

OK, thanks for clarifying.
www.pistuffing.co.uk - Raspberry Pi and other stuffing!

Return to “Interfacing (DSI, CSI, I2C, etc.)”