18f242 Mssp


Closed Thread
Results 1 to 5 of 5

Thread: 18f242 Mssp

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

    Default 18f242 Mssp

    I am working with the 18F242 MSSP configured for a master SPI. It is not working for me, and wondered if anyone could shed some light. I have read the (fine) manual until my fingers are dog eared. Double checked all settings for the registers, but near as I can tell, there are still no comms. To double check that the protocol worked, I used shiftin/shiftout with the same pins, and everything works fine.
    When I flip the control bit for SPI enable, I get a clock, I believe I am getting data out, but for input, I get the dummy data I put in SSPBUF to initiate a transfer. What am I missing?

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


    Did you find this post helpful? Yes | No

    Default

    I forgot the register set up. Sorry...

    ; MSSP REGISTER SETUP
    BF VAR SSPSTAT.0 ; Buffer full status
    CKE var SSPSTAT.6
    SMP var SSPSTAT.7
    WCOL VAR SSPCON1.7 ;Transmit write collision detect bit
    SSPEN VAR SSPCON1.5 ; Enable MSSP
    CKP var SSPCON1.4
    SDI var PORTC.4 ; Synchronous data input
    SDO var PORTC.5 ;Synch data output
    SCK VAR PORTC.3 ;Synch clock output


    SSPSTAT = %10000000
    SSPCON1 = %00010010 ; SS port enable,idle high,SPI master clock/16
    '************************************************* ****************
    Main:
    UART_SPI = 0
    TRISC.2 = 0 :TRISC.3 = 0 :TRISC.4 = 1:TRISC.5 = 0 :TRISA.5 = 1
    SMP = 0 : CKE = 0 : CKP = 1
    Alfat_power = 1
    pause 1500

    I enable the SPI a little later in the program

  3. #3
    Join Date
    Aug 2005
    Posts
    57


    Did you find this post helpful? Yes | No

    Default

    I believe the key to making it work was the pir1.3 interrupt.I used the MSSI port a while back with a Max1270 A/D chip.Attached is that code,look under Data Aquisition.
    Attached Files Attached Files

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by arniepj
    I believe the key to making it work was the pir1.3 interrupt.I used the MSSI port a while back with a Max1270 A/D chip.Attached is that code,look under Data Aquisition.
    I will try this, but...
    I am not using an interrupt in this application. Does it still need to be reset after every transmission?

    Ron

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


    Did you find this post helpful? Yes | No

    Default

    O.K. I got it up and runnung. The interrupt flag idea led me to check all the flag bits. It turned out the buffer full flag was put in the wrong place and the program was running past the buffer before it was full. Thanks for the lead.

    Ron

Similar Threads

  1. 18f242 serin2 timeout
    By Armadus in forum Serial
    Replies: 1
    Last Post: - 28th July 2007, 22:41
  2. PIC 18F242 not starting
    By manxman in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 14th March 2007, 17:00
  3. MSSP Hardware module
    By crematory in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 8th August 2005, 14:32
  4. Mssp
    By PICtron in forum Serial
    Replies: 4
    Last Post: - 2nd August 2005, 17:42
  5. Mssp
    By capitano in forum Code Examples
    Replies: 2
    Last Post: - 15th December 2004, 19:33

Members who have read this thread : 1

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