Searching \ for '[PIC]: AN734 (I2C) on 16F690' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/i2cs.htm?key=i2c
Search entire site for: 'AN734 (I2C) on 16F690'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: AN734 (I2C) on 16F690'
2007\01\14@173542 by Mark Rages

face picon face
Sorry, forgot the tag.

I had to make the some changes to use AN734 (I2C slave example) on a
16F690.  For more information, including an idea for testing I2C, see
my blog. (http://vivara.net/blog/?p=53)

Here's the patch

--- an734.orig.asm      2006-03-09 15:09:16.000000000 -0600
+++ an734.asm   2007-01-14 11:36:07.000000000 -0600
@@ -58,14 +58,14 @@
; Include Files
;---------------------------------------------------------------------

-#include <p16f872.inc> ; Change to device that you are using.
+#include <p16f690.inc> ; Change to device that you are using.


;---------------------------------------------------------------------
;Constant Definitions
;---------------------------------------------------------------------

-#define         NODE_ADDR      0x02    ; I2C address of this node
+#define         NODE_ADDR      0x06    ; I2C address of this node
                               ; Change this value to address that
                               ; you wish to use.
;---------------------------------------------------------------------
@@ -80,6 +80,8 @@
       udata_shr

WREGsave       res     1
+
+       udata
STATUSsave     res     1
FSRsave                res     1
PCLATHsave     res     1
@@ -182,14 +184,18 @@
       bsf     PCON,NOT_POR
       bsf     PCON,NOT_BOR

+       banksel ANSELH          ; I2C lines cannot be on ADC duty
+       bcf ANSELH, ANS10       ; AN10 is multiplexed with RB4/SDA
+
       banksel Index           ; Clear various program variables
       clrf    Index

       clrf    PORTB
       clrf    PIR1
       banksel TRISB
-       clrf    TRISB
-
+       bsf     TRISB,4         ; I2C clock
+       bsf     TRISB,6         ; I2C data
+
       movlw   0x36            ; Setup SSP module for 7-bit
       banksel SSPCON
       movwf   SSPCON          ; address, slave mode

--
You think that it is a secret, but it never has been one.
 - fortune cookie


--
You think that it is a secret, but it never has been one.
 - fortune cookie

2007\01\14@180229 by Philip Pemberton

face
flavicon
face
Mark Rages wrote:
> I had to make the some changes to use AN734 (I2C slave example) on a
> 16F690.  For more information, including an idea for testing I2C, see
> my blog. (http://vivara.net/blog/?p=53)

If you want to know why the address is 'halved', it's probably because I2C's
address field is 7 bits with a 1-bit read/write flag bit in the LSB. SMBus
takes the address as those seven bits, LSB-aligned, with separate R/W
operations on the SMBus controller.

The PIC is comparing the address with 0x06 (write to real address 0x03), your
PC is writing to what it calls address 0x03. So the R/!W bit is low (write),
meaning the address byte has a value of... 0x06.

I'm not 100% sure if this is what's actually happening, but the theory seems
to be accurate... YMMV.

--
Phil.                         |  (\_/)  This is Bunny. Copy and paste Bunny
spam_OUTpiclistTakeThisOuTspamphilpem.me.uk         | (='.'=) into your signature to help him gain
http://www.philpem.me.uk/     | (")_(") world domination.

2007\01\14@183526 by Mark Rages

face picon face
On 1/14/07, Philip Pemberton <.....piclistKILLspamspam@spam@philpem.me.uk> wrote:
> Mark Rages wrote:
> > I had to make the some changes to use AN734 (I2C slave example) on a
> > 16F690.  For more information, including an idea for testing I2C, see
> > my blog. (http://vivara.net/blog/?p=53)
>
> If you want to know why the address is 'halved', it's probably because I2C's
> address field is 7 bits with a 1-bit read/write flag bit in the LSB. SMBus
> takes the address as those seven bits, LSB-aligned, with separate R/W
> operations on the SMBus controller.
>
> The PIC is comparing the address with 0x06 (write to real address 0x03), your
> PC is writing to what it calls address 0x03. So the R/!W bit is low (write),
> meaning the address byte has a value of... 0x06.
>
> I'm not 100% sure if this is what's actually happening, but the theory seems
> to be accurate... YMMV.

I suspected something like that, but I didn't dig through the specs to
verify it.

Oh here it is, in the '690 datasheet, section 13.12.1:

> The value of register SSPSR<7:1> is compared to the value of the SSPADD register.

Regards,
Mark
markrages@gmail
--
You think that it is a secret, but it never has been one.
 - fortune cookie

More... (looser matching)
- Last day of these posts
- In 2007 , 2008 only
- Today
- New search...