Replace Shiftout with spi


Closed Thread
Results 1 to 12 of 12

Hybrid View

  1. #1
    Join Date
    Sep 2003
    Location
    Vermont
    Posts
    373


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e
    euh.. SHIFTOUT is already SPI!

    Give us more details!
    I believe Pedro means hardware SPI. With that assumption, it would be good to know which processor you are working with Pedro. Shiftout/in works very well and it's easy(Thanks Melabs!) buuuuut... It can be slow. How fast do you need to go?

    Ron

  2. #2
    Join Date
    Jul 2006
    Posts
    60


    Did you find this post helpful? Yes | No

    Default

    Hi Ron

    Yes, i mean the hardware SPI
    Like You say the Shifout work very good but it is slow, i need to send a byte
    quickly to a lcd and perhaps with the hardware SPI pin can i have more speed
    The controller that i use is PIC 18F452

    Have You a sample code to do that, don't forget it must sent the MSBFIRST

    Thanks

    Regards

    Pedro

  3. #3
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Pedro,

    There's a sample SPI program on the meLabs website.

    http://www.melabs.com/resources/samples.htm

    Look for spimast.bas

    HTH,
    DT

  4. #4
    Join Date
    Jul 2006
    Posts
    60


    Did you find this post helpful? Yes | No

    Default

    Hi

    Yes i see the sample on melabs site but don't understand how to sent
    with the spi out pin the msbit first, say bit7, bit6, bit5, ... bit0

    Thanks for help
    Pedro

  5. #5
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    The MSSP always sends data MSB first.
    <br>
    DT

  6. #6
    Join Date
    Jul 2006
    Posts
    60


    Did you find this post helpful? Yes | No

    Default

    Hello Darrel

    my board work correct with this instruction
    Shiftout sdata , sclk ,MSBFIRST, [var_out]

    Do You know the correct SPI setup to use the hardware SPI to do that?

    I try with this and have no function
    'spi setup
    SSPEN VAR SSPCON1.5 'SSP Enable bit
    CKP VAR SSPCON1.4 'Clock Polarity Select
    SMP VAR SSPSTAT.7 'Data input sample phase
    CKE VAR SSPSTAT.6 'Clock Edge Select bit

    TRISC = 0

    CKP = 0 'clock idle low 'have changed to 1 for testing but no ok
    CKE = 0 'transmit on idle to active transition 'have changed to 1 for testing
    'but no ok
    SSPIF = 0 'clear SPI interrupt
    SMP = 0

    main:
    SSPEN = 1 'enable SPI pins
    SSPBUF = var_out 'send array variable
    Return

    Have a idea how to fix that?

    Thank You

    Regards

    Pedro

  7. #7
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    For MSBFIRST, you have it correct.

    CKP = 0
    CKE = 0

    Which PIC are you using?
    What OSC frequency are you using?
    What is it sending data to?

    Are you connected to the SDO/SCK pins of the pic?
    SDO(PIC) to SDI(slave), AND SCK(PIC) to SCK(slave).

    Also, in this code...
    Code:
    main:
        SSPEN = 1 'enable SPI pins 
        SSPBUF = var_out 'send array variable
    Return
    Since no subroutine was called, the program will reset when it gets to the Return.
    <br>
    DT

Similar Threads

  1. 7 Segment Displays and MAX7219
    By Bill Legge in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 31st October 2010, 19:30
  2. Smart Star (how to use shift registers)
    By mackrackit in forum Code Examples
    Replies: 3
    Last Post: - 30th November 2008, 21:06
  3. Using SPI with External Interrupts
    By shaiqbashir in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 29th June 2008, 05:08
  4. 16-bit SPI problem
    By shaiqbashir in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 19th June 2008, 16:42
  5. SPI instead of SHIFTOUT - MAX7219
    By Momboz in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 26th April 2008, 23:58

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