i2c on PRO

Questions on control of serial busses
basicchip
Posts: 1090
Joined: Fri Oct 19, 2012 2:39 am
Location: Weeki Watchee, FL
Contact:

Re: i2c on PRO

Post by basicchip »

0xF9 is generally some unexpected error condition

I assume you do have pull ups on both i2c pins (generally 5K or less)



danlee58
Posts: 210
Joined: Thu Jan 17, 2013 2:29 am

Re: i2c on PRO

Post by danlee58 »

The pullups are 2.2K Ohms. I'll double check the wiring to be sure.

Do I have to wait for the SI flag to go high before checking the STAT register?

danlee58
Posts: 210
Joined: Thu Jan 17, 2013 2:29 am

Re: i2c on PRO

Post by danlee58 »

Yes, the pullups are there. I setup a Whlie Loop to look for the SI flag to be set. I get 0x60 from I2C_I2C1NSET. The SI flag never gets set.

How does SI get set?

danlee58
Posts: 210
Joined: Thu Jan 17, 2013 2:29 am

Re: i2c on PRO

Post by danlee58 »

I measured 4.35 Volts at the MAX519 DAC. The spec is 4.5 Volts minimum.

The DAC is mounted on a prototype Arduino Shield board. I am powering the PRO through a USB cable for debugging. Ultimately the power will be from a 12 Volt source, through a DC-to-DC converter to produce 6 Volts.

Is 4.35 Volts from the PRO normal, when It's powered from USB?

basicchip
Posts: 1090
Joined: Fri Oct 19, 2012 2:39 am
Location: Weeki Watchee, FL
Contact:

Re: i2c on PRO

Post by basicchip »

There is a diode on the 5V connection on the 6 pin connector for the USB dongle (this allows that connection while another power supply is connected). So for the DAC you will need to connect your ultimate power supply. Most likely it would work with voltage a litlle low for testing (not recommended for final setup).

Attached is some code written for the i2c on the LPC4357 (same peripheral as all the other LPC parts except the LPC8xx). The I2C_Init will be different and this version is calling routines specific to the LPC4357 to manage IO pins. But the bulk of the I2C_Read and I2C_Write code will work and was tested (this version uses the hardware, but poll the status rather than use interrupts)
Attachments
i2c.h
i2c .h file
(1.82 KiB) Downloaded 821 times
i2c.c
i2c C file
(5.46 KiB) Downloaded 834 times

danlee58
Posts: 210
Joined: Thu Jan 17, 2013 2:29 am

Re: i2c on PRO

Post by danlee58 »

I have 4 AA batteries and a battery holder. I'll connect them to the PRO for testing.

danlee58
Posts: 210
Joined: Thu Jan 17, 2013 2:29 am

Re: i2c on PRO

Post by danlee58 »

With 4 AA batteries measuring 6.3 Volts on the PRO board Optional Power terminals, I get only 4.55 volts at the 5 Volt pin on the lower power connector.

danlee58
Posts: 210
Joined: Thu Jan 17, 2013 2:29 am

Re: i2c on PRO

Post by danlee58 »

I thought that I had my power connected to J8 on the PRO, but it's connected to J4. The 5 Volts is through the 78M05(U1), and D1, when using J4. I'll add 2 more AA cells so my source voltage is between 9 & 10 Volts. That should get regulated 5 Volts to the DAC.

danlee58
Posts: 210
Joined: Thu Jan 17, 2013 2:29 am

Re: i2c on PRO

Post by danlee58 »

We need more power, Mr Scott!

I added 4 more AA batteries to get 12 Volts, and hooked up the DC-to-DC converter, and set the output to 9.0 Volts. I connected the conveter output to J4 on the PRO. This is similar to the way it will be useed. Now I get 5.0 Volts, where I expect it.

Now I get 0xF8, when I read the STAT register. It was F9.

0xF8 indicates that the I2C block is not involved in the serial transfer. I set the Enable bit in the I2C1NEN register.

basicchip
Posts: 1090
Joined: Fri Oct 19, 2012 2:39 am
Location: Weeki Watchee, FL
Contact:

Re: i2c on PRO

Post by basicchip »

some thoughts on debugging i2c without a scope

-check the voltage levels at the IOs, when idle they should be either 3.3 or 5V depending on the supply used by the pullup

-check the configuration of PINSEL register and make sure the values match the User Manual. You could use breakpoint() in C or the same commands from BASIC command line which allows you to read and write any memory location including device registers. printf/print would also work, but is not as flexible.

-check that the IOs are really open drain, by attaching a resistor of equal value as your pullup to GND. When attached with the test pulldown the voltage should be 1/2 of the supply rail. If it is not then the IO is being driven high and is configured incorrectly.

-make sure the IOs are connected correctly (not swapped for SCLK and SDA), you can also force one of those pins low by setting it us as a GPIO and as an output and then drive it low.

-use a second SuperPRO or PROplus to monitor the i2c transaction, a watchI2C.bas program is published here in the forum. The scope demo could also be used to watch slower i2c transactions. I'm thinking of publishing a demo program that would use the SPI hardware to capture faster signals, with it 10 Mhz or faster could be captured, upto 50 MHz if the PCLK settings are changed.

Post Reply