PIC18F4525 to DAC (PCF8591P) I2CWrite too fast?


Closed Thread
Results 1 to 5 of 5

Hybrid View

  1. #1
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Hey welcome here

    Configurations fuses are some of the PIC settings which may screw a design pretty quick. One of the most important is the Oscilattor setting. By default, PBP use XT mode, this is good enough for crystal ~4Mhz, you're using 20MHz so you need to change the OSC mode, in your case you select HS mode. Refer to section 2 of your datasheet.

    There's several way to do it, but we suggest you to place the settings in your code, so you don't need to change it all the time before you program your PIC.

    Short tutorial about that bellow... post 1-5 cover most thing you have to know.
    http://www.picbasic.co.uk/forum/showthread.php?t=543

    I'll suggest you to paste the following lines in your code.
    Code:
    asm
            __CONFIG  _CONFIG1H, _OSC_HS_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
            __CONFIG  _CONFIG2L, _PWRT_ON_2L & _BOREN_ON_2L & _BORV_3_2L 
            __CONFIG  _CONFIG2H, _WDT_OFF_2H 
            __CONFIG  _CONFIG3H, _PBADEN_ON_3H & _LPT1OSC_OFF_3H & _PBADEN_ON_3H & _CCP2MX_PORTC_3H 
            __CONFIG  _CONFIG4L, _DEBUG_OFF_4L & _XINST_OFF_4L & _LVP_OFF_4L & _STVREN_ON_4L 
    endasm
    Definitions of the above are in your datasheet section 23.1

    once you have it and change your
    Code:
    DACAddressByte con %01001000
    to
    Code:
    DACAddressByte con %10010000
    it will produce this SCL signal
    <img SRC="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=2469&stc=1&d=120729308 0">

    and
    <img SRC="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=2468&stc=1&d=120729303 5">

    I2CWRITE send the ControlByte first, then the address.. it's the usual naming convention for EEPROM, in your case they named it another way to better fit with their own convention... but the sequence must be the same as in your datasheet...so the way you did.
    Attached Images Attached Images   
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

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