Troubles with I2C_Write


Closed Thread
Results 1 to 11 of 11

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default

    Do you have appropriate pullup resistors on the I2C clock and data lines ?
    I have seen values from 1.2k to 10k work to good effect. The lower the value the less susceptible the signals are to noise

  2. #2
    Join Date
    Aug 2009
    Posts
    13


    Did you find this post helpful? Yes | No

    Default

    Hm.... false alarm. The DAC chip was bad.
    We have it (or at least a simple saw tooth wave demo) working now:
    Code:
    ;@   __CONFIG    _HS_OSC & _WDT_OFF
    
    DEFINE  OSC 20
    DEFINE	I2C_SLOW		1
    
    
    
    
    ' Allocate RAM
    result		VAR		WORD			' ADC result                            '2
    Iter    	VAR		BYTE			' Generic Iterator						'1
    
    
    ' Initialize ports and directions
            TRISB.1 = 0				' Pin for SDA
            TRISB.4 = 0				' Pin for SCL
    		
    
    mainloop:						' Main program loop
    		'This should set the DAC to output.
    		FOR ITER =0 TO 254
    		result = ITER
    		result=result<<4
    		PAUSE	100
    		I2CWRITE PORTB.1, PORTB.4, $9C, [result.HIGHBYTE, result.LOWBYTE]
    		NEXT
    		FOR ITER =255 TO 1 STEP -1
    		result = ITER
    		result=result<<4
    		PAUSE	100
    		I2CWRITE PORTB.1, PORTB.4, $9C, [result.HIGHBYTE, result.LOWBYTE]
    		NEXT
    		goto mainloop

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