Mssp


Closed Thread
Results 1 to 3 of 3

Thread: Mssp

  1. #1
    capitano's Avatar
    capitano Guest

    Post Mssp

    Sorry for my english
    I am an italian student.
    This is my problem:

    I need to connect a eeprom 24C64 at PIC 16F877 and i didn'know how set MSSP module.
    I wouldn't use I2C read and write command

    I like code sample for MSSP
    thank you!!

  2. #2
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    Christian,

    there will be more chance to find a solution to your problem if you would post your code here rather than sending PMs only.
    (With your code on the board many people could have a look at it and reply)

    Please shrink the code down to the necessary to make it readable.

    regards

    Ralph

  3. #3
    capitano's Avatar
    capitano Guest


    Did you find this post helpful? Yes | No

    Default mssp

    I have find the routine for mssp. It work fine


    'Impostazioni modulo MSSP
    SSPCON.5=1
    SSPCON.3=1
    SSPCON.2=0
    SSPCON.1=0
    SSPCON.0=0
    SSPCON2=0
    SSPSTAT.7=0
    SSPSTAT.6=0

    SSPADD= 24 ' Freq di clock 100 KHz a 10 MHz

    '------------------------------------------------
    ' Subroutine Tx su bus I2C per indirizzi a 16 bit
    :I2CSendw
    gosub I2CStart
    SSPBUF = addressbus
    gosub I2CWait
    SSPBUF = address.lowbyte
    gosub I2CWait
    SSPBUF = address.highbyte
    gosub I2CWait
    SSPBUF = dati
    gosub I2CWait
    gosub I2CStop
    Return

    '------------------------------------------------
    ' Subroutine Rx su bus I2C per indirizzi a 16 bit

    :I2CReceivew

    gosub I2CStart
    SSPBUF = addressbus
    gosub I2CWait
    SSPBUF = address.lowbyte
    gosub I2CWait
    SSPBUF = address.highbyte
    gosub I2CWait
    gosub I2CRestart
    SSPBUF = addressbus + 1
    gosub I2CWait

    while ( SSPSTAT.2=1 )
    WEND

    SSPCON2.3=1
    Gosub I2CWait
    dati=SSPBUF
    gosub I2CNak
    gosub I2CStop

    Return


    '------------------------------------------------
    ' Subroutine Rx su bus I2C per indirizzi a 8 bit
    :I2CReceive

    gosub I2CStart
    SSPBUF = addressbus
    gosub I2CWait
    SSPBUF = address.lowbyte
    gosub I2CWait
    gosub I2CRestart
    SSPBUF = addressbus + 1
    gosub I2CWait

    while ( SSPSTAT.2=1 )
    WEND

    SSPCON2.3=1
    Gosub I2CWait
    dati=SSPBUF
    gosub I2CNak
    gosub I2CStop

    Return

    '------------------------------------------------
    ' Subroutine Tx su bus I2C per indirizzi a 8 bit
    :I2CSend
    gosub I2CStart
    SSPBUF = addressbus
    gosub I2CWait
    SSPBUF = address.lowbyte
    gosub I2CWait
    SSPBUF = dati
    gosub I2CWait
    gosub I2CStop
    Return

    '------------------------------------------------
    ' Subroutine MSSP I2C
    :I2CAck
    SSPCON2.5=0
    SSPCON2.4=1
    gosub I2CWait
    Return


    :I2CNak
    SSPCON2.5=1
    SSPCON2.4=1
    gosub I2CWait
    Return



    :I2CRestart
    SSPCON2.1=1
    GOSUB I2CWait
    Return


    :I2CStart
    SSPCON2.0=1
    GOSUB I2CWait
    Return



    :I2CStop
    SSPCON2.2=1
    GOSUB I2CWait
    Return


    :I2CWait
    while (PIR1.3=0)
    WEND
    PIR1.3=0
    Return



    In the mainprogram

    addressbus=$A0

    address=x
    dati=y
    gosub I2CSendw

Similar Threads

  1. HI2CREAD and HI2CWRITE
    By garryp4 in forum PBP Wish List
    Replies: 17
    Last Post: - 24th October 2008, 12:46
  2. i2c data com. to 24lc512 in freq counter
    By tamertokgoz in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 1st June 2008, 20:48
  3. 18f242 Mssp
    By Ron Marcus in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 13th November 2005, 04:29
  4. MSSP Hardware module
    By crematory in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 8th August 2005, 15:32
  5. Mssp
    By PICtron in forum Serial
    Replies: 4
    Last Post: - 2nd August 2005, 18:42

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