Weird SPI interface: VIH to VIHH for CS?


Closed Thread
Results 1 to 10 of 10

Hybrid View

  1. #1
    Join Date
    Jan 2009
    Location
    Huntsville, AL
    Posts
    37


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    move res=24 before your repeatit label may help

    Maybe not a bad idea to set the clock LOW at the top of your code.
    Good catch. But even with the res=24 inside the loop, I'm still reading 100k across the wipers and the A terminals, and low resistance across the wipers and the B terminals. I slowed down the clock with a "define shift_pauseus 100", took the res=24 outside the loop, but still can't see any changes in resistance. Here's my adjusted code:

    --------------------
    cmcon=7
    define osc 8
    define shift_pauseus 100

    res var byte

    CS var porta.2 'CS
    CLK var porta.3 'CLK
    SI var porta.4 'SI
    LED var porta.1 'LED

    high CS
    high LED
    pause 500
    low LED
    pause 500
    high LED

    res=24

    repeatit:
    low CS
    shiftout SI,CLK,1,[%00000000\8,res\8]
    high CS
    pause 10
    low CS
    shiftout SI,CLK,1,[%00010000\8,res\8]
    high CS
    pause 500
    res=res+32
    goto repeatit

    end
    --------------------
    I also have 10k resistors between the MCP4261 pins and the 16F628A pins, but that shouldn't affect anything.

    WP and SHDN can be left floating, right? Am I correctly formatting the command byte? Aren't the memory locations %0000 and %0001 the correct ones to address?

    Thanks for the help!
    Dave

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    I wouldn't leave a pin floating myself, mainly SHDN. On the other hand, by their specs, they says there's a "Smart Pull-Up" inside... how smart it is... who knows

    Your code seems to be ok to me, but you still haven't added the LOW CS in there... not sur if this could help though...

    PS: Make sure your DEFINEs are all in UPPERCASE.

    Do you have a PICKIT 2? in this case you could monitor what happen on CS/CLK/SDI and SDO

    Do you have a complete schematic of your thing?

    EDIT: Try this one
    Code:
            define OSC 8
            
            cmcon=7
            res var byte
            Command var WORD
            CS var porta.2 'CS
            CLK var porta.3 'CLK
            SI var porta.4 'SI
            LED var porta.1 'LED
            
            high CS
            LOW CLK
            high LED
            pause 500
            low LED
            pause 500
            high LED
            
            res=24
    
    repeatit:
            command.highbyte=0 ' Volatile Wiper 0
            comand.lowbyte=res
            low CS
            shiftout SI,CLK,1,[command\16]
            high CS
            
            pause 10
            
            Command.HighByte=%00010000  ' Volatile Wiper 1    
            low CS
            shiftout SI,CLK,1,[Command\16]
            high CS
            
            pause 500
            res=res+32
            
            goto repeatit
    Last edited by mister_e; - 29th January 2009 at 06:45.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Jan 2009
    Location
    Huntsville, AL
    Posts
    37


    Did you find this post helpful? Yes | No

    Default

    It still wasn't working... until I changed out the 10k resistors with 500 ohms. Apparently the 10k were too high. Maybe there's an internal pull up or down that was low enough to prevent the pin from reaching the required voltage threshold.

    What pins should I be worried about protecting anyway? CS, SI, SO, CLK, etc?

    Thanks,
    Dave

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    I also have 10k resistors between the MCP4261 pins and the 16F628A pins, but that shouldn't affect anything.
    .
    .
    .
    .
    It still wasn't working... until I changed out the 10k resistors with 500 ohms.
    Are you saying that your 10K resistor where in serie between the PIC and the MCP chip?

    If so, you just don't need any, connect them directly. The only concern you may have, is the open-collector ones. In this case 10K or lower are nice between 5V and your pin.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    Join Date
    Jan 2009
    Location
    Huntsville, AL
    Posts
    37


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    Are you saying that your 10K resistor where in serie between the PIC and the MCP chip?

    If so, you just don't need any, connect them directly. The only concern you may have, is the open-collector ones. In this case 10K or lower are nice between 5V and your pin.
    Yeah, I usually put them on to prevent burning out a pin on accident. What pins are considered "open-collector"? Do CS, CLK, and SI typically have internal resistors that limit current flow? What about SO?

    Thanks!
    Dave

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    What you need to worry is your PIC I/O, some could be Open-Collector type, so if you use a open collector I/O as output, you need to add a pull-up resistor on it, unless your pin will never go to the high level unless your device have internal pull-up.

    If you want to protect your PIC i/O from short, then use something like ~100-200 Ohm would work. In theory each I/O is capable to drive/sink 25mA... 5V/25mA=200 Ohms. Higher the current limiting + Faster your signal is, higher the chance to screw up your signal shape/edges/amplitude, higher the chance to have issue.


    As you don't use Shiftin, you don't need to worry about SO
    Last edited by mister_e; - 30th January 2009 at 17:27.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. Master SPI interface to LCD/OLED??
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 19th September 2009, 23:44
  2. need help for APR6008 SPI interface
    By vu2iia in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 30th June 2009, 03:19
  3. 16-bit SPI problem
    By shaiqbashir in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 19th June 2008, 15:42
  4. Help with MicroMag3 SPI interface to PIC
    By kaan in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 31st May 2006, 23:20
  5. Serial Peripheral Interface (SPI)
    By O2_Guy in forum Serial
    Replies: 1
    Last Post: - 22nd March 2006, 20:01

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