I2C problem (16F877A with DS1844)


Closed Thread
Results 1 to 12 of 12

Hybrid View

  1. #1
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Try this out. If it works, it's up to you to figure out what's different...

    (and your English is fine, not perfect, but fine...and certainly a lot better than my ___________(<-insert language here).)

    DEFINE OSC 4
    DEFINE I2C_HOLD 1
    Define LCD_DREG PORTB 'LCD definialasa
    Define LCD_DBIT 4 'kezdo adatbit
    Define LCD_RSREG PORTB 'PORTB.3:RSbit
    Define LCD_RSBIT 3
    Define LCD_EREG PORTB 'Ebit:PORTB.2
    Define LCD_EBIT 2
    Define LCD_BITS 4 'LCD bus meret
    Define LCD_LINES 2 '2 soros
    buttontemp var byte : h var byte : b var byte : c var byte : t var byte : m1 var byte : m2 var byte : m3 var byte : m4 var byte : mb1 var byte : mb2 var byte
    mt1 var byte : mt2 var byte : d1 var byte : i2cdev var byte : sda var portc.4 : scl var portc.3 : goto skip_on_int
    On interrupt goto delay_5s 'megszakitasi rutin
    disable 'megszakitas felfüggesztese
    delay_5s: d1=d1+1 : INTCON.2=0
    if d1>77 then '5s=5000ms=65ms*77
    d1=0 : INTCON=0 : goto kiirhe 'hangero kiirasa
    endif 'ha nem,vissza
    resume
    enable
    skip_on_int:
    m1=0 : m2=$40 : m3=$80 : m4=$c0 : trisc=$e7 : trisd=$f : trisa=0 : trisb=0 : i2cdev=$50 : h=0 : b=0 : c=31 : t=31 : porta=63 : high portd.4 : adcon0=0
    adcon1=7 : cmcon=7 : sspcon=0 : pause 500 : lcdout $fe,1," Udvozollek" : pause 200 : i2cwrite sda,scl,i2cdev,[$1f,$5f,$9f,$df] : pause 100 : option_reg=7
    intcon=$a0
    main: button PORTC.1,0,0,0,buttontemp,1,novelhe : button PORTC.6,0,0,0,buttontemp,1,csokkenthe : button PortC.5,0,0,0,buttontemp,1,bemnov
    button PORTd.3,0,0,0,buttontemp,1,bemcsokk : button PORTC.0,0,0,0,buttontemp,1,bassn : button PORTD.1,0,0,0,buttontemp,1,basscs
    button PORTc.7,0,0,0,buttontemp,1,tren : button PORTd.2,0,0,0,buttontemp,1,trecs : Goto main
    novelhe: if h<63 THEN h = h + 1
    if ( h < 16 ) OR ( h > 31 and h < 48 ) then
    portA = h + 16 : goto kiirhe
    endif
    if ( h > 15 and h < 32 ) OR ( h > 47 and h < 64) then
    porta = h - 16 : goto kiirhe
    endif
    Goto kiirhe
    csokkenthe: if h>0 then h= h - 1
    if ( h < 16 ) OR ( h > 31 and h < 48 ) then
    portA = h + 16 : goto kiirhe
    endif
    if ( h > 15 and h < 32 ) OR ( h > 47 and h < 64) then
    porta = h - 16 : goto kiirhe
    endif
    Goto kiirhe
    bassn: if c<63 THEN c = c + 2
    mb1=c & m1 : mb2=c & m4 : i2cwrite sda,scl,,i2cdev,[mb1,mb2] : pause 200 : goto kiirmely
    basscs: if c>1 then c= c - 2
    mb1=c & m1 : mb2=c & m4 : i2cwrite sda,scl,i2cdev,[mb1,mb2] : pause 200 : goto kiirmely
    tren: if t<63 THEN t = t + 2
    mt1=t & m2 : mt2=t & m3 : i2cwrite sda,scl,i2cdev,[mt1,mt2] : Pause 200 : goto kiirmely
    trecs: if t>1 THEN t = t - 2
    mt1=t & m2 : mt2=t & m3 : i2cwrite sda,scl,i2cdev,[mt1,mt2] : Pause 200 : goto kiirmely
    kiirhe: lcdout $fe,1," Hangero: ",#h : pause 250 : b=b+1 : lcdout $fe,$c0," Bemenet: ",#b : pause 250 : b=b-1 : goto main
    kiirmely: mb1=0 : mb2=0
    LOOKUP c,[0,20,0,15,0,9,0,8,0,7,0,6,0,5,0,4,0,4,0,3,0,2,0,2, 0,1,0,1,0,0,0,0,0,0,0,1,0,1,0,2,0,2,0,3,0,4,0,4,0, 5,0,6,0,7,0,8,0,9,0,15,0,20,0,20],mb1
    LOOKUP c,[0,0,0,0,0,8,0,4,0,3,0,3,0,5,0,6,0,0,0,4,0,8,0,2,0, 6,0,0,0,5,0,0,0,5,0,0,0,6,0,2,0,8,0,4,0,0,0,6,0,5, 0,3,0,3,0,4,0,8,0,0,0,0,0,0],mb2
    if c<32 then kiirmep 'pozitiv ertek eseten
    if c>32 then kiirmen 'negativ eseten
    kiirmen: lcdout $fe,1," Mely: ","-",#mb1,",",#mb2,"dB":goto kiirmag
    kiirmep: lcdout $fe,1," Mely: "," ",#mb1,",",#mb2,"dB":goto kiirmag
    kiirmag: pause 250 : mb1=0 : mb2=0
    LOOKUP t,[0,20,0,15,0,9,0,8,0,7,0,6,0,5,0,4,0,4,0,3,0,2,0,2, 0,1,0,1,0,0,0,0,0,0,0,1,0,1,0,2,0,2,0,3,0,4,0,4,0, 5,0,6,0,7,0,8,0,9,0,15,0,20,0,20],mb1
    LOOKUP t,[0,0,0,0,0,8,0,4,0,3,0,3,0,5,0,6,0,0,0,4,0,8,0,2,0, 6,0,0,0,5,0,0,0,5,0,0,0,6,0,2,0,8,0,4,0,0,0,6,0,5, 0,3,0,3,0,4,0,8,0,0,0,0,0,0],mb2
    if t<32 then kiirmap
    if t>32 then kiirman
    kiirman: lcdout $fe,$c0," Magas: ","-",#mb1,",",#mb2,"dB" : pause 250 : TMR0=0 : d1=0 : INTCON=%10100000 : goto main
    kiirmap: lcdout $fe,$c0," Magas: "," ",#mb1,",",#mb2,"dB" : pause 250 : TMR0=0 : d1=0 : INTCON=%10100000 : goto main
    bemnov: if b<3 then b=b+1
    goto new1
    bemcsokk: if b>0 then b=b-1
    goto new1
    new1: low portd.7 : low portd.6 : low portd.5 : low portd.4 : high portd.0[bem+4] : goto kirrhe
    End
    Last edited by skimask; - 7th June 2007 at 17:43.

  2. #2
    Join Date
    Jun 2007
    Posts
    6


    Did you find this post helpful? Yes | No

    Default Thanks

    Thanks for the post

    Unfortunately that way nor functionate. Already I've tried with one other DS1844 also , but nothing change. Already everything run-through on several occasions , but nothing make mistake not I had found.

  3. #3
    Join Date
    Sep 2004
    Location
    Mentor, Ohio
    Posts
    352


    Did you find this post helpful? Yes | No

    Smile

    Hello,

    Do you have 4.7K pull up resistors on SCL and SDA?

    BobK

  4. #4
    Join Date
    Feb 2007
    Posts
    10


    Did you find this post helpful? Yes | No

    Default

    You may have a trace problem or breadboard problem. Check with a meter.

    Tim
    Last edited by T_J_W; - 9th June 2007 at 13:02.

  5. #5
    Join Date
    Jun 2007
    Posts
    6


    Did you find this post helpful? Yes | No

    Default

    Thanks

    Yes, I have 4,7k pull-up resistors

    Already I've tried check, but I hadn't found nothing mistake.
    Yet I will to try

Similar Threads

  1. I2C Master/Slave 16F88/16F767 working code
    By DanPBP in forum Code Examples
    Replies: 2
    Last Post: - 23rd October 2012, 22:31
  2. HARDWARE I2C SAMPLE CODE question
    By Michael Wakileh in forum Code Examples
    Replies: 2
    Last Post: - 16th June 2009, 21:07
  3. Another I2C Slave Routine Problem
    By DanPBP in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 19th February 2009, 05:50
  4. I2C Master Slave issues.
    By cpayne in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 29th March 2008, 19:33
  5. Problem with I2C (24c32 eeprom)
    By lab310 in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 5th February 2008, 09:00

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts