Clock connection to DS1802 from 16F877A


Closed Thread
Results 1 to 8 of 8

Hybrid View

  1. #1
    Join Date
    Aug 2005
    Location
    Vermont
    Posts
    15


    Did you find this post helpful? Yes | No

    Default Datasheets

    I fully understand how overwhelming they can be. I've been trying to get my head wrapped around the DS2406 datasheet and trying to understand how the one wire commands can be used to communicate with them. It's less than clear on several points. Good luck with your project.

  2. #2
    Join Date
    Oct 2005
    Location
    Las Vegas, Nevada, USA
    Posts
    27


    Did you find this post helpful? Yes | No

    Talking Easier than I thought it would be

    I didn't realize that just designating a "CLK" pin on the 16F877A is all that was needed. I was under the impression that I had to somehow place a square wave on the "CLK" pin for the DS1802's reference. I used a 4 MHz crystal on the 16F877A. The following relevant code works great for reading pot values from the DS1802 and displaying the pot values on an Optrex LCD:


    INCLUDE "modedefs.bas"

    @ DEVICE XT_OSC, WDT_OFF, LVP_OFF, BOD_OFF, PWRT_ON, PROTECT_OFF

    DEFINE LCD_DREG PORTA ' RA to LCD data port
    DEFINE LCD_DBIT 0 ' Starting data bit on A0 & last on A3
    DEFINE LCD_BITS 4 ' Set 4-bit data bus width
    DEFINE LCD_RSREG PORTA ' Set LCD register select port to A
    DEFINE LCD_RSBIT 4 ' Set A4 to register select pin
    DEFINE LCD_EREG PORTE ' Set LCD enable to port E
    DEFINE LCD_EBIT 0 ' Set E0 to LCD enable pin
    DEFINE LCD_LINES 4 ' LCD is a 4 line display
    DEFINE LCD_COMMANDUS 2000 ' Set LCD command delay time in uS
    DEFINE LCD_DATAUS 50 ' Set LCD data delay time in uS

    ADCON1 = 7 ' Digital I/O for RA & RE
    INTCON.7 = 1 ' Enable all unmasked interrupts (GIE)
    TRISB = 255 ' All PORTB pins as inputs for panel switches
    OPTION_REG.7 = 0 ' Enable all PORTB internal pull-ups
    RST var PORTD.5 ' Set high to read potentiometer settings
    RST = 0
    CLK var PORTE.1 ' Clock DS1802 to read potentiometer settings
    ReadPots var PORTE.2 ' Read potentiometer settings
    LPot var byte ' Left channel
    RPot var byte ' Right channel

    pause 500
    LCDOUT 254, 12 ' Turn cursor off & display on
    lcdout 254, 1 ' Clear display
    pause 200
    lcdout 254, 135, "Volume"
    gosub update_lcd

    MAIN:
    if PORTB <> 255 THEN

    endif
    GOTO MAIN

    UPDATE_LCD:
    RST = 1
    shiftin readpots, clk, LSBPRE, [lpot, rpot]
    rst = 0
    lpot = lpot & %00111111
    rpot = rpot & %00111111
    if lpot < 10 then
    lcdout 254, 194, "L:-", #lpot, "db ", " R:-", #rpot, "db "
    else
    lcdout 254, 194, "L:-", #lpot, "db", " R:-", #rpot, "db "
    endif
    return

Similar Threads

  1. Single digit 7 Seg LED clock - PIC16F88
    By thirsty in forum Code Examples
    Replies: 4
    Last Post: - 17th July 2009, 08:42
  2. EM4095 Chip, get Clock and Data signals?
    By mindthomas in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 19th August 2008, 06:27
  3. Shiftout/in
    By BobEdge in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 23rd August 2007, 11:48
  4. Help with sound command in 2 programs
    By hyperboarder in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th July 2007, 20:36
  5. LCD Clock, Interrup
    By Patrick in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 16th July 2006, 16: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