Microchip MCP41xxx Digital Potentiometer Code Trouble


Closed Thread
Results 1 to 4 of 4
  1. #1

    Default Microchip MCP41xxx Digital Potentiometer Code Trouble

    Can someone possibly explain to me why this code would not work? When I run it the digital pot does nothing.

    Code:
        si      var     portb.2
        sclk    var     portb.1
        cs      var     portb.0
    
        pot_value   var     byte
        data_word   var     word
    
        low     sclk    ' Set clock pin low
        high    cs      ' Set chip select low
    
        clear
        
    start:
        pot_value = pot_value + 1
        data_word.byte0 = %00010001     ' Set write instruction to potentiometer 0
        data_word.byte1 = pot_value     ' Set potentiometer value to be written
        gosub shout
        goto start                      
    
    shout:
        low cs
        shiftout si,sclk,1,[data_word\16]   ' Shift 16 bits out starting at bit0
        high cs
        return
    Last edited by CocaColaKid; - 31st August 2005 at 14:48.

  2. #2
    Join Date
    Aug 2005
    Posts
    2


    Did you find this post helpful? Yes | No

    Default

    Hello.
    Maybe you must first shiftout write command and after that shiftout value.

    Regards,
    Damir

  3. #3


    Did you find this post helpful? Yes | No

    Default

    I thought I orginally tried that way and it didn't work however it does now so I can only assume I had something missed. Anyways though, what I want to do is to daisy chain three of these together. According to the data sheets when a command comes in a NOP is sent out the serial output line which loads the 2nd chip with all 0's. Now if I issue this command now and add a NOP after it should it not push it into the 2nd chip?
    Last edited by CocaColaKid; - 31st August 2005 at 18:19.

  4. #4


    Did you find this post helpful? Yes | No

    Default

    I figured out the source to all my problems. I originally had the SPI lines on porte which didn't work so I moved them over to portb and then everything worked fine. The reason I had so my problems is because I forgot to sent porte to digital instead of analog, oops.

Similar Threads

  1. How much code space do PBP statements use.
    By Darrel Taylor in forum Code Examples
    Replies: 5
    Last Post: - 13th February 2009, 21:31
  2. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  3. Re-Writing IF-THEN-AND-ENDIF code?
    By jessey in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 18th August 2006, 17:23
  4. Code trouble
    By rocky79 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 24th August 2005, 12:31
  5. Timer PIC16F57
    By leonel in forum mel PIC BASIC Pro
    Replies: 25
    Last Post: - 1st July 2005, 08:14

Members who have read this thread : 1

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