I2C

11 views
Skip to first unread message

Jim Spence

unread,
Aug 23, 2009, 10:54:00 AM8/23/09
to PIC32-Basic
Use this for any I2C related discussions. There is documentation,
hints articles atc. on line at www.i2c.byvac.com. There are also some
PIC32_Basic programs there as well.

peter247

unread,
Aug 25, 2009, 8:10:05 AM8/25/09
to PIC32-Basic
Hi alll , I`ll start this off and do a first post .

So far I have these i2c devices.

DS1307 , MCP23016 , MCP23008 , BV4219 , BV4235 , BV4237 .

and found it very easy to use them with the BV513

eg i2cwrite 0x42 0x20 a$+" " or i2cwrite 0x42 0x20 "print this"

On Aug 23, 3:54 pm, Jim Spence <j...@byvac.com> wrote:
> Use this for any I2C related discussions. There is documentation,
> hints articles atc. on line atwww.i2c.byvac.com. There are also some

Malcolm

unread,
Aug 26, 2009, 3:43:51 PM8/26/09
to PIC32-Basic
Peter,
I am just trying feed data to the bv4219 (Beginner) and it does seem
simple to a point.
Initially I had problems understanding the S-addr and S constructs but
really the dont seem to be needed.
Are the built into i2cwrite I wonder.
Having confered with Jim I had some success after using i2copen 400000
but this turned out to be a red herring; the problem was coding errors
closing down communications.
I am currently trying to work out how to get charactors from the small
keyboard to feed to the screen.
Have you done this?

Malcolm

peter247

unread,
Aug 26, 2009, 4:41:08 PM8/26/09
to PIC32-Basic
Hi Malcolm . Hope this will help.

o.k for a start I`ve changed the default address from 0x42 to 0x64
below is the function I use for printing the time , etc

so to clear the screen use :- i2cwrite 0x42 0x5
and switch the black light on ;- i2cwrite 0x42 0x6 1
to display in white :- i2cwrite 0x42 0x20 text$ and change the
0x20 to 0x21 for black

// --- LCD Display functions ---
//
// i2cwrite 0x64 0x5 - clear screen
// i2cwrite 0x64 0x6 0 or 1 - Back light
// i2cwrite 0x64 0x20 text$ - white text
// i2cwrite 0x64 0x21 text$ - black text
// i2cwrite 0x64 0x25 < 0 to 7 > < 0 to 20 > - C / R

function display_time
if i2ctest(0x64) = 1 then
i2cwrite 0x64 0x25 3 0
i2cwrite 0x64 0x20 time$()
endif
endf

Malcolm

unread,
Aug 26, 2009, 6:10:47 PM8/26/09
to PIC32-Basic
thanks for the info Peter, I will have a play with that.
Malcolm

Malcolm

unread,
Aug 31, 2009, 4:44:16 PM8/31/09
to PIC32-Basic
Peter
Tried your your code examples and they worked OK as you would expect
and I am now somewhat wiser.
I will ask a further question.
The code ' while key?(2) = 0 works to get out of a loop as used in the
keypad example, it can invoke various errors when used incorrectly.
Are there any rules for its use or is there another way of getting out
of looping program.

Malcolm

peter247

unread,
Aug 31, 2009, 5:47:36 PM8/31/09
to PIC32-Basic
Hi Malcolm , Not used that function so can`t tell you.
From the docs, it`s just looking to see if you have anything into the
serial buffer.

I`ve found some function just don`t like to be inside a schedule eg
"process ???? every 123"
eg just add a "wait 1" to lock it up

Malcolm

unread,
Aug 31, 2009, 5:52:49 PM8/31/09
to PIC32-Basic
Thannks Peter,
Will look at 'wait'
Malcolm
Reply all
Reply to author
Forward
0 new messages