<< return to Pixycam.com

I2C communication problems with STM32F3Discovery Board

I am attempting to port the Pixy over to an STM32F3Discovery Board using I2C communication. I have used the “porting guide” from this site but I cannot seem to get the Pixy to acknowledge the STM32F3Discovery’s commands. I hooked up Oscilloscope to the SDA and SCL lines between the Pixy and the STM32 board and I can capture the command from the Master(the discovery board) but the Pixy is not pulling down the Ack bit on the 9th bit of the frame. I see :101010011 for the first frame on my scope. I have left the address of the Pixy at its default value of 0x54 and the SCL frequency captured on the scope is about 100kHz. Is there an obvious problem with the clock frequency or is the first frame that is trying to setup for a “Write” command formatted improperly for a Pixy address of 0x54 that was set on the Pixy using Pixymon?

I also have a question regarding which register address to start reading data from on the Pixy. Most of the I2C examples I have found for the STM32 boards on the web show a step where the address of the register you are trying to read is sent to the slave device before the data is actually read and then many of the I2C slave devices are set up to auto-increment the registers on successive reads.

Any help you could provide would be appreciated. In case it matters, I am using the Eclipse compiler and programming in C (not C++)

Regards.

I found the following link over on the Hardware forum that fixed the problem with the Pixy acknowledging the commands from the master:

http://www.cmucam.org/boards/8/topics/5412?r=5423#message-5423

Just changing the port of the pixy to 1 using the Pixymon software was all that was needed to allow the Pixy to acknowledge commands from the master.

I am still looking for the answer to my question regarding the register to start reading from on the first read request. I plan to monitor the I2C lines while it is successfully communicating to an Arduino Mega in hopes of getting my answer by mimicking what I see the arduino doing but is sure would be easier of someone on the forum already knows that answer that could help me out.

Help to hear something…

Regards.

Hello Brent,
The Pixy serial protocol doesn’t use a register address scheme like you describe for most STM32 I2C examples.

The protocol is described in detail in the porting guide, but you’ve seen this, so I don’t think I’m answering your question.

Edward

I have looked at the porting guide and I now understand that the serial protocol is using a polling scheme instead of the address scheme as you mentioned. I am really stuck here though. I can get my Arduino Mega2560 working fine. And can see the SCL and SDA signals on the scope and they are about 4.5V peak to peak and I notice that there is about a 1 clock cycle delay between 9-bit messages on the bus.

When I try my STM32F3Discovery board, I cannot find the sync bits (0xAA55, 0xAA55). My peak to peak voltage is closer to 3.44V and there is no “delay” between 9-bit messages on the bus meaning that the SCL signal is a steady 100kHz signal for the entire process of reading a word including sending a request to read 2 bytes from the Pixy and reading two consecutive bytes. Looking at the data read from the Bus it seems that the first byte is being read in as zero for most of the words. The Pixy just doesn’t send data for the first byte most of the time. It does occasionally send both bytes but not consistently enough to sync.

I tried slowing the SCL signal down to 50kHz and there was no change in performance. Here is sample output from the 100kHz clock frequency:

‘w’ = 0x55
‘w’ = 0xaa55
‘w’ = 0xaa21
‘w’ = 0x101
‘w’ = 0xa7
‘w’ = 0x59
‘w’ = 0x10
‘w’ = 0x10
‘w’ = 0x55
‘w’ = 0xaa55
‘w’ = 0xaa18
‘w’ = 0x101
‘w’ = 0xa5
‘w’ = 0x58
‘w’ = 0xe
‘w’ = 0xc
‘w’ = 0

It looks like the 0x55 is supposed to be 0xaa55 but, again, no first byte. My code, and the scope, just show all zeros for the first byte.
Does anyone have any suggestions?