IC2 pic 18f452 program problems


Closed Thread
Results 1 to 8 of 8

Hybrid View

  1. #1
    Join Date
    Jul 2007
    Posts
    53


    Did you find this post helpful? Yes | No

    Question Then why is there a specific SCL and SDA pins on the datasheet?

    Hi Darrel!

    Quote Originally Posted by Darrel Taylor View Post
    The SDA and SCL can be on almost any pin. Just specify them in the I2CWRITE statement.
    I know you're right, but then what's is the purpose of having specific pins listed in the datasheet for SCL and SDA? (I'm using PIC184620)

    Is there any difference between those pins and any others regarding I2C?


    J-P

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


    Did you find this post helpful? Yes | No

    Default

    The dedicated SCL/SDA pins are for the SSP (Synchronous Serial Port).
    The SSP module can do SPI or I2C, in Master or Slave modes.

    The I2CWRITE/I2CREAD are bit bang routines that don't use the Hardware SSP, so they can use almost any pin as SDA and SCL.

    There aren't any PBP commands that use the SSP directly.
    <br>
    DT

  3. #3
    MrSafe's Avatar
    MrSafe Guest


    Did you find this post helpful? Yes | No

    Default

    thank you I have solved it.

    I have another problem I have a loop set up to where it sends messages out until the user presses a key.

    example:

    while key != 15

    gosub getkey

    serout PORTD.0, T1200, [X]

    wend
    To clarify this program sends data the first time but then waits for a user to press a key(other than 15) before sending the data again when it should send the data until the user presses a key (15).

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


    Did you find this post helpful? Yes | No

    Default

    If your getkey subroutine doesn't return if no keys are pressed, it'll do what you are describing.

    But it's hard to say whats wrong without seeing the getkey subroutine.
    <br>
    DT

  5. #5
    MrSafe's Avatar
    MrSafe Guest


    Did you find this post helpful? Yes | No

    Default

    Heres the subroutine for get key


    '---- Subroutine to Key from keypad ----
    '
    getkey:
    ;
    key = 0
    PortC = 0 ' all outputs pins low
    TrisC = $f0 ' bottom 4 pins out, top 4 pins in
    ;
    input PORTC
    ;
    pause 250
    ;
    PORTC = %11111110 ' row 1
    ;
    if PORTC.4 = 0 then
    key = 1
    return
    endif
    ;
    if PORTC.5 = 0 then
    key = 2
    return
    endif
    ;
    if PORTC.6 = 0 then
    key = 3
    return
    endif
    ;
    if PORTC.7 = 0 then
    key = 12
    return
    endif
    ;
    PORTC = %11111101 ' row 2
    ;
    if PORTC.4 = 0 then
    key = 4
    return
    endif
    ;
    if PORTC.5 = 0 then
    key = 5
    return
    endif
    ;
    if PORTC.6 = 0 then
    key = 6
    return
    endif
    ;
    if PORTC.7 = 0 then
    key = 13
    return
    endif
    ;
    PORTC = %11111011 ' row 3
    ;
    if PORTC.4 = 0 then
    key = 7
    return
    endif
    ;
    if PORTC.5 = 0 then
    key = 8
    return
    endif
    ;
    if PORTC.6 = 0 then
    key = 9
    return
    endif
    ;
    if PORTC.7 = 0 then
    key = 14
    return
    endif
    ;
    PORTC = %11110111 ' row 4
    ;
    if PORTC.4 = 0 then
    key = 10
    return
    endif
    ;
    if PORTC.5 = 0 then
    key = 0
    return
    endif
    ;
    if PORTC.6 = 0 then
    key = 11
    return
    endif
    ;
    if PORTC.7 = 0 then
    key = 15
    return
    endif
    ;
    goto getkey
    return
    ;
    gotkey:
    key = (col * 4) + (ncd (row ^ $f))
    '
    return
    '
    end

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


    Did you find this post helpful? Yes | No

    Default

    Comment out the goto getkey just before GotKey:

    That will keep it from waiting for a key before proceeding.
    <br>
    DT

Similar Threads

  1. Presetting Configuration Fuses (PIC Defines) into your Program
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 82
    Last Post: - 15th December 2013, 10:54
  2. Replies: 288
    Last Post: - 25th August 2008, 17:53
  3. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 09:26
  4. Replies: 14
    Last Post: - 26th September 2007, 06:41
  5. Which pic has a big flash program memory?
    By amindzo in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 1st November 2006, 20:35

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