Indexing port pins for serout2/serin2


Closed Thread
Results 1 to 10 of 10

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default

    I was hoping there was an easy answer to this and someone would post, "You silly you have to do it this way...." or "Yes that code should work by you forgot about some setting in the programer." Hrm, I guess I'll go back to hacking away at the keyboard on Monday.

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


    Did you find this post helpful? Yes | No

    Default

    You can use pin "Numbers".

    But the pins will need to be grouped within 2 full ports, instead of scattered like you've shown.
    Preferably PORTB and PORTC.
    0-7 is PORTB, 8-15 is PORTC, but they can be changed in the 16F877.bas file.

    Code:
    for i = 0 to 15
        serout2 i, 8276, ["hello, this is PIN# ",DEC i]
        PAUSE 300
    next i
    DT

  3. #3


    Did you find this post helpful? Yes | No

    Default

    Using the pin "number" was the first thing I tried because I saw them do it in the PBP manual. But when I implemented it I couldn't make any sense of how the "numbers corresponded to the actual ABCDE Ports. And for some 2 different "numbers" I can't remember which ones, would correspond to data coming out on the same pin.

    Why is PORTB.O = "number" 0 ? Where is PORTA?


    This is what is in my .bas file:

    '************************************************* ***************
    '* 16F877.BAS *
    '* *
    '* By : Leonard Zerman, Jeff Schmoyer *
    '* Notice : Copyright (c) 1998 microEngineering Labs, Inc. *
    '* All Rights Reserved *
    '* Date : 10/23/98 *
    '* Version : 2.11 *
    '* Notes : *
    '************************************************* ***************

    BANK0 $0020, $007F
    BANK1 $00A0, $00EF
    BANK2 $0110, $016F
    BANK3 $0190, $01EF
    EEPROM $2100, $21FF
    LIBRARY "PBPPIC14"
    DEFINE CODE_SIZE 8

    include "PIC14EXT.BAS"

    PORTL VAR PORTB
    PORTH VAR PORTC
    TRISL VAR TRISB
    TRISH VAR TRISC

    include "PBPPIC14.RAM"

    '*-----------------------* EOF 16F877.BAS *---------------------*

    here is my .inc:

    ;************************************************* ***************
    ;* 16F877.INC *
    ;* *
    ;* By : Leonard Zerman, Jeff Schmoyer *
    ;* Notice : Copyright (c) 2003 microEngineering Labs, Inc. *
    ;* All Rights Reserved *
    ;* Date : 11/07/03 *
    ;* Version : 2.45 *
    ;* Notes : *
    ;************************************************* ***************
    NOLIST
    ifdef PM_USED
    LIST
    include 'M16F87x.INC' ; PM header
    device pic16F877, xt_osc, wdt_on, pwrt_on, lvp_off, protect_off
    XALL
    NOLIST
    else
    LIST
    LIST p = 16F877, r = dec, w = -302
    INCLUDE "P16F877.INC" ; MPASM Header
    __config _XT_OSC & _WDT_ON & _PWRTE_ON & _LVP_OFF & _CP_OFF
    NOLIST
    endif
    LIST

    Thanks for the reply!

  4. #4


    Did you find this post helpful? Yes | No

    Default

    You can use pin "Numbers".

    But the pins will need to be grouped within 2 full ports, instead of scattered like you've shown.
    Preferably PORTB and PORTC.
    0-7 is PORTB, 8-15 is PORTC, but they can be changed in the 16F877.bas file.

    Can I add ports A D and E somehow to the BAS file? I screwed aroud with trying to change the ports during runtime, but that doesn't seem to work.



    for i = 0 to 15
    serout2 i, 8276, ["hello, this is PIN# ",DEC i]
    PAUSE 300
    next i

    i = 0
    PORTL = A
    PORTH = D
    TRISL = A
    TRISH = D

    for i = 0 to 15
    serout2 i, 8276, ["hello, this is PIN# ",DEC i + 16]
    PAUSE 300
    next i

    next i

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