PIC18F4525 to DAC (PCF8591P) I2CWrite too fast?


Results 1 to 5 of 5

Threaded View

  1. #3


    Did you find this post helpful? Yes | No

    Default

    I'm using pull-up resistors on the SDA/SCL lines that are 2.2k (which i think is standard for 100kbps I2C communication).

    I'm pretty new to coding in PicBasic Pro, but what is a configuration fuses setting? I'm coding/compiling it in MicroCode Studio using the PicBasic Pro compiler and using the MPLAB PICSTART PLUS programmer to program it to the board. It seems to use MPASM to convert the code from Assembly to Hex.

    The period of the SCL signal when it's hooked up to the oscilloscope is a regular square wave (not noisy) with a period of 1us, which was a very clear clock signal showing 1MHz. With the changes applied to the code, the clock signal was still showing a frequency of 1MHz. It doesn't change when adding the I2C_SLOW code.

    Code:
    DEFINE OSC 20 '20 MHz external oscillator     
    DEFINE I2C_SLOW 1
    
    SDA var PORTC.4 'SDA port 
    SCL var PORTC.3 'SCL port
    
    Loop VAR Byte
    
    DACAddressByte con %10010000 ' DAC Address byte (7-bit address: 1001 000)
    DACControlByte VAR  BYTE ' DAC control byte (sets DAC to D/A:0100 0000)
    DACControlByte = %01000000
    
    start: 
    
    For Loop = 0 To 255 'ramp up
    I2CWRITE sda,scl,DACAddressByte,DACControlByte,[Loop] 'I2CWrite
    Pause 10 'wait for write
    Next
    
    GoTo start
    Last edited by opticsteam1; - 4th April 2008 at 08:16. Reason: oops forgot the address shift

Similar Threads

  1. I2CRead & I2CWrite not working as expected
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 30
    Last Post: - 27th October 2021, 18:36
  2. PIC 18F4550 and MCP23017
    By DaveC3 in forum Code Examples
    Replies: 12
    Last Post: - 4th December 2010, 14:01
  3. Wanted: Sound chip interfaced with pic
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 34
    Last Post: - 8th September 2008, 13:38
  4. My I2CWRITE - timings and tricks
    By FinchPJ in forum Code Examples
    Replies: 5
    Last Post: - 3rd March 2008, 21:40

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