Word Variable and I2C


Results 1 to 9 of 9

Threaded View

  1. #8
    Join Date
    Jun 2009
    Location
    Sc*nthorpe, UK
    Posts
    333


    Did you find this post helpful? Yes | No

    Default Re: Word Variable and I2C

    Although the registers are described as 12 bit they do have 8 bit and 4 bit portions that are accessible separately.

    7.3.3 LED output and PWM control
    The turn-on time of each LED driver output and the duty cycle of PWM can be controlled
    independently using the LEDn_ON and LEDn_OFF registers.
    There will be two 12-bit registers per LED output. These registers will be programmed by
    the user. Both registers will hold a value from 0 to 4095. One 12-bit register will hold a
    value for the ON time and the other 12-bit register will hold the value for the OFF time. The
    ON and OFF times are compared with the value of a 12-bit counter that will be running
    continuously from 0000h to 0FFFh (0 to 4095 decimal).
    Update on ACK requires all 4 PWM channel registers to be loaded before outputs will
    change on the last ACK

    Example 1: (assumes that the LED0 output is used and
    (delay time) + (PWM duty cycle) ≤ 100 %)
    Delay time = 10 %; PWM duty cycle = 20 % (LED on time = 20 %; LED off time = 80 %).
    Delay time = 10 % = 409.6 ~ 410 counts = 19Ah.
    Since the counter starts at 0 and ends at 4095, we will subtract 1, so delay time = 199h
    counts.
    LED0_ON_H = 1h; LED0_ON_L = 99h
    LED on time = 20 % = 819.2 ~ 819 counts.
    Off time = 4CCh (decimal 410 + 819 − 1 = 1228)
    LED0_OFF_H = 4h; LED0_OFF_L = CCh

    I read this to mean that you need four i2c write statements
    led0_on_h = 1h
    led0_on_l =99h
    led0_off_h = 4h
    led0_off_l =cch

    but maybe the registers will auto increment and only one i2c write statement is required.

    I could be wrong and I have no way to test my interpretation.
    Last edited by EarlyBird2; - 20th May 2014 at 06:51. Reason: More thoughts

Similar Threads

  1. Stumped with word variable
    By Scampy in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 11th November 2013, 13:11
  2. Word variable and storing correct value
    By Scampy in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 28th December 2012, 12:04
  3. SEROUT WORD variable problem
    By Tobias in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 19th April 2009, 11:20
  4. adding new word variable ?
    By iugmoh in forum General
    Replies: 4
    Last Post: - 21st February 2008, 00:26
  5. word variable to 25lc640
    By TONIGALEA in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 6th July 2004, 19:59

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