Question on SPI Data out on PortC.7(pic18f4550)


Closed Thread
Results 1 to 10 of 10

Hybrid View

  1. #1
    Join Date
    Jun 2011
    Location
    Philippines
    Posts
    223


    Did you find this post helpful? Yes | No

    Default Re: Question on SPI Data out on PortC.7(pic18f4550)

    I'm trying to figure it out this block of code from SDFS how to make disable hardware SPI.
    Code:
    ' Initialize some values for the following subroutines
    	SDC_UseHardSPI = TRUE	' Use hardware SSP port for SPI.
    	DISK_mount = FALSE	' The card has not been initialized.
    	FAT_mode = "r"		' Read mode if not otherwise specified.
    	FAT_count = 0		' Default character count to 0.
    
    ' Skip over SD/MMC/FAT subroutines
    	Goto SkipSD
    
    
    ' Subroutines for communicating with an SD/MMC card
    ' Subroutine to initialize SD card pins
    InitIO:
    	SD_CS = 1		' SD card not selected.
    	SD_CS_TRIS = 0		' Output SD card chip select.
    	SD_CD_TRIS = 1		' Input card detect.
    
    	SDO = 1			' Start SPI data out high.
    	SDO_TRIS = 0		' Output SPI data out.
    	SDI_TRIS = 1		' Input SPI data in.
    	SCL = 1			' SPI clock idles high.
    	SCL_TRIS = 0		' Output SPI clock.
    	Return
    
    
    ' Subroutine to initialize hardware SSP for SPI at less than 400kHz
    OpenSPIM:
    	If (SDC_UseHardSPI) Then
    		SSPSTAT = %00000000	' Sample at middle of data output time, Mode 1, 1: Transmit on idle to active clock transition.
    		SSPCON1 = %00010010	' SPI master mode, clock = Fosc/64, Mode 1, 1: Clock idle high.
    		SSPEN = 1		' Enable hardware SPI port.
    	Endif
    	Return
    
    
    ' Subroutine to initialize hardware SSP for SPI at full speed
    OpenSPIMFast:
    	If (SDC_UseHardSPI) Then
    		SSPSTAT = %00000000	' Sample at middle of data output time, Mode 1, 1: Transmit on idle to active clock transition.
    		SSPCON1 = %00010000	' SPI master mode, clock = Fosc/64, Mode 1, 1: Clock idle high.
    		SSPEN = 1		' Enable hardware SPI port.
    	Endif
    	Return
    
    
    ' Subroutine to release hardware SSP from SPI
    CloseSPIM:
    	If (SDC_UseHardSPI) Then
    		SSPEN = 0		' Disable hardware SPI port.
    	Endif
    	Return
    But not really sure what to do? Hope anyone can help out...

    /tacbanon

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: Question on SPI Data out on PortC.7(pic18f4550)

    Hi,
    I've never used that code but I'd probably try SDC_UseHardwareSPI = FALSE.
    However, don't change the SDFS.pbp file. INCLUDE it in your program and ADD SDC_UseHardwareSPI = FALSE after including it (see the example) - it will "overwrite" the default setting.

    /Henrik.

  3. #3
    Join Date
    Jun 2011
    Location
    Philippines
    Posts
    223


    Did you find this post helpful? Yes | No

    Default Re: Question on SPI Data out on PortC.7(pic18f4550)

    Hi Henrik,
    Thanks for the response, I will try it and post here my result.

    Kind regards,
    tacbanon

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: Question on SPI Data out on PortC.7(pic18f4550)

    /Henrik is correct.

    This example may help.
    http://www.picbasic.co.uk/forum/cont...USB-SD-LOGGING
    I did comment out the pin alias in SDFS so I could change things around in my code without bothering with opening the include.
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Jun 2011
    Location
    Philippines
    Posts
    223


    Did you find this post helpful? Yes | No

    Default Re: Question on SPI Data out on PortC.7(pic18f4550)

    @Dave
    Sorry for the late reply...thanks for the link..got it to work now.

    /tacbanon

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