Microchip MCP41xxx Digital Potentiometer Code Trouble


Results 1 to 4 of 4

Threaded View

  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.

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 : 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