i2c on PRO

Questions on control of serial busses
YahooArchive
Posts: 1462
Joined: Fri Oct 19, 2012 5:11 am

Re: i2c on PRO

Post by YahooArchive »

To be honest I hadn't heard of "bit-banging" before I joined this group! We're
using the NXP hardware features in our libraries.

We did start some work on an I2C library recently as a way of storing persistent
data in EEPROMs on a couple of development boards we use. However, we are
currently implementing an IAP library so that the user can use the spare flash
ROM on the MCU instead. That has the advantage that it is applicable to all of
the boards (including the ARMmite) that we support. We will probably revisit I2C
once that is finished.

Cheers,
Chris Burrows
http://www.armaide.com



YahooArchive
Posts: 1462
Joined: Fri Oct 19, 2012 5:11 am

Re: i2c on PRO

Post by YahooArchive »

Hi Chris,

Another question: Do you have support for interrupts with EINT0 and EINT1 so
that pulse width measurements can be done accurately?

Thanks,
Victor

YahooArchive
Posts: 1462
Joined: Fri Oct 19, 2012 5:11 am

Re: i2c on PRO

Post by YahooArchive »

Hi Chris,

Do you have I2C library working with Armaid? Will that work with ARMmite and
ARMmite PRO?

Thanks,
Victor

YahooArchive
Posts: 1462
Joined: Fri Oct 19, 2012 5:11 am

Re: i2c on PRO

Post by YahooArchive »

Anything you can do in C (and more) is highly likely to be possible in
Oberon-07. One of the examples included with the evaluation edition of Armaide
that works on the ARMmite is a blinking LED driven by timer interrupts
(IRQBlinker.mod & IRQTimer.2100.mod). I don't see any reason why this couldn't
be adapted to use external interrupts instead of timer interrupts.

Regards,
Chris Burrows

CFB Software
Armaide: LPC2xxx Development System for Pascal programmers
http://www.armaide.com

YahooArchive
Posts: 1462
Joined: Fri Oct 19, 2012 5:11 am

Re: i2c on PRO

Post by YahooArchive »

So why aren't the dedicated i2c pins connected to the "Arduino" pins?

The simple answer is those pins are ALWAYS open-drain, which means you can't
drive them high (they need a pullup resistor).

As they are open-drain that conflicts with more peoples software than those who
want to use the hardware i2c for some reason.

IMHO the i2c hardware in the LPC parts is pretty useless, requiring either lots
of polling or interrupts and if you look at the throughput the bit banged
routines have more flexibility with only a small performance penalty.

As for the other serial protocols, the only time we've used the hardware was for
the SPI ethernet interface on the ARMweb. Unlike a device like an A/D which
uses only short commands, the ethernet is sending large blocks of data, and
there it makes sense to use the SPI hardware.

BASIC does not preclude you from using any of the serial hardware, you can
access all the registers and now even link in interrupt routines. But in these
cases the code is almost always very specific to the target device, so we really
can't publish examples for them. And we will rely on users publishing examples
that they have used.

YahooArchive
Posts: 1462
Joined: Fri Oct 19, 2012 5:11 am

Re: i2c on PRO

Post by YahooArchive »

--- In ARMexpress@yahoogroups.com, "pompey2" wrote:
>
> Chris, Please let us know if you get the hardware I2C1 working on the PRO. I
know there are several of us here that need it! I'll volunteer to beta test it,
even if it means trashing Basic on one of my PROs....
>

Unfortunately, we do not have an ARMmite PRO here to try it out on. We normally
order our stuff from SparkFun as they don't charge an arm and a leg to ship to
Australia. Last time we looked they didn't have any PROs. We'll get one with our
next order if they are back in stock.

As long as the SCL and SDA I2C pins are functional on the PRO as you and Bruce
seem to think, I'd be amazed if the ARMmite code didn't work on the PRO. We only
had to change two lines of code to get our EEPROM I2C1 ARMmite demo working on
one of the other development boards we support and that uses an LPC2148 MCU!

In the meantime, if you can hook up your ARMmite PRO to a Microchip 24LC256 I2C
EEPROM:

http://www.microchip.com/wwwproducts/De ... e=en010823

we can send you a copy of the ARMmite HEX executable file of the demo to try
out.

Regards,
Chris Burrows

CFB Software
Armaide: LPC2xxx Development System for Pascal / Delphi programmers
http://www.armaide.com

YahooArchive
Posts: 1462
Joined: Fri Oct 19, 2012 5:11 am

Re: i2c on PRO

Post by YahooArchive »

--- In ARMexpress@yahoogroups.com, "cfbsoftware1" wrote:
>
> Unfortunately, we do not have an ARMmite PRO here to try it out on. We
normally order our stuff from SparkFun as they don't charge an arm and a leg to
ship to Australia. Last time we looked they didn't have any PROs. We'll get one
with our next order if they are back in stock.
>

Update: They are now back in stock at SparkFun so the order's gone. Assuming all
goes well (no reason to believe it won't!) we will soon be adding the ARMmite
PRO to the list of boards we actively support with Armaide.

We also ordered an I2C temperature sensor IC which will give us three different
types of I2C devices to provide examples for.

Cheers,
Chris

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

Re: i2c on PRO

Post by danlee58 »

I am tring to set up a Maxim MAX519 DAC using SCL1, & SDA1 on an ARMmite PRO. I don't get an ACK(I2C_I21STAT = 0x08) from the hardware after I send a STA_ It might be a hardware problem, as this is all new hardware & software.
Any comments on the code?


Code in LPC210x.h
"#define I2C_I2C1NSET (*(REG32 (0xE005C000)))
#define I2C_I21STAT (*(REG32 (0xE005C004)))
#define I2C_I21DAT (*(REG32 (0xE005C008)))
#define I2C_I21ADR (*(REG32 (0xE005C00C)))
#define I2C_I21SCLH (*(REG32 (0xE005C010)))
#define I2C_I21SCLL (*(REG32 (0xE005C014)))
#define I2C_I2C1NCLR (*(REG32 (0xE005C018)))"

Code in C program
"PCB_PINSEL1 = 0x010100; //Select pins P17, & P18 as SCL1, & SDA1;

I2C_I2C1NSET = 0X60; //SET START BIT
while (I2C_I21STAT != 0X08); //WAIT FOR THE STATUS BIT TO BE 08h
printf("i2c device1 found\n");
"

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

Re: i2c on PRO

Post by danlee58 »

I have corrected thge C Code as below:

"PCB_PINSEL1 = 0x014; //Select pins P17, & P18 as SCL1, & SDA1;

I2C_I2C1NSET = 0x60; //SET START BIT
while (I2C_I21STAT != 0x08); //WAIT FOR THE STATUS BIT TO BE 08h
printf("i2c device1 found\n");

Also this code is included;

I2C_I21SCLH = 0x0F; //SET HIGH BYTE OF I21SCL CLOCK REGISTER
I2C_I21SCLL = 0x0F; //SET LOW BYTE OF I21SCL CLOCK REGISTER

This should produce a 400Khz square wave clock.

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

Re: i2c on PRO

Post by danlee58 »

The I2C_I21STAT has 0xF9. I am expecting 0x08.

Post Reply