MCP41xxx Digital pot issue


Results 1 to 5 of 5

Threaded View

  1. #1
    Join Date
    Feb 2004
    Location
    Michigan, USA
    Posts
    305

    Default MCP41xxx Digital pot issue

    I cant seem to get a MCP41100 single digital pot to work. The wiper is always at mid point. I've tried many different things to get this working but just no luck. Can anyone see what the issue might be? There's data out to the pot and timings seem fine so I have no idea what is going wrong at this point.

    On a second look - it seems the SCK pin is going high at the start of data and then low after the 16 bits have been sent. Shouldn't it go high and low for each bit sent?

    Code:
    Define OSC 48
    Define	ADC_BITS	  10	' Set number of bits in result
    Define	ADC_CLOCK	   3	' Set clock source (3=rc)
    Define	ADC_SAMPLEUS  50	' Set sampling time in uS
    Include "modedefs.bas"
    SCK     var     PORTB.1     ' Alias PORTC.3 to SCK (serial data clock)
    SDO     var     PORTA.5     ' Alias PORTC.5 to SDO (serial data out)
    CS      var     PORTB.2     ' Alias PORTC.2 to C_EN (chip enable)
    POT0    var     byte        ' 
    increment var byte
    increment = 0
    
    TRISA = %11011111	' Set PORTA to all input except 5
       ADCON1 = %00000000	' Set PORTA analog and right justify result
       ADCON2.7=1
    TRISB = %00011001
    TRISC = %01000000
    
            HIGH    CS                  'Chip enable high to start
            high    sck                 'Mode 1,1 SCK idles high
    
    loop1
    increment = increment + 1 
    write 0, increment
    
    pot0 = %00010001
           
    GOSUB   write_pots
    goto loop1       
          
    WRITE_POTS:                                 
    
            low     CS                          ' Make chip active
            shiftout    sdo,sck,5,[pot0,increment]     ' Mode 1,1 / Mode 5 PBP - clock idles high, MSB shift out first
            high    CS                          ' 
            
    return
    
    End
    Last edited by jmgelba; - 16th February 2016 at 18:51.

Similar Threads

  1. Digital Pot
    By TONIGALEA in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 3rd January 2012, 07:54
  2. Digital Pot
    By Tastature in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 29th July 2008, 16:20
  3. Controlling A Digital Pot
    By TonyA in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 27th April 2006, 21:30
  4. Digital Pot
    By Scott in forum General
    Replies: 6
    Last Post: - 14th September 2005, 01:31
  5. Microchip MCP41xxx Digital Potentiometer Code Trouble
    By CocaColaKid in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 31st August 2005, 18:21

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